babylon.module.d.ts 5.4 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824
  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. /**
  13660. * Gets the node used to drive the bone's transformation
  13661. * @returns a transform node or null
  13662. */
  13663. getTransformNode(): Nullable<TransformNode>;
  13664. /** Gets or sets current position (in local space) */
  13665. position: Vector3;
  13666. /** Gets or sets current rotation (in local space) */
  13667. rotation: Vector3;
  13668. /** Gets or sets current rotation quaternion (in local space) */
  13669. rotationQuaternion: Quaternion;
  13670. /** Gets or sets current scaling (in local space) */
  13671. scaling: Vector3;
  13672. /**
  13673. * Gets the animation properties override
  13674. */
  13675. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13676. private _decompose;
  13677. private _compose;
  13678. /**
  13679. * Update the base and local matrices
  13680. * @param matrix defines the new base or local matrix
  13681. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13682. * @param updateLocalMatrix defines if the local matrix should be updated
  13683. */
  13684. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13685. /** @hidden */
  13686. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13687. /**
  13688. * Flag the bone as dirty (Forcing it to update everything)
  13689. */
  13690. markAsDirty(): void;
  13691. /** @hidden */
  13692. _markAsDirtyAndCompose(): void;
  13693. private _markAsDirtyAndDecompose;
  13694. /**
  13695. * Translate the bone in local or world space
  13696. * @param vec The amount to translate the bone
  13697. * @param space The space that the translation is in
  13698. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13699. */
  13700. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13701. /**
  13702. * Set the postion of the bone in local or world space
  13703. * @param position The position to set the bone
  13704. * @param space The space that the position is in
  13705. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13706. */
  13707. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13708. /**
  13709. * Set the absolute position of the bone (world space)
  13710. * @param position The position to set the bone
  13711. * @param mesh The mesh that this bone is attached to
  13712. */
  13713. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13714. /**
  13715. * Scale the bone on the x, y and z axes (in local space)
  13716. * @param x The amount to scale the bone on the x axis
  13717. * @param y The amount to scale the bone on the y axis
  13718. * @param z The amount to scale the bone on the z axis
  13719. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13720. */
  13721. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13722. /**
  13723. * Set the bone scaling in local space
  13724. * @param scale defines the scaling vector
  13725. */
  13726. setScale(scale: Vector3): void;
  13727. /**
  13728. * Gets the current scaling in local space
  13729. * @returns the current scaling vector
  13730. */
  13731. getScale(): Vector3;
  13732. /**
  13733. * Gets the current scaling in local space and stores it in a target vector
  13734. * @param result defines the target vector
  13735. */
  13736. getScaleToRef(result: Vector3): void;
  13737. /**
  13738. * Set the yaw, pitch, and roll of the bone in local or world space
  13739. * @param yaw The rotation of the bone on the y axis
  13740. * @param pitch The rotation of the bone on the x axis
  13741. * @param roll The rotation of the bone on the z axis
  13742. * @param space The space that the axes of rotation are in
  13743. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13744. */
  13745. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13746. /**
  13747. * Add a rotation to the bone on an axis in local or world space
  13748. * @param axis The axis to rotate the bone on
  13749. * @param amount The amount to rotate the bone
  13750. * @param space The space that the axis is in
  13751. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13752. */
  13753. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13754. /**
  13755. * Set the rotation of the bone to a particular axis angle in local or world space
  13756. * @param axis The axis to rotate the bone on
  13757. * @param angle The angle that the bone should be rotated to
  13758. * @param space The space that the axis is in
  13759. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13760. */
  13761. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13762. /**
  13763. * Set the euler rotation of the bone in local of world space
  13764. * @param rotation The euler rotation that the bone should be set to
  13765. * @param space The space that the rotation is in
  13766. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13767. */
  13768. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13769. /**
  13770. * Set the quaternion rotation of the bone in local of world space
  13771. * @param quat The quaternion rotation that the bone should be set to
  13772. * @param space The space that the rotation is in
  13773. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13774. */
  13775. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13776. /**
  13777. * Set the rotation matrix of the bone in local of world space
  13778. * @param rotMat The rotation matrix that the bone should be set to
  13779. * @param space The space that the rotation is in
  13780. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13781. */
  13782. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13783. private _rotateWithMatrix;
  13784. private _getNegativeRotationToRef;
  13785. /**
  13786. * Get the position of the bone in local or world space
  13787. * @param space The space that the returned position is in
  13788. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13789. * @returns The position of the bone
  13790. */
  13791. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13792. /**
  13793. * Copy the position of the bone to a vector3 in local or world space
  13794. * @param space The space that the returned position is in
  13795. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13796. * @param result The vector3 to copy the position to
  13797. */
  13798. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13799. /**
  13800. * Get the absolute position of the bone (world space)
  13801. * @param mesh The mesh that this bone is attached to
  13802. * @returns The absolute position of the bone
  13803. */
  13804. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13805. /**
  13806. * Copy the absolute position of the bone (world space) to the result param
  13807. * @param mesh The mesh that this bone is attached to
  13808. * @param result The vector3 to copy the absolute position to
  13809. */
  13810. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13811. /**
  13812. * Compute the absolute transforms of this bone and its children
  13813. */
  13814. computeAbsoluteTransforms(): void;
  13815. /**
  13816. * Get the world direction from an axis that is in the local space of the bone
  13817. * @param localAxis The local direction that is used to compute the world direction
  13818. * @param mesh The mesh that this bone is attached to
  13819. * @returns The world direction
  13820. */
  13821. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13822. /**
  13823. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13824. * @param localAxis The local direction that is used to compute the world direction
  13825. * @param mesh The mesh that this bone is attached to
  13826. * @param result The vector3 that the world direction will be copied to
  13827. */
  13828. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13829. /**
  13830. * Get the euler rotation of the bone in local or world space
  13831. * @param space The space that the rotation should be in
  13832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13833. * @returns The euler rotation
  13834. */
  13835. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13836. /**
  13837. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13838. * @param space The space that the rotation should be in
  13839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13840. * @param result The vector3 that the rotation should be copied to
  13841. */
  13842. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13843. /**
  13844. * Get the quaternion rotation of the bone in either local or world space
  13845. * @param space The space that the rotation should be in
  13846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13847. * @returns The quaternion rotation
  13848. */
  13849. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13850. /**
  13851. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13852. * @param space The space that the rotation should be in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. * @param result The quaternion that the rotation should be copied to
  13855. */
  13856. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13857. /**
  13858. * Get the rotation matrix of the bone in local or world space
  13859. * @param space The space that the rotation should be in
  13860. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13861. * @returns The rotation matrix
  13862. */
  13863. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13864. /**
  13865. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13866. * @param space The space that the rotation should be in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. * @param result The quaternion that the rotation should be copied to
  13869. */
  13870. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13871. /**
  13872. * Get the world position of a point that is in the local space of the bone
  13873. * @param position The local position
  13874. * @param mesh The mesh that this bone is attached to
  13875. * @returns The world position
  13876. */
  13877. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13878. /**
  13879. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13880. * @param position The local position
  13881. * @param mesh The mesh that this bone is attached to
  13882. * @param result The vector3 that the world position should be copied to
  13883. */
  13884. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13885. /**
  13886. * Get the local position of a point that is in world space
  13887. * @param position The world position
  13888. * @param mesh The mesh that this bone is attached to
  13889. * @returns The local position
  13890. */
  13891. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13892. /**
  13893. * Get the local position of a point that is in world space and copy it to the result param
  13894. * @param position The world position
  13895. * @param mesh The mesh that this bone is attached to
  13896. * @param result The vector3 that the local position should be copied to
  13897. */
  13898. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13899. }
  13900. }
  13901. declare module "babylonjs/Meshes/transformNode" {
  13902. import { DeepImmutable } from "babylonjs/types";
  13903. import { Observable } from "babylonjs/Misc/observable";
  13904. import { Nullable } from "babylonjs/types";
  13905. import { Camera } from "babylonjs/Cameras/camera";
  13906. import { Scene } from "babylonjs/scene";
  13907. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13908. import { Node } from "babylonjs/node";
  13909. import { Bone } from "babylonjs/Bones/bone";
  13910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13911. import { Space } from "babylonjs/Maths/math.axis";
  13912. /**
  13913. * 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.
  13914. * @see https://doc.babylonjs.com/how_to/transformnode
  13915. */
  13916. export class TransformNode extends Node {
  13917. /**
  13918. * Object will not rotate to face the camera
  13919. */
  13920. static BILLBOARDMODE_NONE: number;
  13921. /**
  13922. * Object will rotate to face the camera but only on the x axis
  13923. */
  13924. static BILLBOARDMODE_X: number;
  13925. /**
  13926. * Object will rotate to face the camera but only on the y axis
  13927. */
  13928. static BILLBOARDMODE_Y: number;
  13929. /**
  13930. * Object will rotate to face the camera but only on the z axis
  13931. */
  13932. static BILLBOARDMODE_Z: number;
  13933. /**
  13934. * Object will rotate to face the camera
  13935. */
  13936. static BILLBOARDMODE_ALL: number;
  13937. private _forward;
  13938. private _forwardInverted;
  13939. private _up;
  13940. private _right;
  13941. private _rightInverted;
  13942. private _position;
  13943. private _rotation;
  13944. private _rotationQuaternion;
  13945. protected _scaling: Vector3;
  13946. protected _isDirty: boolean;
  13947. private _transformToBoneReferal;
  13948. private _billboardMode;
  13949. /**
  13950. * Gets or sets the billboard mode. Default is 0.
  13951. *
  13952. * | Value | Type | Description |
  13953. * | --- | --- | --- |
  13954. * | 0 | BILLBOARDMODE_NONE | |
  13955. * | 1 | BILLBOARDMODE_X | |
  13956. * | 2 | BILLBOARDMODE_Y | |
  13957. * | 4 | BILLBOARDMODE_Z | |
  13958. * | 7 | BILLBOARDMODE_ALL | |
  13959. *
  13960. */
  13961. billboardMode: number;
  13962. private _preserveParentRotationForBillboard;
  13963. /**
  13964. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13965. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13966. */
  13967. preserveParentRotationForBillboard: boolean;
  13968. /**
  13969. * 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
  13970. */
  13971. scalingDeterminant: number;
  13972. private _infiniteDistance;
  13973. /**
  13974. * Gets or sets the distance of the object to max, often used by skybox
  13975. */
  13976. infiniteDistance: boolean;
  13977. /**
  13978. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13979. * By default the system will update normals to compensate
  13980. */
  13981. ignoreNonUniformScaling: boolean;
  13982. /**
  13983. * 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
  13984. */
  13985. reIntegrateRotationIntoRotationQuaternion: boolean;
  13986. /** @hidden */
  13987. _poseMatrix: Nullable<Matrix>;
  13988. /** @hidden */
  13989. _localMatrix: Matrix;
  13990. private _usePivotMatrix;
  13991. private _absolutePosition;
  13992. private _pivotMatrix;
  13993. private _pivotMatrixInverse;
  13994. protected _postMultiplyPivotMatrix: boolean;
  13995. protected _isWorldMatrixFrozen: boolean;
  13996. /** @hidden */
  13997. _indexInSceneTransformNodesArray: number;
  13998. /**
  13999. * An event triggered after the world matrix is updated
  14000. */
  14001. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14002. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14003. /**
  14004. * Gets a string identifying the name of the class
  14005. * @returns "TransformNode" string
  14006. */
  14007. getClassName(): string;
  14008. /**
  14009. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14010. */
  14011. position: Vector3;
  14012. /**
  14013. * 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)).
  14014. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14015. */
  14016. rotation: Vector3;
  14017. /**
  14018. * 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)).
  14019. */
  14020. scaling: Vector3;
  14021. /**
  14022. * 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).
  14023. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14024. */
  14025. rotationQuaternion: Nullable<Quaternion>;
  14026. /**
  14027. * The forward direction of that transform in world space.
  14028. */
  14029. readonly forward: Vector3;
  14030. /**
  14031. * The up direction of that transform in world space.
  14032. */
  14033. readonly up: Vector3;
  14034. /**
  14035. * The right direction of that transform in world space.
  14036. */
  14037. readonly right: Vector3;
  14038. /**
  14039. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14040. * @param matrix the matrix to copy the pose from
  14041. * @returns this TransformNode.
  14042. */
  14043. updatePoseMatrix(matrix: Matrix): TransformNode;
  14044. /**
  14045. * Returns the mesh Pose matrix.
  14046. * @returns the pose matrix
  14047. */
  14048. getPoseMatrix(): Matrix;
  14049. /** @hidden */
  14050. _isSynchronized(): boolean;
  14051. /** @hidden */
  14052. _initCache(): void;
  14053. /**
  14054. * Flag the transform node as dirty (Forcing it to update everything)
  14055. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14056. * @returns this transform node
  14057. */
  14058. markAsDirty(property: string): TransformNode;
  14059. /**
  14060. * Returns the current mesh absolute position.
  14061. * Returns a Vector3.
  14062. */
  14063. readonly absolutePosition: Vector3;
  14064. /**
  14065. * Sets a new matrix to apply before all other transformation
  14066. * @param matrix defines the transform matrix
  14067. * @returns the current TransformNode
  14068. */
  14069. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14070. /**
  14071. * Sets a new pivot matrix to the current node
  14072. * @param matrix defines the new pivot matrix to use
  14073. * @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
  14074. * @returns the current TransformNode
  14075. */
  14076. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14077. /**
  14078. * Returns the mesh pivot matrix.
  14079. * Default : Identity.
  14080. * @returns the matrix
  14081. */
  14082. getPivotMatrix(): Matrix;
  14083. /**
  14084. * Prevents the World matrix to be computed any longer.
  14085. * @returns the TransformNode.
  14086. */
  14087. freezeWorldMatrix(): TransformNode;
  14088. /**
  14089. * Allows back the World matrix computation.
  14090. * @returns the TransformNode.
  14091. */
  14092. unfreezeWorldMatrix(): this;
  14093. /**
  14094. * True if the World matrix has been frozen.
  14095. */
  14096. readonly isWorldMatrixFrozen: boolean;
  14097. /**
  14098. * Retuns the mesh absolute position in the World.
  14099. * @returns a Vector3.
  14100. */
  14101. getAbsolutePosition(): Vector3;
  14102. /**
  14103. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14104. * @param absolutePosition the absolute position to set
  14105. * @returns the TransformNode.
  14106. */
  14107. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14108. /**
  14109. * Sets the mesh position in its local space.
  14110. * @param vector3 the position to set in localspace
  14111. * @returns the TransformNode.
  14112. */
  14113. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14114. /**
  14115. * Returns the mesh position in the local space from the current World matrix values.
  14116. * @returns a new Vector3.
  14117. */
  14118. getPositionExpressedInLocalSpace(): Vector3;
  14119. /**
  14120. * Translates the mesh along the passed Vector3 in its local space.
  14121. * @param vector3 the distance to translate in localspace
  14122. * @returns the TransformNode.
  14123. */
  14124. locallyTranslate(vector3: Vector3): TransformNode;
  14125. private static _lookAtVectorCache;
  14126. /**
  14127. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14128. * @param targetPoint the position (must be in same space as current mesh) to look at
  14129. * @param yawCor optional yaw (y-axis) correction in radians
  14130. * @param pitchCor optional pitch (x-axis) correction in radians
  14131. * @param rollCor optional roll (z-axis) correction in radians
  14132. * @param space the choosen space of the target
  14133. * @returns the TransformNode.
  14134. */
  14135. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14136. /**
  14137. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14138. * This Vector3 is expressed in the World space.
  14139. * @param localAxis axis to rotate
  14140. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14141. */
  14142. getDirection(localAxis: Vector3): Vector3;
  14143. /**
  14144. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14145. * localAxis is expressed in the mesh local space.
  14146. * result is computed in the Wordl space from the mesh World matrix.
  14147. * @param localAxis axis to rotate
  14148. * @param result the resulting transformnode
  14149. * @returns this TransformNode.
  14150. */
  14151. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14152. /**
  14153. * Sets this transform node rotation to the given local axis.
  14154. * @param localAxis the axis in local space
  14155. * @param yawCor optional yaw (y-axis) correction in radians
  14156. * @param pitchCor optional pitch (x-axis) correction in radians
  14157. * @param rollCor optional roll (z-axis) correction in radians
  14158. * @returns this TransformNode
  14159. */
  14160. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14161. /**
  14162. * Sets a new pivot point to the current node
  14163. * @param point defines the new pivot point to use
  14164. * @param space defines if the point is in world or local space (local by default)
  14165. * @returns the current TransformNode
  14166. */
  14167. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14168. /**
  14169. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14170. * @returns the pivot point
  14171. */
  14172. getPivotPoint(): Vector3;
  14173. /**
  14174. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14175. * @param result the vector3 to store the result
  14176. * @returns this TransformNode.
  14177. */
  14178. getPivotPointToRef(result: Vector3): TransformNode;
  14179. /**
  14180. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14181. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14182. */
  14183. getAbsolutePivotPoint(): Vector3;
  14184. /**
  14185. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14186. * @param result vector3 to store the result
  14187. * @returns this TransformNode.
  14188. */
  14189. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14190. /**
  14191. * Defines the passed node as the parent of the current node.
  14192. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14193. * @see https://doc.babylonjs.com/how_to/parenting
  14194. * @param node the node ot set as the parent
  14195. * @returns this TransformNode.
  14196. */
  14197. setParent(node: Nullable<Node>): TransformNode;
  14198. private _nonUniformScaling;
  14199. /**
  14200. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14201. */
  14202. readonly nonUniformScaling: boolean;
  14203. /** @hidden */
  14204. _updateNonUniformScalingState(value: boolean): boolean;
  14205. /**
  14206. * Attach the current TransformNode to another TransformNode associated with a bone
  14207. * @param bone Bone affecting the TransformNode
  14208. * @param affectedTransformNode TransformNode associated with the bone
  14209. * @returns this object
  14210. */
  14211. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14212. /**
  14213. * Detach the transform node if its associated with a bone
  14214. * @returns this object
  14215. */
  14216. detachFromBone(): TransformNode;
  14217. private static _rotationAxisCache;
  14218. /**
  14219. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14220. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14221. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14222. * The passed axis is also normalized.
  14223. * @param axis the axis to rotate around
  14224. * @param amount the amount to rotate in radians
  14225. * @param space Space to rotate in (Default: local)
  14226. * @returns the TransformNode.
  14227. */
  14228. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14229. /**
  14230. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14231. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14232. * The passed axis is also normalized. .
  14233. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14234. * @param point the point to rotate around
  14235. * @param axis the axis to rotate around
  14236. * @param amount the amount to rotate in radians
  14237. * @returns the TransformNode
  14238. */
  14239. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14240. /**
  14241. * Translates the mesh along the axis vector for the passed distance in the given space.
  14242. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14243. * @param axis the axis to translate in
  14244. * @param distance the distance to translate
  14245. * @param space Space to rotate in (Default: local)
  14246. * @returns the TransformNode.
  14247. */
  14248. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14249. /**
  14250. * Adds a rotation step to the mesh current rotation.
  14251. * x, y, z are Euler angles expressed in radians.
  14252. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14253. * This means this rotation is made in the mesh local space only.
  14254. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14255. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14256. * ```javascript
  14257. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14258. * ```
  14259. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14260. * 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.
  14261. * @param x Rotation to add
  14262. * @param y Rotation to add
  14263. * @param z Rotation to add
  14264. * @returns the TransformNode.
  14265. */
  14266. addRotation(x: number, y: number, z: number): TransformNode;
  14267. /**
  14268. * @hidden
  14269. */
  14270. protected _getEffectiveParent(): Nullable<Node>;
  14271. /**
  14272. * Computes the world matrix of the node
  14273. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14274. * @returns the world matrix
  14275. */
  14276. computeWorldMatrix(force?: boolean): Matrix;
  14277. protected _afterComputeWorldMatrix(): void;
  14278. /**
  14279. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14280. * @param func callback function to add
  14281. *
  14282. * @returns the TransformNode.
  14283. */
  14284. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14285. /**
  14286. * Removes a registered callback function.
  14287. * @param func callback function to remove
  14288. * @returns the TransformNode.
  14289. */
  14290. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14291. /**
  14292. * Gets the position of the current mesh in camera space
  14293. * @param camera defines the camera to use
  14294. * @returns a position
  14295. */
  14296. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14297. /**
  14298. * Returns the distance from the mesh to the active camera
  14299. * @param camera defines the camera to use
  14300. * @returns the distance
  14301. */
  14302. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14303. /**
  14304. * Clone the current transform node
  14305. * @param name Name of the new clone
  14306. * @param newParent New parent for the clone
  14307. * @param doNotCloneChildren Do not clone children hierarchy
  14308. * @returns the new transform node
  14309. */
  14310. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14311. /**
  14312. * Serializes the objects information.
  14313. * @param currentSerializationObject defines the object to serialize in
  14314. * @returns the serialized object
  14315. */
  14316. serialize(currentSerializationObject?: any): any;
  14317. /**
  14318. * Returns a new TransformNode object parsed from the source provided.
  14319. * @param parsedTransformNode is the source.
  14320. * @param scene the scne the object belongs to
  14321. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14322. * @returns a new TransformNode object parsed from the source provided.
  14323. */
  14324. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14325. /**
  14326. * Get all child-transformNodes of this node
  14327. * @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
  14328. * @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
  14329. * @returns an array of TransformNode
  14330. */
  14331. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14332. /**
  14333. * Releases resources associated with this transform node.
  14334. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14335. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14336. */
  14337. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14338. /**
  14339. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14340. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14341. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14342. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14343. * @returns the current mesh
  14344. */
  14345. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14346. }
  14347. }
  14348. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14349. import { Observable } from "babylonjs/Misc/observable";
  14350. import { Nullable } from "babylonjs/types";
  14351. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14352. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14354. import { Ray } from "babylonjs/Culling/ray";
  14355. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14356. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14357. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14358. /**
  14359. * Defines the types of pose enabled controllers that are supported
  14360. */
  14361. export enum PoseEnabledControllerType {
  14362. /**
  14363. * HTC Vive
  14364. */
  14365. VIVE = 0,
  14366. /**
  14367. * Oculus Rift
  14368. */
  14369. OCULUS = 1,
  14370. /**
  14371. * Windows mixed reality
  14372. */
  14373. WINDOWS = 2,
  14374. /**
  14375. * Samsung gear VR
  14376. */
  14377. GEAR_VR = 3,
  14378. /**
  14379. * Google Daydream
  14380. */
  14381. DAYDREAM = 4,
  14382. /**
  14383. * Generic
  14384. */
  14385. GENERIC = 5
  14386. }
  14387. /**
  14388. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14389. */
  14390. export interface MutableGamepadButton {
  14391. /**
  14392. * Value of the button/trigger
  14393. */
  14394. value: number;
  14395. /**
  14396. * If the button/trigger is currently touched
  14397. */
  14398. touched: boolean;
  14399. /**
  14400. * If the button/trigger is currently pressed
  14401. */
  14402. pressed: boolean;
  14403. }
  14404. /**
  14405. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14406. * @hidden
  14407. */
  14408. export interface ExtendedGamepadButton extends GamepadButton {
  14409. /**
  14410. * If the button/trigger is currently pressed
  14411. */
  14412. readonly pressed: boolean;
  14413. /**
  14414. * If the button/trigger is currently touched
  14415. */
  14416. readonly touched: boolean;
  14417. /**
  14418. * Value of the button/trigger
  14419. */
  14420. readonly value: number;
  14421. }
  14422. /** @hidden */
  14423. export interface _GamePadFactory {
  14424. /**
  14425. * Returns wether or not the current gamepad can be created for this type of controller.
  14426. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14427. * @returns true if it can be created, otherwise false
  14428. */
  14429. canCreate(gamepadInfo: any): boolean;
  14430. /**
  14431. * Creates a new instance of the Gamepad.
  14432. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14433. * @returns the new gamepad instance
  14434. */
  14435. create(gamepadInfo: any): Gamepad;
  14436. }
  14437. /**
  14438. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14439. */
  14440. export class PoseEnabledControllerHelper {
  14441. /** @hidden */
  14442. static _ControllerFactories: _GamePadFactory[];
  14443. /** @hidden */
  14444. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14445. /**
  14446. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14447. * @param vrGamepad the gamepad to initialized
  14448. * @returns a vr controller of the type the gamepad identified as
  14449. */
  14450. static InitiateController(vrGamepad: any): Gamepad;
  14451. }
  14452. /**
  14453. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14454. */
  14455. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14456. /**
  14457. * If the controller is used in a webXR session
  14458. */
  14459. isXR: boolean;
  14460. private _deviceRoomPosition;
  14461. private _deviceRoomRotationQuaternion;
  14462. /**
  14463. * The device position in babylon space
  14464. */
  14465. devicePosition: Vector3;
  14466. /**
  14467. * The device rotation in babylon space
  14468. */
  14469. deviceRotationQuaternion: Quaternion;
  14470. /**
  14471. * The scale factor of the device in babylon space
  14472. */
  14473. deviceScaleFactor: number;
  14474. /**
  14475. * (Likely devicePosition should be used instead) The device position in its room space
  14476. */
  14477. position: Vector3;
  14478. /**
  14479. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14480. */
  14481. rotationQuaternion: Quaternion;
  14482. /**
  14483. * The type of controller (Eg. Windows mixed reality)
  14484. */
  14485. controllerType: PoseEnabledControllerType;
  14486. protected _calculatedPosition: Vector3;
  14487. private _calculatedRotation;
  14488. /**
  14489. * The raw pose from the device
  14490. */
  14491. rawPose: DevicePose;
  14492. private _trackPosition;
  14493. private _maxRotationDistFromHeadset;
  14494. private _draggedRoomRotation;
  14495. /**
  14496. * @hidden
  14497. */
  14498. _disableTrackPosition(fixedPosition: Vector3): void;
  14499. /**
  14500. * Internal, the mesh attached to the controller
  14501. * @hidden
  14502. */
  14503. _mesh: Nullable<AbstractMesh>;
  14504. private _poseControlledCamera;
  14505. private _leftHandSystemQuaternion;
  14506. /**
  14507. * Internal, matrix used to convert room space to babylon space
  14508. * @hidden
  14509. */
  14510. _deviceToWorld: Matrix;
  14511. /**
  14512. * Node to be used when casting a ray from the controller
  14513. * @hidden
  14514. */
  14515. _pointingPoseNode: Nullable<TransformNode>;
  14516. /**
  14517. * Name of the child mesh that can be used to cast a ray from the controller
  14518. */
  14519. static readonly POINTING_POSE: string;
  14520. /**
  14521. * Creates a new PoseEnabledController from a gamepad
  14522. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14523. */
  14524. constructor(browserGamepad: any);
  14525. private _workingMatrix;
  14526. /**
  14527. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14528. */
  14529. update(): void;
  14530. /**
  14531. * Updates only the pose device and mesh without doing any button event checking
  14532. */
  14533. protected _updatePoseAndMesh(): void;
  14534. /**
  14535. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14536. * @param poseData raw pose fromthe device
  14537. */
  14538. updateFromDevice(poseData: DevicePose): void;
  14539. /**
  14540. * @hidden
  14541. */
  14542. _meshAttachedObservable: Observable<AbstractMesh>;
  14543. /**
  14544. * Attaches a mesh to the controller
  14545. * @param mesh the mesh to be attached
  14546. */
  14547. attachToMesh(mesh: AbstractMesh): void;
  14548. /**
  14549. * Attaches the controllers mesh to a camera
  14550. * @param camera the camera the mesh should be attached to
  14551. */
  14552. attachToPoseControlledCamera(camera: TargetCamera): void;
  14553. /**
  14554. * Disposes of the controller
  14555. */
  14556. dispose(): void;
  14557. /**
  14558. * The mesh that is attached to the controller
  14559. */
  14560. readonly mesh: Nullable<AbstractMesh>;
  14561. /**
  14562. * Gets the ray of the controller in the direction the controller is pointing
  14563. * @param length the length the resulting ray should be
  14564. * @returns a ray in the direction the controller is pointing
  14565. */
  14566. getForwardRay(length?: number): Ray;
  14567. }
  14568. }
  14569. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14570. import { Observable } from "babylonjs/Misc/observable";
  14571. import { Scene } from "babylonjs/scene";
  14572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14573. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14574. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14575. /**
  14576. * Defines the WebVRController object that represents controllers tracked in 3D space
  14577. */
  14578. export abstract class WebVRController extends PoseEnabledController {
  14579. /**
  14580. * Internal, the default controller model for the controller
  14581. */
  14582. protected _defaultModel: AbstractMesh;
  14583. /**
  14584. * Fired when the trigger state has changed
  14585. */
  14586. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14587. /**
  14588. * Fired when the main button state has changed
  14589. */
  14590. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14591. /**
  14592. * Fired when the secondary button state has changed
  14593. */
  14594. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14595. /**
  14596. * Fired when the pad state has changed
  14597. */
  14598. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14599. /**
  14600. * Fired when controllers stick values have changed
  14601. */
  14602. onPadValuesChangedObservable: Observable<StickValues>;
  14603. /**
  14604. * Array of button availible on the controller
  14605. */
  14606. protected _buttons: Array<MutableGamepadButton>;
  14607. private _onButtonStateChange;
  14608. /**
  14609. * Fired when a controller button's state has changed
  14610. * @param callback the callback containing the button that was modified
  14611. */
  14612. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14613. /**
  14614. * X and Y axis corresponding to the controllers joystick
  14615. */
  14616. pad: StickValues;
  14617. /**
  14618. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14619. */
  14620. hand: string;
  14621. /**
  14622. * The default controller model for the controller
  14623. */
  14624. readonly defaultModel: AbstractMesh;
  14625. /**
  14626. * Creates a new WebVRController from a gamepad
  14627. * @param vrGamepad the gamepad that the WebVRController should be created from
  14628. */
  14629. constructor(vrGamepad: any);
  14630. /**
  14631. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14632. */
  14633. update(): void;
  14634. /**
  14635. * Function to be called when a button is modified
  14636. */
  14637. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14638. /**
  14639. * Loads a mesh and attaches it to the controller
  14640. * @param scene the scene the mesh should be added to
  14641. * @param meshLoaded callback for when the mesh has been loaded
  14642. */
  14643. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14644. private _setButtonValue;
  14645. private _changes;
  14646. private _checkChanges;
  14647. /**
  14648. * Disposes of th webVRCOntroller
  14649. */
  14650. dispose(): void;
  14651. }
  14652. }
  14653. declare module "babylonjs/Lights/hemisphericLight" {
  14654. import { Nullable } from "babylonjs/types";
  14655. import { Scene } from "babylonjs/scene";
  14656. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14657. import { Color3 } from "babylonjs/Maths/math.color";
  14658. import { Effect } from "babylonjs/Materials/effect";
  14659. import { Light } from "babylonjs/Lights/light";
  14660. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14661. /**
  14662. * The HemisphericLight simulates the ambient environment light,
  14663. * so the passed direction is the light reflection direction, not the incoming direction.
  14664. */
  14665. export class HemisphericLight extends Light {
  14666. /**
  14667. * The groundColor is the light in the opposite direction to the one specified during creation.
  14668. * 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.
  14669. */
  14670. groundColor: Color3;
  14671. /**
  14672. * The light reflection direction, not the incoming direction.
  14673. */
  14674. direction: Vector3;
  14675. /**
  14676. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14677. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14678. * The HemisphericLight can't cast shadows.
  14679. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14680. * @param name The friendly name of the light
  14681. * @param direction The direction of the light reflection
  14682. * @param scene The scene the light belongs to
  14683. */
  14684. constructor(name: string, direction: Vector3, scene: Scene);
  14685. protected _buildUniformLayout(): void;
  14686. /**
  14687. * Returns the string "HemisphericLight".
  14688. * @return The class name
  14689. */
  14690. getClassName(): string;
  14691. /**
  14692. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14693. * Returns the updated direction.
  14694. * @param target The target the direction should point to
  14695. * @return The computed direction
  14696. */
  14697. setDirectionToTarget(target: Vector3): Vector3;
  14698. /**
  14699. * Returns the shadow generator associated to the light.
  14700. * @returns Always null for hemispheric lights because it does not support shadows.
  14701. */
  14702. getShadowGenerator(): Nullable<IShadowGenerator>;
  14703. /**
  14704. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14705. * @param effect The effect to update
  14706. * @param lightIndex The index of the light in the effect to update
  14707. * @returns The hemispheric light
  14708. */
  14709. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14710. /**
  14711. * Computes the world matrix of the node
  14712. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14713. * @param useWasUpdatedFlag defines a reserved property
  14714. * @returns the world matrix
  14715. */
  14716. computeWorldMatrix(): Matrix;
  14717. /**
  14718. * Returns the integer 3.
  14719. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14720. */
  14721. getTypeID(): number;
  14722. /**
  14723. * Prepares the list of defines specific to the light type.
  14724. * @param defines the list of defines
  14725. * @param lightIndex defines the index of the light for the effect
  14726. */
  14727. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14728. }
  14729. }
  14730. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14731. /** @hidden */
  14732. export var vrMultiviewToSingleviewPixelShader: {
  14733. name: string;
  14734. shader: string;
  14735. };
  14736. }
  14737. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14738. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14739. import { Scene } from "babylonjs/scene";
  14740. /**
  14741. * Renders to multiple views with a single draw call
  14742. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14743. */
  14744. export class MultiviewRenderTarget extends RenderTargetTexture {
  14745. /**
  14746. * Creates a multiview render target
  14747. * @param scene scene used with the render target
  14748. * @param size the size of the render target (used for each view)
  14749. */
  14750. constructor(scene: Scene, size?: number | {
  14751. width: number;
  14752. height: number;
  14753. } | {
  14754. ratio: number;
  14755. });
  14756. /**
  14757. * @hidden
  14758. * @param faceIndex the face index, if its a cube texture
  14759. */
  14760. _bindFrameBuffer(faceIndex?: number): void;
  14761. /**
  14762. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14763. * @returns the view count
  14764. */
  14765. getViewCount(): number;
  14766. }
  14767. }
  14768. declare module "babylonjs/Maths/math.frustum" {
  14769. import { Matrix } from "babylonjs/Maths/math.vector";
  14770. import { DeepImmutable } from "babylonjs/types";
  14771. import { Plane } from "babylonjs/Maths/math.plane";
  14772. /**
  14773. * Reprasents a camera frustum
  14774. */
  14775. export class Frustum {
  14776. /**
  14777. * Gets the planes representing the frustum
  14778. * @param transform matrix to be applied to the returned planes
  14779. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14780. */
  14781. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14782. /**
  14783. * Gets the near frustum plane transformed by the transform matrix
  14784. * @param transform transformation matrix to be applied to the resulting frustum plane
  14785. * @param frustumPlane the resuling frustum plane
  14786. */
  14787. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14788. /**
  14789. * Gets the far frustum plane transformed by the transform matrix
  14790. * @param transform transformation matrix to be applied to the resulting frustum plane
  14791. * @param frustumPlane the resuling frustum plane
  14792. */
  14793. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14794. /**
  14795. * Gets the left frustum plane transformed by the transform matrix
  14796. * @param transform transformation matrix to be applied to the resulting frustum plane
  14797. * @param frustumPlane the resuling frustum plane
  14798. */
  14799. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14800. /**
  14801. * Gets the right frustum plane transformed by the transform matrix
  14802. * @param transform transformation matrix to be applied to the resulting frustum plane
  14803. * @param frustumPlane the resuling frustum plane
  14804. */
  14805. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14806. /**
  14807. * Gets the top frustum plane transformed by the transform matrix
  14808. * @param transform transformation matrix to be applied to the resulting frustum plane
  14809. * @param frustumPlane the resuling frustum plane
  14810. */
  14811. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14812. /**
  14813. * Gets the bottom frustum plane transformed by the transform matrix
  14814. * @param transform transformation matrix to be applied to the resulting frustum plane
  14815. * @param frustumPlane the resuling frustum plane
  14816. */
  14817. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14818. /**
  14819. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14820. * @param transform transformation matrix to be applied to the resulting frustum planes
  14821. * @param frustumPlanes the resuling frustum planes
  14822. */
  14823. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14824. }
  14825. }
  14826. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14827. import { Camera } from "babylonjs/Cameras/camera";
  14828. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14829. import { Nullable } from "babylonjs/types";
  14830. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14831. import { Matrix } from "babylonjs/Maths/math.vector";
  14832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14833. module "babylonjs/Engines/engine" {
  14834. interface Engine {
  14835. /**
  14836. * Creates a new multiview render target
  14837. * @param width defines the width of the texture
  14838. * @param height defines the height of the texture
  14839. * @returns the created multiview texture
  14840. */
  14841. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14842. /**
  14843. * Binds a multiview framebuffer to be drawn to
  14844. * @param multiviewTexture texture to bind
  14845. */
  14846. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14847. }
  14848. }
  14849. module "babylonjs/Cameras/camera" {
  14850. interface Camera {
  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. _useMultiviewToSingleView: boolean;
  14856. /**
  14857. * @hidden
  14858. * 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)
  14859. */
  14860. _multiviewTexture: Nullable<RenderTargetTexture>;
  14861. /**
  14862. * @hidden
  14863. * ensures the multiview texture of the camera exists and has the specified width/height
  14864. * @param width height to set on the multiview texture
  14865. * @param height width to set on the multiview texture
  14866. */
  14867. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14868. }
  14869. }
  14870. module "babylonjs/scene" {
  14871. interface Scene {
  14872. /** @hidden */
  14873. _transformMatrixR: Matrix;
  14874. /** @hidden */
  14875. _multiviewSceneUbo: Nullable<UniformBuffer>;
  14876. /** @hidden */
  14877. _createMultiviewUbo(): void;
  14878. /** @hidden */
  14879. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14880. /** @hidden */
  14881. _renderMultiviewToSingleView(camera: Camera): void;
  14882. }
  14883. }
  14884. }
  14885. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  14886. import { Camera } from "babylonjs/Cameras/camera";
  14887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14888. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  14889. import "babylonjs/Engines/Extensions/engine.multiview";
  14890. /**
  14891. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14892. * This will not be used for webXR as it supports displaying texture arrays directly
  14893. */
  14894. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14895. /**
  14896. * Initializes a VRMultiviewToSingleview
  14897. * @param name name of the post process
  14898. * @param camera camera to be applied to
  14899. * @param scaleFactor scaling factor to the size of the output texture
  14900. */
  14901. constructor(name: string, camera: Camera, scaleFactor: number);
  14902. }
  14903. }
  14904. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  14905. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  14906. import { Nullable } from "babylonjs/types";
  14907. import { Size } from "babylonjs/Maths/math.size";
  14908. import { Observable } from "babylonjs/Misc/observable";
  14909. module "babylonjs/Engines/engine" {
  14910. interface Engine {
  14911. /** @hidden */
  14912. _vrDisplay: any;
  14913. /** @hidden */
  14914. _vrSupported: boolean;
  14915. /** @hidden */
  14916. _oldSize: Size;
  14917. /** @hidden */
  14918. _oldHardwareScaleFactor: number;
  14919. /** @hidden */
  14920. _vrExclusivePointerMode: boolean;
  14921. /** @hidden */
  14922. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14923. /** @hidden */
  14924. _onVRDisplayPointerRestricted: () => void;
  14925. /** @hidden */
  14926. _onVRDisplayPointerUnrestricted: () => void;
  14927. /** @hidden */
  14928. _onVrDisplayConnect: Nullable<(display: any) => void>;
  14929. /** @hidden */
  14930. _onVrDisplayDisconnect: Nullable<() => void>;
  14931. /** @hidden */
  14932. _onVrDisplayPresentChange: Nullable<() => void>;
  14933. /**
  14934. * Observable signaled when VR display mode changes
  14935. */
  14936. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14937. /**
  14938. * Observable signaled when VR request present is complete
  14939. */
  14940. onVRRequestPresentComplete: Observable<boolean>;
  14941. /**
  14942. * Observable signaled when VR request present starts
  14943. */
  14944. onVRRequestPresentStart: Observable<Engine>;
  14945. /**
  14946. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14947. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14948. */
  14949. isInVRExclusivePointerMode: boolean;
  14950. /**
  14951. * Gets a boolean indicating if a webVR device was detected
  14952. * @returns true if a webVR device was detected
  14953. */
  14954. isVRDevicePresent(): boolean;
  14955. /**
  14956. * Gets the current webVR device
  14957. * @returns the current webVR device (or null)
  14958. */
  14959. getVRDevice(): any;
  14960. /**
  14961. * Initializes a webVR display and starts listening to display change events
  14962. * The onVRDisplayChangedObservable will be notified upon these changes
  14963. * @returns A promise containing a VRDisplay and if vr is supported
  14964. */
  14965. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14966. /** @hidden */
  14967. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14968. /**
  14969. * Call this function to switch to webVR mode
  14970. * Will do nothing if webVR is not supported or if there is no webVR device
  14971. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14972. */
  14973. enableVR(): void;
  14974. /** @hidden */
  14975. _onVRFullScreenTriggered(): void;
  14976. }
  14977. }
  14978. }
  14979. declare module "babylonjs/Cameras/VR/webVRCamera" {
  14980. import { Nullable } from "babylonjs/types";
  14981. import { Observable } from "babylonjs/Misc/observable";
  14982. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  14983. import { Scene } from "babylonjs/scene";
  14984. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14985. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  14986. import { Node } from "babylonjs/node";
  14987. import { Ray } from "babylonjs/Culling/ray";
  14988. import "babylonjs/Cameras/RigModes/webVRRigMode";
  14989. import "babylonjs/Engines/Extensions/engine.webVR";
  14990. /**
  14991. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14992. * IMPORTANT!! The data is right-hand data.
  14993. * @export
  14994. * @interface DevicePose
  14995. */
  14996. export interface DevicePose {
  14997. /**
  14998. * The position of the device, values in array are [x,y,z].
  14999. */
  15000. readonly position: Nullable<Float32Array>;
  15001. /**
  15002. * The linearVelocity of the device, values in array are [x,y,z].
  15003. */
  15004. readonly linearVelocity: Nullable<Float32Array>;
  15005. /**
  15006. * The linearAcceleration of the device, values in array are [x,y,z].
  15007. */
  15008. readonly linearAcceleration: Nullable<Float32Array>;
  15009. /**
  15010. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15011. */
  15012. readonly orientation: Nullable<Float32Array>;
  15013. /**
  15014. * The angularVelocity of the device, values in array are [x,y,z].
  15015. */
  15016. readonly angularVelocity: Nullable<Float32Array>;
  15017. /**
  15018. * The angularAcceleration of the device, values in array are [x,y,z].
  15019. */
  15020. readonly angularAcceleration: Nullable<Float32Array>;
  15021. }
  15022. /**
  15023. * Interface representing a pose controlled object in Babylon.
  15024. * A pose controlled object has both regular pose values as well as pose values
  15025. * from an external device such as a VR head mounted display
  15026. */
  15027. export interface PoseControlled {
  15028. /**
  15029. * The position of the object in babylon space.
  15030. */
  15031. position: Vector3;
  15032. /**
  15033. * The rotation quaternion of the object in babylon space.
  15034. */
  15035. rotationQuaternion: Quaternion;
  15036. /**
  15037. * The position of the device in babylon space.
  15038. */
  15039. devicePosition?: Vector3;
  15040. /**
  15041. * The rotation quaternion of the device in babylon space.
  15042. */
  15043. deviceRotationQuaternion: Quaternion;
  15044. /**
  15045. * The raw pose coming from the device.
  15046. */
  15047. rawPose: Nullable<DevicePose>;
  15048. /**
  15049. * The scale of the device to be used when translating from device space to babylon space.
  15050. */
  15051. deviceScaleFactor: number;
  15052. /**
  15053. * Updates the poseControlled values based on the input device pose.
  15054. * @param poseData the pose data to update the object with
  15055. */
  15056. updateFromDevice(poseData: DevicePose): void;
  15057. }
  15058. /**
  15059. * Set of options to customize the webVRCamera
  15060. */
  15061. export interface WebVROptions {
  15062. /**
  15063. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15064. */
  15065. trackPosition?: boolean;
  15066. /**
  15067. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15068. */
  15069. positionScale?: number;
  15070. /**
  15071. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15072. */
  15073. displayName?: string;
  15074. /**
  15075. * Should the native controller meshes be initialized. (default: true)
  15076. */
  15077. controllerMeshes?: boolean;
  15078. /**
  15079. * Creating a default HemiLight only on controllers. (default: true)
  15080. */
  15081. defaultLightingOnControllers?: boolean;
  15082. /**
  15083. * If you don't want to use the default VR button of the helper. (default: false)
  15084. */
  15085. useCustomVRButton?: boolean;
  15086. /**
  15087. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15088. */
  15089. customVRButton?: HTMLButtonElement;
  15090. /**
  15091. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15092. */
  15093. rayLength?: number;
  15094. /**
  15095. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15096. */
  15097. defaultHeight?: number;
  15098. /**
  15099. * If multiview should be used if availible (default: false)
  15100. */
  15101. useMultiview?: boolean;
  15102. }
  15103. /**
  15104. * This represents a WebVR camera.
  15105. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15106. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15107. */
  15108. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15109. private webVROptions;
  15110. /**
  15111. * @hidden
  15112. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15113. */
  15114. _vrDevice: any;
  15115. /**
  15116. * The rawPose of the vrDevice.
  15117. */
  15118. rawPose: Nullable<DevicePose>;
  15119. private _onVREnabled;
  15120. private _specsVersion;
  15121. private _attached;
  15122. private _frameData;
  15123. protected _descendants: Array<Node>;
  15124. private _deviceRoomPosition;
  15125. /** @hidden */
  15126. _deviceRoomRotationQuaternion: Quaternion;
  15127. private _standingMatrix;
  15128. /**
  15129. * Represents device position in babylon space.
  15130. */
  15131. devicePosition: Vector3;
  15132. /**
  15133. * Represents device rotation in babylon space.
  15134. */
  15135. deviceRotationQuaternion: Quaternion;
  15136. /**
  15137. * The scale of the device to be used when translating from device space to babylon space.
  15138. */
  15139. deviceScaleFactor: number;
  15140. private _deviceToWorld;
  15141. private _worldToDevice;
  15142. /**
  15143. * References to the webVR controllers for the vrDevice.
  15144. */
  15145. controllers: Array<WebVRController>;
  15146. /**
  15147. * Emits an event when a controller is attached.
  15148. */
  15149. onControllersAttachedObservable: Observable<WebVRController[]>;
  15150. /**
  15151. * Emits an event when a controller's mesh has been loaded;
  15152. */
  15153. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15154. /**
  15155. * Emits an event when the HMD's pose has been updated.
  15156. */
  15157. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15158. private _poseSet;
  15159. /**
  15160. * If the rig cameras be used as parent instead of this camera.
  15161. */
  15162. rigParenting: boolean;
  15163. private _lightOnControllers;
  15164. private _defaultHeight?;
  15165. /**
  15166. * Instantiates a WebVRFreeCamera.
  15167. * @param name The name of the WebVRFreeCamera
  15168. * @param position The starting anchor position for the camera
  15169. * @param scene The scene the camera belongs to
  15170. * @param webVROptions a set of customizable options for the webVRCamera
  15171. */
  15172. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15173. /**
  15174. * Gets the device distance from the ground in meters.
  15175. * @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.
  15176. */
  15177. deviceDistanceToRoomGround(): number;
  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. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15181. */
  15182. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15183. /**
  15184. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15185. * @returns A promise with a boolean set to if the standing matrix is supported.
  15186. */
  15187. useStandingMatrixAsync(): Promise<boolean>;
  15188. /**
  15189. * Disposes the camera
  15190. */
  15191. dispose(): void;
  15192. /**
  15193. * Gets a vrController by name.
  15194. * @param name The name of the controller to retreive
  15195. * @returns the controller matching the name specified or null if not found
  15196. */
  15197. getControllerByName(name: string): Nullable<WebVRController>;
  15198. private _leftController;
  15199. /**
  15200. * The controller corresponding to the users left hand.
  15201. */
  15202. readonly leftController: Nullable<WebVRController>;
  15203. private _rightController;
  15204. /**
  15205. * The controller corresponding to the users right hand.
  15206. */
  15207. readonly rightController: Nullable<WebVRController>;
  15208. /**
  15209. * Casts a ray forward from the vrCamera's gaze.
  15210. * @param length Length of the ray (default: 100)
  15211. * @returns the ray corresponding to the gaze
  15212. */
  15213. getForwardRay(length?: number): Ray;
  15214. /**
  15215. * @hidden
  15216. * Updates the camera based on device's frame data
  15217. */
  15218. _checkInputs(): void;
  15219. /**
  15220. * Updates the poseControlled values based on the input device pose.
  15221. * @param poseData Pose coming from the device
  15222. */
  15223. updateFromDevice(poseData: DevicePose): void;
  15224. private _htmlElementAttached;
  15225. private _detachIfAttached;
  15226. /**
  15227. * WebVR's attach control will start broadcasting frames to the device.
  15228. * Note that in certain browsers (chrome for example) this function must be called
  15229. * within a user-interaction callback. Example:
  15230. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15231. *
  15232. * @param element html element to attach the vrDevice to
  15233. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15234. */
  15235. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15236. /**
  15237. * Detaches the camera from the html element and disables VR
  15238. *
  15239. * @param element html element to detach from
  15240. */
  15241. detachControl(element: HTMLElement): void;
  15242. /**
  15243. * @returns the name of this class
  15244. */
  15245. getClassName(): string;
  15246. /**
  15247. * Calls resetPose on the vrDisplay
  15248. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15249. */
  15250. resetToCurrentRotation(): void;
  15251. /**
  15252. * @hidden
  15253. * Updates the rig cameras (left and right eye)
  15254. */
  15255. _updateRigCameras(): void;
  15256. private _workingVector;
  15257. private _oneVector;
  15258. private _workingMatrix;
  15259. private updateCacheCalled;
  15260. private _correctPositionIfNotTrackPosition;
  15261. /**
  15262. * @hidden
  15263. * Updates the cached values of the camera
  15264. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15265. */
  15266. _updateCache(ignoreParentClass?: boolean): void;
  15267. /**
  15268. * @hidden
  15269. * Get current device position in babylon world
  15270. */
  15271. _computeDevicePosition(): void;
  15272. /**
  15273. * Updates the current device position and rotation in the babylon world
  15274. */
  15275. update(): void;
  15276. /**
  15277. * @hidden
  15278. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15279. * @returns an identity matrix
  15280. */
  15281. _getViewMatrix(): Matrix;
  15282. private _tmpMatrix;
  15283. /**
  15284. * This function is called by the two RIG cameras.
  15285. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15286. * @hidden
  15287. */
  15288. _getWebVRViewMatrix(): Matrix;
  15289. /** @hidden */
  15290. _getWebVRProjectionMatrix(): Matrix;
  15291. private _onGamepadConnectedObserver;
  15292. private _onGamepadDisconnectedObserver;
  15293. private _updateCacheWhenTrackingDisabledObserver;
  15294. /**
  15295. * Initializes the controllers and their meshes
  15296. */
  15297. initControllers(): void;
  15298. }
  15299. }
  15300. declare module "babylonjs/PostProcesses/postProcess" {
  15301. import { Nullable } from "babylonjs/types";
  15302. import { SmartArray } from "babylonjs/Misc/smartArray";
  15303. import { Observable } from "babylonjs/Misc/observable";
  15304. import { Vector2 } from "babylonjs/Maths/math.vector";
  15305. import { Camera } from "babylonjs/Cameras/camera";
  15306. import { Effect } from "babylonjs/Materials/effect";
  15307. import "babylonjs/Shaders/postprocess.vertex";
  15308. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15309. import { Engine } from "babylonjs/Engines/engine";
  15310. import { Color4 } from "babylonjs/Maths/math.color";
  15311. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15312. /**
  15313. * Size options for a post process
  15314. */
  15315. export type PostProcessOptions = {
  15316. width: number;
  15317. height: number;
  15318. };
  15319. /**
  15320. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15321. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15322. */
  15323. export class PostProcess {
  15324. /** Name of the PostProcess. */
  15325. name: string;
  15326. /**
  15327. * Gets or sets the unique id of the post process
  15328. */
  15329. uniqueId: number;
  15330. /**
  15331. * Width of the texture to apply the post process on
  15332. */
  15333. width: number;
  15334. /**
  15335. * Height of the texture to apply the post process on
  15336. */
  15337. height: number;
  15338. /**
  15339. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15340. * @hidden
  15341. */
  15342. _outputTexture: Nullable<InternalTexture>;
  15343. /**
  15344. * Sampling mode used by the shader
  15345. * See https://doc.babylonjs.com/classes/3.1/texture
  15346. */
  15347. renderTargetSamplingMode: number;
  15348. /**
  15349. * Clear color to use when screen clearing
  15350. */
  15351. clearColor: Color4;
  15352. /**
  15353. * If the buffer needs to be cleared before applying the post process. (default: true)
  15354. * Should be set to false if shader will overwrite all previous pixels.
  15355. */
  15356. autoClear: boolean;
  15357. /**
  15358. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15359. */
  15360. alphaMode: number;
  15361. /**
  15362. * Sets the setAlphaBlendConstants of the babylon engine
  15363. */
  15364. alphaConstants: Color4;
  15365. /**
  15366. * Animations to be used for the post processing
  15367. */
  15368. animations: import("babylonjs/Animations/animation").Animation[];
  15369. /**
  15370. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15371. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15372. */
  15373. enablePixelPerfectMode: boolean;
  15374. /**
  15375. * Force the postprocess to be applied without taking in account viewport
  15376. */
  15377. forceFullscreenViewport: boolean;
  15378. /**
  15379. * List of inspectable custom properties (used by the Inspector)
  15380. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15381. */
  15382. inspectableCustomProperties: IInspectable[];
  15383. /**
  15384. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15385. *
  15386. * | Value | Type | Description |
  15387. * | ----- | ----------------------------------- | ----------- |
  15388. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15389. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15390. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15391. *
  15392. */
  15393. scaleMode: number;
  15394. /**
  15395. * Force textures to be a power of two (default: false)
  15396. */
  15397. alwaysForcePOT: boolean;
  15398. private _samples;
  15399. /**
  15400. * Number of sample textures (default: 1)
  15401. */
  15402. samples: number;
  15403. /**
  15404. * Modify the scale of the post process to be the same as the viewport (default: false)
  15405. */
  15406. adaptScaleToCurrentViewport: boolean;
  15407. private _camera;
  15408. private _scene;
  15409. private _engine;
  15410. private _options;
  15411. private _reusable;
  15412. private _textureType;
  15413. /**
  15414. * Smart array of input and output textures for the post process.
  15415. * @hidden
  15416. */
  15417. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15418. /**
  15419. * The index in _textures that corresponds to the output texture.
  15420. * @hidden
  15421. */
  15422. _currentRenderTextureInd: number;
  15423. private _effect;
  15424. private _samplers;
  15425. private _fragmentUrl;
  15426. private _vertexUrl;
  15427. private _parameters;
  15428. private _scaleRatio;
  15429. protected _indexParameters: any;
  15430. private _shareOutputWithPostProcess;
  15431. private _texelSize;
  15432. private _forcedOutputTexture;
  15433. /**
  15434. * Returns the fragment url or shader name used in the post process.
  15435. * @returns the fragment url or name in the shader store.
  15436. */
  15437. getEffectName(): string;
  15438. /**
  15439. * An event triggered when the postprocess is activated.
  15440. */
  15441. onActivateObservable: Observable<Camera>;
  15442. private _onActivateObserver;
  15443. /**
  15444. * A function that is added to the onActivateObservable
  15445. */
  15446. onActivate: Nullable<(camera: Camera) => void>;
  15447. /**
  15448. * An event triggered when the postprocess changes its size.
  15449. */
  15450. onSizeChangedObservable: Observable<PostProcess>;
  15451. private _onSizeChangedObserver;
  15452. /**
  15453. * A function that is added to the onSizeChangedObservable
  15454. */
  15455. onSizeChanged: (postProcess: PostProcess) => void;
  15456. /**
  15457. * An event triggered when the postprocess applies its effect.
  15458. */
  15459. onApplyObservable: Observable<Effect>;
  15460. private _onApplyObserver;
  15461. /**
  15462. * A function that is added to the onApplyObservable
  15463. */
  15464. onApply: (effect: Effect) => void;
  15465. /**
  15466. * An event triggered before rendering the postprocess
  15467. */
  15468. onBeforeRenderObservable: Observable<Effect>;
  15469. private _onBeforeRenderObserver;
  15470. /**
  15471. * A function that is added to the onBeforeRenderObservable
  15472. */
  15473. onBeforeRender: (effect: Effect) => void;
  15474. /**
  15475. * An event triggered after rendering the postprocess
  15476. */
  15477. onAfterRenderObservable: Observable<Effect>;
  15478. private _onAfterRenderObserver;
  15479. /**
  15480. * A function that is added to the onAfterRenderObservable
  15481. */
  15482. onAfterRender: (efect: Effect) => void;
  15483. /**
  15484. * 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
  15485. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15486. */
  15487. inputTexture: InternalTexture;
  15488. /**
  15489. * Gets the camera which post process is applied to.
  15490. * @returns The camera the post process is applied to.
  15491. */
  15492. getCamera(): Camera;
  15493. /**
  15494. * Gets the texel size of the postprocess.
  15495. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15496. */
  15497. readonly texelSize: Vector2;
  15498. /**
  15499. * Creates a new instance PostProcess
  15500. * @param name The name of the PostProcess.
  15501. * @param fragmentUrl The url of the fragment shader to be used.
  15502. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15503. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15504. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15505. * @param camera The camera to apply the render pass to.
  15506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15507. * @param engine The engine which the post process will be applied. (default: current engine)
  15508. * @param reusable If the post process can be reused on the same frame. (default: false)
  15509. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15510. * @param textureType Type of textures used when performing the post process. (default: 0)
  15511. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15512. * @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
  15513. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15514. */
  15515. constructor(
  15516. /** Name of the PostProcess. */
  15517. 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);
  15518. /**
  15519. * Gets a string idenfifying the name of the class
  15520. * @returns "PostProcess" string
  15521. */
  15522. getClassName(): string;
  15523. /**
  15524. * Gets the engine which this post process belongs to.
  15525. * @returns The engine the post process was enabled with.
  15526. */
  15527. getEngine(): Engine;
  15528. /**
  15529. * The effect that is created when initializing the post process.
  15530. * @returns The created effect corresponding the the postprocess.
  15531. */
  15532. getEffect(): Effect;
  15533. /**
  15534. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15535. * @param postProcess The post process to share the output with.
  15536. * @returns This post process.
  15537. */
  15538. shareOutputWith(postProcess: PostProcess): PostProcess;
  15539. /**
  15540. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15541. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15542. */
  15543. useOwnOutput(): void;
  15544. /**
  15545. * Updates the effect with the current post process compile time values and recompiles the shader.
  15546. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15547. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15548. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15549. * @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
  15550. * @param onCompiled Called when the shader has been compiled.
  15551. * @param onError Called if there is an error when compiling a shader.
  15552. */
  15553. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15554. /**
  15555. * The post process is reusable if it can be used multiple times within one frame.
  15556. * @returns If the post process is reusable
  15557. */
  15558. isReusable(): boolean;
  15559. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15560. markTextureDirty(): void;
  15561. /**
  15562. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15563. * 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.
  15564. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15565. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15566. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15567. * @returns The target texture that was bound to be written to.
  15568. */
  15569. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15570. /**
  15571. * If the post process is supported.
  15572. */
  15573. readonly isSupported: boolean;
  15574. /**
  15575. * The aspect ratio of the output texture.
  15576. */
  15577. readonly aspectRatio: number;
  15578. /**
  15579. * Get a value indicating if the post-process is ready to be used
  15580. * @returns true if the post-process is ready (shader is compiled)
  15581. */
  15582. isReady(): boolean;
  15583. /**
  15584. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15585. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15586. */
  15587. apply(): Nullable<Effect>;
  15588. private _disposeTextures;
  15589. /**
  15590. * Disposes the post process.
  15591. * @param camera The camera to dispose the post process on.
  15592. */
  15593. dispose(camera?: Camera): void;
  15594. }
  15595. }
  15596. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15597. /** @hidden */
  15598. export var kernelBlurVaryingDeclaration: {
  15599. name: string;
  15600. shader: string;
  15601. };
  15602. }
  15603. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15604. /** @hidden */
  15605. export var kernelBlurFragment: {
  15606. name: string;
  15607. shader: string;
  15608. };
  15609. }
  15610. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15611. /** @hidden */
  15612. export var kernelBlurFragment2: {
  15613. name: string;
  15614. shader: string;
  15615. };
  15616. }
  15617. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15618. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15619. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15620. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15621. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15622. /** @hidden */
  15623. export var kernelBlurPixelShader: {
  15624. name: string;
  15625. shader: string;
  15626. };
  15627. }
  15628. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15629. /** @hidden */
  15630. export var kernelBlurVertex: {
  15631. name: string;
  15632. shader: string;
  15633. };
  15634. }
  15635. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15636. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15637. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15638. /** @hidden */
  15639. export var kernelBlurVertexShader: {
  15640. name: string;
  15641. shader: string;
  15642. };
  15643. }
  15644. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15645. import { Vector2 } from "babylonjs/Maths/math.vector";
  15646. import { Nullable } from "babylonjs/types";
  15647. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15648. import { Camera } from "babylonjs/Cameras/camera";
  15649. import { Effect } from "babylonjs/Materials/effect";
  15650. import { Engine } from "babylonjs/Engines/engine";
  15651. import "babylonjs/Shaders/kernelBlur.fragment";
  15652. import "babylonjs/Shaders/kernelBlur.vertex";
  15653. /**
  15654. * The Blur Post Process which blurs an image based on a kernel and direction.
  15655. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15656. */
  15657. export class BlurPostProcess extends PostProcess {
  15658. /** The direction in which to blur the image. */
  15659. direction: Vector2;
  15660. private blockCompilation;
  15661. protected _kernel: number;
  15662. protected _idealKernel: number;
  15663. protected _packedFloat: boolean;
  15664. private _staticDefines;
  15665. /**
  15666. * Sets the length in pixels of the blur sample region
  15667. */
  15668. /**
  15669. * Gets the length in pixels of the blur sample region
  15670. */
  15671. kernel: number;
  15672. /**
  15673. * Sets wether or not the blur needs to unpack/repack floats
  15674. */
  15675. /**
  15676. * Gets wether or not the blur is unpacking/repacking floats
  15677. */
  15678. packedFloat: boolean;
  15679. /**
  15680. * Creates a new instance BlurPostProcess
  15681. * @param name The name of the effect.
  15682. * @param direction The direction in which to blur the image.
  15683. * @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.
  15684. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15685. * @param camera The camera to apply the render pass to.
  15686. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15687. * @param engine The engine which the post process will be applied. (default: current engine)
  15688. * @param reusable If the post process can be reused on the same frame. (default: false)
  15689. * @param textureType Type of textures used when performing the post process. (default: 0)
  15690. * @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)
  15691. */
  15692. constructor(name: string,
  15693. /** The direction in which to blur the image. */
  15694. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15695. /**
  15696. * Updates the effect with the current post process compile time values and recompiles the shader.
  15697. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15698. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15699. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15700. * @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
  15701. * @param onCompiled Called when the shader has been compiled.
  15702. * @param onError Called if there is an error when compiling a shader.
  15703. */
  15704. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15705. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15706. /**
  15707. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15708. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15709. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15710. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15711. * The gaps between physical kernels are compensated for in the weighting of the samples
  15712. * @param idealKernel Ideal blur kernel.
  15713. * @return Nearest best kernel.
  15714. */
  15715. protected _nearestBestKernel(idealKernel: number): number;
  15716. /**
  15717. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15718. * @param x The point on the Gaussian distribution to sample.
  15719. * @return the value of the Gaussian function at x.
  15720. */
  15721. protected _gaussianWeight(x: number): number;
  15722. /**
  15723. * Generates a string that can be used as a floating point number in GLSL.
  15724. * @param x Value to print.
  15725. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15726. * @return GLSL float string.
  15727. */
  15728. protected _glslFloat(x: number, decimalFigures?: number): string;
  15729. }
  15730. }
  15731. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15732. import { Scene } from "babylonjs/scene";
  15733. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15734. import { Plane } from "babylonjs/Maths/math.plane";
  15735. /**
  15736. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15737. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15738. * You can then easily use it as a reflectionTexture on a flat surface.
  15739. * In case the surface is not a plane, please consider relying on reflection probes.
  15740. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15741. */
  15742. export class MirrorTexture extends RenderTargetTexture {
  15743. private scene;
  15744. /**
  15745. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15746. * 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.
  15747. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15748. */
  15749. mirrorPlane: Plane;
  15750. /**
  15751. * Define the blur ratio used to blur the reflection if needed.
  15752. */
  15753. blurRatio: number;
  15754. /**
  15755. * Define the adaptive blur kernel used to blur the reflection if needed.
  15756. * This will autocompute the closest best match for the `blurKernel`
  15757. */
  15758. adaptiveBlurKernel: number;
  15759. /**
  15760. * Define the blur kernel used to blur the reflection if needed.
  15761. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15762. */
  15763. blurKernel: number;
  15764. /**
  15765. * Define the blur kernel on the X 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. blurKernelX: number;
  15769. /**
  15770. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15771. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15772. */
  15773. blurKernelY: number;
  15774. private _autoComputeBlurKernel;
  15775. protected _onRatioRescale(): void;
  15776. private _updateGammaSpace;
  15777. private _imageProcessingConfigChangeObserver;
  15778. private _transformMatrix;
  15779. private _mirrorMatrix;
  15780. private _savedViewMatrix;
  15781. private _blurX;
  15782. private _blurY;
  15783. private _adaptiveBlurKernel;
  15784. private _blurKernelX;
  15785. private _blurKernelY;
  15786. private _blurRatio;
  15787. /**
  15788. * Instantiates a Mirror Texture.
  15789. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15790. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15791. * You can then easily use it as a reflectionTexture on a flat surface.
  15792. * In case the surface is not a plane, please consider relying on reflection probes.
  15793. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15794. * @param name
  15795. * @param size
  15796. * @param scene
  15797. * @param generateMipMaps
  15798. * @param type
  15799. * @param samplingMode
  15800. * @param generateDepthBuffer
  15801. */
  15802. constructor(name: string, size: number | {
  15803. width: number;
  15804. height: number;
  15805. } | {
  15806. ratio: number;
  15807. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15808. private _preparePostProcesses;
  15809. /**
  15810. * Clone the mirror texture.
  15811. * @returns the cloned texture
  15812. */
  15813. clone(): MirrorTexture;
  15814. /**
  15815. * Serialize the texture to a JSON representation you could use in Parse later on
  15816. * @returns the serialized JSON representation
  15817. */
  15818. serialize(): any;
  15819. /**
  15820. * Dispose the texture and release its associated resources.
  15821. */
  15822. dispose(): void;
  15823. }
  15824. }
  15825. declare module "babylonjs/Materials/Textures/texture" {
  15826. import { Observable } from "babylonjs/Misc/observable";
  15827. import { Nullable } from "babylonjs/types";
  15828. import { Scene } from "babylonjs/scene";
  15829. import { Matrix } from "babylonjs/Maths/math.vector";
  15830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15831. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15832. import { Engine } from "babylonjs/Engines/engine";
  15833. /**
  15834. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15835. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15836. */
  15837. export class Texture extends BaseTexture {
  15838. /** @hidden */
  15839. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15840. /** @hidden */
  15841. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15842. /** @hidden */
  15843. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15844. /** nearest is mag = nearest and min = nearest and mip = linear */
  15845. static readonly NEAREST_SAMPLINGMODE: number;
  15846. /** nearest is mag = nearest and min = nearest and mip = linear */
  15847. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15848. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15849. static readonly BILINEAR_SAMPLINGMODE: number;
  15850. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15851. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15852. /** Trilinear is mag = linear and min = linear and mip = linear */
  15853. static readonly TRILINEAR_SAMPLINGMODE: number;
  15854. /** Trilinear is mag = linear and min = linear and mip = linear */
  15855. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15856. /** mag = nearest and min = nearest and mip = nearest */
  15857. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15858. /** mag = nearest and min = linear and mip = nearest */
  15859. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15860. /** mag = nearest and min = linear and mip = linear */
  15861. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15862. /** mag = nearest and min = linear and mip = none */
  15863. static readonly NEAREST_LINEAR: number;
  15864. /** mag = nearest and min = nearest and mip = none */
  15865. static readonly NEAREST_NEAREST: number;
  15866. /** mag = linear and min = nearest and mip = nearest */
  15867. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15868. /** mag = linear and min = nearest and mip = linear */
  15869. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15870. /** mag = linear and min = linear and mip = none */
  15871. static readonly LINEAR_LINEAR: number;
  15872. /** mag = linear and min = nearest and mip = none */
  15873. static readonly LINEAR_NEAREST: number;
  15874. /** Explicit coordinates mode */
  15875. static readonly EXPLICIT_MODE: number;
  15876. /** Spherical coordinates mode */
  15877. static readonly SPHERICAL_MODE: number;
  15878. /** Planar coordinates mode */
  15879. static readonly PLANAR_MODE: number;
  15880. /** Cubic coordinates mode */
  15881. static readonly CUBIC_MODE: number;
  15882. /** Projection coordinates mode */
  15883. static readonly PROJECTION_MODE: number;
  15884. /** Inverse Cubic coordinates mode */
  15885. static readonly SKYBOX_MODE: number;
  15886. /** Inverse Cubic coordinates mode */
  15887. static readonly INVCUBIC_MODE: number;
  15888. /** Equirectangular coordinates mode */
  15889. static readonly EQUIRECTANGULAR_MODE: number;
  15890. /** Equirectangular Fixed coordinates mode */
  15891. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15892. /** Equirectangular Fixed Mirrored coordinates mode */
  15893. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15894. /** Texture is not repeating outside of 0..1 UVs */
  15895. static readonly CLAMP_ADDRESSMODE: number;
  15896. /** Texture is repeating outside of 0..1 UVs */
  15897. static readonly WRAP_ADDRESSMODE: number;
  15898. /** Texture is repeating and mirrored */
  15899. static readonly MIRROR_ADDRESSMODE: number;
  15900. /**
  15901. * 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
  15902. */
  15903. static UseSerializedUrlIfAny: boolean;
  15904. /**
  15905. * Define the url of the texture.
  15906. */
  15907. url: Nullable<string>;
  15908. /**
  15909. * Define an offset on the texture to offset the u coordinates of the UVs
  15910. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15911. */
  15912. uOffset: number;
  15913. /**
  15914. * Define an offset on the texture to offset the v coordinates of the UVs
  15915. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15916. */
  15917. vOffset: number;
  15918. /**
  15919. * Define an offset on the texture to scale the u coordinates of the UVs
  15920. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15921. */
  15922. uScale: number;
  15923. /**
  15924. * Define an offset on the texture to scale the v coordinates of the UVs
  15925. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15926. */
  15927. vScale: number;
  15928. /**
  15929. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15930. * @see http://doc.babylonjs.com/how_to/more_materials
  15931. */
  15932. uAng: number;
  15933. /**
  15934. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15935. * @see http://doc.babylonjs.com/how_to/more_materials
  15936. */
  15937. vAng: number;
  15938. /**
  15939. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15940. * @see http://doc.babylonjs.com/how_to/more_materials
  15941. */
  15942. wAng: number;
  15943. /**
  15944. * Defines the center of rotation (U)
  15945. */
  15946. uRotationCenter: number;
  15947. /**
  15948. * Defines the center of rotation (V)
  15949. */
  15950. vRotationCenter: number;
  15951. /**
  15952. * Defines the center of rotation (W)
  15953. */
  15954. wRotationCenter: number;
  15955. /**
  15956. * Are mip maps generated for this texture or not.
  15957. */
  15958. readonly noMipmap: boolean;
  15959. /**
  15960. * List of inspectable custom properties (used by the Inspector)
  15961. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15962. */
  15963. inspectableCustomProperties: Nullable<IInspectable[]>;
  15964. private _noMipmap;
  15965. /** @hidden */
  15966. _invertY: boolean;
  15967. private _rowGenerationMatrix;
  15968. private _cachedTextureMatrix;
  15969. private _projectionModeMatrix;
  15970. private _t0;
  15971. private _t1;
  15972. private _t2;
  15973. private _cachedUOffset;
  15974. private _cachedVOffset;
  15975. private _cachedUScale;
  15976. private _cachedVScale;
  15977. private _cachedUAng;
  15978. private _cachedVAng;
  15979. private _cachedWAng;
  15980. private _cachedProjectionMatrixId;
  15981. private _cachedCoordinatesMode;
  15982. /** @hidden */
  15983. protected _initialSamplingMode: number;
  15984. /** @hidden */
  15985. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15986. private _deleteBuffer;
  15987. protected _format: Nullable<number>;
  15988. private _delayedOnLoad;
  15989. private _delayedOnError;
  15990. /**
  15991. * Observable triggered once the texture has been loaded.
  15992. */
  15993. onLoadObservable: Observable<Texture>;
  15994. protected _isBlocking: boolean;
  15995. /**
  15996. * Is the texture preventing material to render while loading.
  15997. * If false, a default texture will be used instead of the loading one during the preparation step.
  15998. */
  15999. isBlocking: boolean;
  16000. /**
  16001. * Get the current sampling mode associated with the texture.
  16002. */
  16003. readonly samplingMode: number;
  16004. /**
  16005. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16006. */
  16007. readonly invertY: boolean;
  16008. /**
  16009. * Instantiates a new texture.
  16010. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16011. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16012. * @param url define the url of the picture to load as a texture
  16013. * @param scene define the scene or engine the texture will belong to
  16014. * @param noMipmap define if the texture will require mip maps or not
  16015. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16016. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16017. * @param onLoad define a callback triggered when the texture has been loaded
  16018. * @param onError define a callback triggered when an error occurred during the loading session
  16019. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16020. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16021. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16022. */
  16023. 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);
  16024. /**
  16025. * Update the url (and optional buffer) of this texture if url was null during construction.
  16026. * @param url the url of the texture
  16027. * @param buffer the buffer of the texture (defaults to null)
  16028. * @param onLoad callback called when the texture is loaded (defaults to null)
  16029. */
  16030. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16031. /**
  16032. * Finish the loading sequence of a texture flagged as delayed load.
  16033. * @hidden
  16034. */
  16035. delayLoad(): void;
  16036. private _prepareRowForTextureGeneration;
  16037. /**
  16038. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16039. * @returns the transform matrix of the texture.
  16040. */
  16041. getTextureMatrix(): Matrix;
  16042. /**
  16043. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16044. * @returns The reflection texture transform
  16045. */
  16046. getReflectionTextureMatrix(): Matrix;
  16047. /**
  16048. * Clones the texture.
  16049. * @returns the cloned texture
  16050. */
  16051. clone(): Texture;
  16052. /**
  16053. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16054. * @returns The JSON representation of the texture
  16055. */
  16056. serialize(): any;
  16057. /**
  16058. * Get the current class name of the texture useful for serialization or dynamic coding.
  16059. * @returns "Texture"
  16060. */
  16061. getClassName(): string;
  16062. /**
  16063. * Dispose the texture and release its associated resources.
  16064. */
  16065. dispose(): void;
  16066. /**
  16067. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16068. * @param parsedTexture Define the JSON representation of the texture
  16069. * @param scene Define the scene the parsed texture should be instantiated in
  16070. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16071. * @returns The parsed texture if successful
  16072. */
  16073. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16074. /**
  16075. * Creates a texture from its base 64 representation.
  16076. * @param data Define the base64 payload without the data: prefix
  16077. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16078. * @param scene Define the scene the texture should belong to
  16079. * @param noMipmap Forces the texture to not create mip map information if true
  16080. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16081. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16082. * @param onLoad define a callback triggered when the texture has been loaded
  16083. * @param onError define a callback triggered when an error occurred during the loading session
  16084. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16085. * @returns the created texture
  16086. */
  16087. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16088. /**
  16089. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16090. * @param data Define the base64 payload without the data: prefix
  16091. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16092. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16093. * @param scene Define the scene the texture should belong to
  16094. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16095. * @param noMipmap Forces the texture to not create mip map information if true
  16096. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16097. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16098. * @param onLoad define a callback triggered when the texture has been loaded
  16099. * @param onError define a callback triggered when an error occurred during the loading session
  16100. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16101. * @returns the created texture
  16102. */
  16103. 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;
  16104. }
  16105. }
  16106. declare module "babylonjs/PostProcesses/postProcessManager" {
  16107. import { Nullable } from "babylonjs/types";
  16108. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16109. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16110. import { Scene } from "babylonjs/scene";
  16111. /**
  16112. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16113. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16114. */
  16115. export class PostProcessManager {
  16116. private _scene;
  16117. private _indexBuffer;
  16118. private _vertexBuffers;
  16119. /**
  16120. * Creates a new instance PostProcess
  16121. * @param scene The scene that the post process is associated with.
  16122. */
  16123. constructor(scene: Scene);
  16124. private _prepareBuffers;
  16125. private _buildIndexBuffer;
  16126. /**
  16127. * Rebuilds the vertex buffers of the manager.
  16128. * @hidden
  16129. */
  16130. _rebuild(): void;
  16131. /**
  16132. * Prepares a frame to be run through a post process.
  16133. * @param sourceTexture The input texture to the post procesess. (default: null)
  16134. * @param postProcesses An array of post processes to be run. (default: null)
  16135. * @returns True if the post processes were able to be run.
  16136. * @hidden
  16137. */
  16138. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16139. /**
  16140. * Manually render a set of post processes to a texture.
  16141. * @param postProcesses An array of post processes to be run.
  16142. * @param targetTexture The target texture to render to.
  16143. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16144. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16145. * @param lodLevel defines which lod of the texture to render to
  16146. */
  16147. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16148. /**
  16149. * Finalize the result of the output of the postprocesses.
  16150. * @param doNotPresent If true the result will not be displayed to the screen.
  16151. * @param targetTexture The target texture to render to.
  16152. * @param faceIndex The index of the face to bind the target texture to.
  16153. * @param postProcesses The array of post processes to render.
  16154. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16155. * @hidden
  16156. */
  16157. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16158. /**
  16159. * Disposes of the post process manager.
  16160. */
  16161. dispose(): void;
  16162. }
  16163. }
  16164. declare module "babylonjs/Misc/gradients" {
  16165. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16166. /** Interface used by value gradients (color, factor, ...) */
  16167. export interface IValueGradient {
  16168. /**
  16169. * Gets or sets the gradient value (between 0 and 1)
  16170. */
  16171. gradient: number;
  16172. }
  16173. /** Class used to store color4 gradient */
  16174. export class ColorGradient implements IValueGradient {
  16175. /**
  16176. * Gets or sets the gradient value (between 0 and 1)
  16177. */
  16178. gradient: number;
  16179. /**
  16180. * Gets or sets first associated color
  16181. */
  16182. color1: Color4;
  16183. /**
  16184. * Gets or sets second associated color
  16185. */
  16186. color2?: Color4;
  16187. /**
  16188. * Will get a color picked randomly between color1 and color2.
  16189. * If color2 is undefined then color1 will be used
  16190. * @param result defines the target Color4 to store the result in
  16191. */
  16192. getColorToRef(result: Color4): void;
  16193. }
  16194. /** Class used to store color 3 gradient */
  16195. export class Color3Gradient implements IValueGradient {
  16196. /**
  16197. * Gets or sets the gradient value (between 0 and 1)
  16198. */
  16199. gradient: number;
  16200. /**
  16201. * Gets or sets the associated color
  16202. */
  16203. color: Color3;
  16204. }
  16205. /** Class used to store factor gradient */
  16206. export class FactorGradient implements IValueGradient {
  16207. /**
  16208. * Gets or sets the gradient value (between 0 and 1)
  16209. */
  16210. gradient: number;
  16211. /**
  16212. * Gets or sets first associated factor
  16213. */
  16214. factor1: number;
  16215. /**
  16216. * Gets or sets second associated factor
  16217. */
  16218. factor2?: number;
  16219. /**
  16220. * Will get a number picked randomly between factor1 and factor2.
  16221. * If factor2 is undefined then factor1 will be used
  16222. * @returns the picked number
  16223. */
  16224. getFactor(): number;
  16225. }
  16226. /**
  16227. * Helper used to simplify some generic gradient tasks
  16228. */
  16229. export class GradientHelper {
  16230. /**
  16231. * Gets the current gradient from an array of IValueGradient
  16232. * @param ratio defines the current ratio to get
  16233. * @param gradients defines the array of IValueGradient
  16234. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16235. */
  16236. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16237. }
  16238. }
  16239. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16240. import { Scene } from "babylonjs/scene";
  16241. import { ISceneComponent } from "babylonjs/sceneComponent";
  16242. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16243. module "babylonjs/abstractScene" {
  16244. interface AbstractScene {
  16245. /**
  16246. * The list of procedural textures added to the scene
  16247. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16248. */
  16249. proceduralTextures: Array<ProceduralTexture>;
  16250. }
  16251. }
  16252. /**
  16253. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16254. * in a given scene.
  16255. */
  16256. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16257. /**
  16258. * The component name helpfull to identify the component in the list of scene components.
  16259. */
  16260. readonly name: string;
  16261. /**
  16262. * The scene the component belongs to.
  16263. */
  16264. scene: Scene;
  16265. /**
  16266. * Creates a new instance of the component for the given scene
  16267. * @param scene Defines the scene to register the component in
  16268. */
  16269. constructor(scene: Scene);
  16270. /**
  16271. * Registers the component in a given scene
  16272. */
  16273. register(): void;
  16274. /**
  16275. * Rebuilds the elements related to this component in case of
  16276. * context lost for instance.
  16277. */
  16278. rebuild(): void;
  16279. /**
  16280. * Disposes the component and the associated ressources.
  16281. */
  16282. dispose(): void;
  16283. private _beforeClear;
  16284. }
  16285. }
  16286. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16287. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16288. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16289. module "babylonjs/Engines/engine" {
  16290. interface Engine {
  16291. /**
  16292. * Creates a new render target cube texture
  16293. * @param size defines the size of the texture
  16294. * @param options defines the options used to create the texture
  16295. * @returns a new render target cube texture stored in an InternalTexture
  16296. */
  16297. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16298. }
  16299. }
  16300. }
  16301. declare module "babylonjs/Shaders/procedural.vertex" {
  16302. /** @hidden */
  16303. export var proceduralVertexShader: {
  16304. name: string;
  16305. shader: string;
  16306. };
  16307. }
  16308. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16309. import { Observable } from "babylonjs/Misc/observable";
  16310. import { Nullable } from "babylonjs/types";
  16311. import { Scene } from "babylonjs/scene";
  16312. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16313. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16314. import { Effect } from "babylonjs/Materials/effect";
  16315. import { Texture } from "babylonjs/Materials/Textures/texture";
  16316. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16317. import "babylonjs/Shaders/procedural.vertex";
  16318. /**
  16319. * 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.
  16320. * This is the base class of any Procedural texture and contains most of the shareable code.
  16321. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16322. */
  16323. export class ProceduralTexture extends Texture {
  16324. isCube: boolean;
  16325. /**
  16326. * Define if the texture is enabled or not (disabled texture will not render)
  16327. */
  16328. isEnabled: boolean;
  16329. /**
  16330. * Define if the texture must be cleared before rendering (default is true)
  16331. */
  16332. autoClear: boolean;
  16333. /**
  16334. * Callback called when the texture is generated
  16335. */
  16336. onGenerated: () => void;
  16337. /**
  16338. * Event raised when the texture is generated
  16339. */
  16340. onGeneratedObservable: Observable<ProceduralTexture>;
  16341. /** @hidden */
  16342. _generateMipMaps: boolean;
  16343. /** @hidden **/
  16344. _effect: Effect;
  16345. /** @hidden */
  16346. _textures: {
  16347. [key: string]: Texture;
  16348. };
  16349. private _size;
  16350. private _currentRefreshId;
  16351. private _refreshRate;
  16352. private _vertexBuffers;
  16353. private _indexBuffer;
  16354. private _uniforms;
  16355. private _samplers;
  16356. private _fragment;
  16357. private _floats;
  16358. private _ints;
  16359. private _floatsArrays;
  16360. private _colors3;
  16361. private _colors4;
  16362. private _vectors2;
  16363. private _vectors3;
  16364. private _matrices;
  16365. private _fallbackTexture;
  16366. private _fallbackTextureUsed;
  16367. private _engine;
  16368. private _cachedDefines;
  16369. private _contentUpdateId;
  16370. private _contentData;
  16371. /**
  16372. * Instantiates a new procedural texture.
  16373. * 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.
  16374. * This is the base class of any Procedural texture and contains most of the shareable code.
  16375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16376. * @param name Define the name of the texture
  16377. * @param size Define the size of the texture to create
  16378. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16379. * @param scene Define the scene the texture belongs to
  16380. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16381. * @param generateMipMaps Define if the texture should creates mip maps or not
  16382. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16383. */
  16384. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16385. /**
  16386. * The effect that is created when initializing the post process.
  16387. * @returns The created effect corresponding the the postprocess.
  16388. */
  16389. getEffect(): Effect;
  16390. /**
  16391. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16392. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16393. */
  16394. getContent(): Nullable<ArrayBufferView>;
  16395. private _createIndexBuffer;
  16396. /** @hidden */
  16397. _rebuild(): void;
  16398. /**
  16399. * Resets the texture in order to recreate its associated resources.
  16400. * This can be called in case of context loss
  16401. */
  16402. reset(): void;
  16403. protected _getDefines(): string;
  16404. /**
  16405. * Is the texture ready to be used ? (rendered at least once)
  16406. * @returns true if ready, otherwise, false.
  16407. */
  16408. isReady(): boolean;
  16409. /**
  16410. * Resets the refresh counter of the texture and start bak from scratch.
  16411. * Could be useful to regenerate the texture if it is setup to render only once.
  16412. */
  16413. resetRefreshCounter(): void;
  16414. /**
  16415. * Set the fragment shader to use in order to render the texture.
  16416. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16417. */
  16418. setFragment(fragment: any): void;
  16419. /**
  16420. * Define the refresh rate of the texture or the rendering frequency.
  16421. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16422. */
  16423. refreshRate: number;
  16424. /** @hidden */
  16425. _shouldRender(): boolean;
  16426. /**
  16427. * Get the size the texture is rendering at.
  16428. * @returns the size (texture is always squared)
  16429. */
  16430. getRenderSize(): number;
  16431. /**
  16432. * Resize the texture to new value.
  16433. * @param size Define the new size the texture should have
  16434. * @param generateMipMaps Define whether the new texture should create mip maps
  16435. */
  16436. resize(size: number, generateMipMaps: boolean): void;
  16437. private _checkUniform;
  16438. /**
  16439. * Set a texture in the shader program used to render.
  16440. * @param name Define the name of the uniform samplers as defined in the shader
  16441. * @param texture Define the texture to bind to this sampler
  16442. * @return the texture itself allowing "fluent" like uniform updates
  16443. */
  16444. setTexture(name: string, texture: Texture): ProceduralTexture;
  16445. /**
  16446. * Set a float in the shader.
  16447. * @param name Define the name of the uniform as defined in the shader
  16448. * @param value Define the value to give to the uniform
  16449. * @return the texture itself allowing "fluent" like uniform updates
  16450. */
  16451. setFloat(name: string, value: number): ProceduralTexture;
  16452. /**
  16453. * Set a int in the shader.
  16454. * @param name Define the name of the uniform as defined in the shader
  16455. * @param value Define the value to give to the uniform
  16456. * @return the texture itself allowing "fluent" like uniform updates
  16457. */
  16458. setInt(name: string, value: number): ProceduralTexture;
  16459. /**
  16460. * Set an array of floats in the shader.
  16461. * @param name Define the name of the uniform as defined in the shader
  16462. * @param value Define the value to give to the uniform
  16463. * @return the texture itself allowing "fluent" like uniform updates
  16464. */
  16465. setFloats(name: string, value: number[]): ProceduralTexture;
  16466. /**
  16467. * Set a vec3 in the shader from a Color3.
  16468. * @param name Define the name of the uniform as defined in the shader
  16469. * @param value Define the value to give to the uniform
  16470. * @return the texture itself allowing "fluent" like uniform updates
  16471. */
  16472. setColor3(name: string, value: Color3): ProceduralTexture;
  16473. /**
  16474. * Set a vec4 in the shader from a Color4.
  16475. * @param name Define the name of the uniform as defined in the shader
  16476. * @param value Define the value to give to the uniform
  16477. * @return the texture itself allowing "fluent" like uniform updates
  16478. */
  16479. setColor4(name: string, value: Color4): ProceduralTexture;
  16480. /**
  16481. * Set a vec2 in the shader from a Vector2.
  16482. * @param name Define the name of the uniform as defined in the shader
  16483. * @param value Define the value to give to the uniform
  16484. * @return the texture itself allowing "fluent" like uniform updates
  16485. */
  16486. setVector2(name: string, value: Vector2): ProceduralTexture;
  16487. /**
  16488. * Set a vec3 in the shader from a Vector3.
  16489. * @param name Define the name of the uniform as defined in the shader
  16490. * @param value Define the value to give to the uniform
  16491. * @return the texture itself allowing "fluent" like uniform updates
  16492. */
  16493. setVector3(name: string, value: Vector3): ProceduralTexture;
  16494. /**
  16495. * Set a mat4 in the shader from a MAtrix.
  16496. * @param name Define the name of the uniform as defined in the shader
  16497. * @param value Define the value to give to the uniform
  16498. * @return the texture itself allowing "fluent" like uniform updates
  16499. */
  16500. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16501. /**
  16502. * Render the texture to its associated render target.
  16503. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16504. */
  16505. render(useCameraPostProcess?: boolean): void;
  16506. /**
  16507. * Clone the texture.
  16508. * @returns the cloned texture
  16509. */
  16510. clone(): ProceduralTexture;
  16511. /**
  16512. * Dispose the texture and release its asoociated resources.
  16513. */
  16514. dispose(): void;
  16515. }
  16516. }
  16517. declare module "babylonjs/Particles/baseParticleSystem" {
  16518. import { Nullable } from "babylonjs/types";
  16519. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16521. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16522. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16523. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16524. import { Scene } from "babylonjs/scene";
  16525. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16526. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16527. import { Texture } from "babylonjs/Materials/Textures/texture";
  16528. import { Color4 } from "babylonjs/Maths/math.color";
  16529. import { Animation } from "babylonjs/Animations/animation";
  16530. /**
  16531. * This represents the base class for particle system in Babylon.
  16532. * 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.
  16533. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16534. * @example https://doc.babylonjs.com/babylon101/particles
  16535. */
  16536. export class BaseParticleSystem {
  16537. /**
  16538. * Source color is added to the destination color without alpha affecting the result
  16539. */
  16540. static BLENDMODE_ONEONE: number;
  16541. /**
  16542. * Blend current color and particle color using particle’s alpha
  16543. */
  16544. static BLENDMODE_STANDARD: number;
  16545. /**
  16546. * Add current color and particle color multiplied by particle’s alpha
  16547. */
  16548. static BLENDMODE_ADD: number;
  16549. /**
  16550. * Multiply current color with particle color
  16551. */
  16552. static BLENDMODE_MULTIPLY: number;
  16553. /**
  16554. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16555. */
  16556. static BLENDMODE_MULTIPLYADD: number;
  16557. /**
  16558. * List of animations used by the particle system.
  16559. */
  16560. animations: Animation[];
  16561. /**
  16562. * The id of the Particle system.
  16563. */
  16564. id: string;
  16565. /**
  16566. * The friendly name of the Particle system.
  16567. */
  16568. name: string;
  16569. /**
  16570. * The rendering group used by the Particle system to chose when to render.
  16571. */
  16572. renderingGroupId: number;
  16573. /**
  16574. * The emitter represents the Mesh or position we are attaching the particle system to.
  16575. */
  16576. emitter: Nullable<AbstractMesh | Vector3>;
  16577. /**
  16578. * The maximum number of particles to emit per frame
  16579. */
  16580. emitRate: number;
  16581. /**
  16582. * If you want to launch only a few particles at once, that can be done, as well.
  16583. */
  16584. manualEmitCount: number;
  16585. /**
  16586. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16587. */
  16588. updateSpeed: number;
  16589. /**
  16590. * The amount of time the particle system is running (depends of the overall update speed).
  16591. */
  16592. targetStopDuration: number;
  16593. /**
  16594. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16595. */
  16596. disposeOnStop: boolean;
  16597. /**
  16598. * Minimum power of emitting particles.
  16599. */
  16600. minEmitPower: number;
  16601. /**
  16602. * Maximum power of emitting particles.
  16603. */
  16604. maxEmitPower: number;
  16605. /**
  16606. * Minimum life time of emitting particles.
  16607. */
  16608. minLifeTime: number;
  16609. /**
  16610. * Maximum life time of emitting particles.
  16611. */
  16612. maxLifeTime: number;
  16613. /**
  16614. * Minimum Size of emitting particles.
  16615. */
  16616. minSize: number;
  16617. /**
  16618. * Maximum Size of emitting particles.
  16619. */
  16620. maxSize: number;
  16621. /**
  16622. * Minimum scale of emitting particles on X axis.
  16623. */
  16624. minScaleX: number;
  16625. /**
  16626. * Maximum scale of emitting particles on X axis.
  16627. */
  16628. maxScaleX: number;
  16629. /**
  16630. * Minimum scale of emitting particles on Y axis.
  16631. */
  16632. minScaleY: number;
  16633. /**
  16634. * Maximum scale of emitting particles on Y axis.
  16635. */
  16636. maxScaleY: number;
  16637. /**
  16638. * Gets or sets the minimal initial rotation in radians.
  16639. */
  16640. minInitialRotation: number;
  16641. /**
  16642. * Gets or sets the maximal initial rotation in radians.
  16643. */
  16644. maxInitialRotation: number;
  16645. /**
  16646. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16647. */
  16648. minAngularSpeed: number;
  16649. /**
  16650. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16651. */
  16652. maxAngularSpeed: number;
  16653. /**
  16654. * The texture used to render each particle. (this can be a spritesheet)
  16655. */
  16656. particleTexture: Nullable<Texture>;
  16657. /**
  16658. * The layer mask we are rendering the particles through.
  16659. */
  16660. layerMask: number;
  16661. /**
  16662. * This can help using your own shader to render the particle system.
  16663. * The according effect will be created
  16664. */
  16665. customShader: any;
  16666. /**
  16667. * By default particle system starts as soon as they are created. This prevents the
  16668. * automatic start to happen and let you decide when to start emitting particles.
  16669. */
  16670. preventAutoStart: boolean;
  16671. private _noiseTexture;
  16672. /**
  16673. * Gets or sets a texture used to add random noise to particle positions
  16674. */
  16675. noiseTexture: Nullable<ProceduralTexture>;
  16676. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16677. noiseStrength: Vector3;
  16678. /**
  16679. * Callback triggered when the particle animation is ending.
  16680. */
  16681. onAnimationEnd: Nullable<() => void>;
  16682. /**
  16683. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16684. */
  16685. blendMode: number;
  16686. /**
  16687. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16688. * to override the particles.
  16689. */
  16690. forceDepthWrite: boolean;
  16691. /** 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 */
  16692. preWarmCycles: number;
  16693. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16694. preWarmStepOffset: number;
  16695. /**
  16696. * 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)
  16697. */
  16698. spriteCellChangeSpeed: number;
  16699. /**
  16700. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16701. */
  16702. startSpriteCellID: number;
  16703. /**
  16704. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16705. */
  16706. endSpriteCellID: number;
  16707. /**
  16708. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16709. */
  16710. spriteCellWidth: number;
  16711. /**
  16712. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16713. */
  16714. spriteCellHeight: number;
  16715. /**
  16716. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16717. */
  16718. spriteRandomStartCell: boolean;
  16719. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16720. translationPivot: Vector2;
  16721. /** @hidden */
  16722. protected _isAnimationSheetEnabled: boolean;
  16723. /**
  16724. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16725. */
  16726. beginAnimationOnStart: boolean;
  16727. /**
  16728. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16729. */
  16730. beginAnimationFrom: number;
  16731. /**
  16732. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16733. */
  16734. beginAnimationTo: number;
  16735. /**
  16736. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16737. */
  16738. beginAnimationLoop: boolean;
  16739. /**
  16740. * Gets or sets a world offset applied to all particles
  16741. */
  16742. worldOffset: Vector3;
  16743. /**
  16744. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16745. */
  16746. isAnimationSheetEnabled: boolean;
  16747. /**
  16748. * Get hosting scene
  16749. * @returns the scene
  16750. */
  16751. getScene(): Scene;
  16752. /**
  16753. * You can use gravity if you want to give an orientation to your particles.
  16754. */
  16755. gravity: Vector3;
  16756. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16757. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16758. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16759. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16760. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16761. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16762. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16763. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16764. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16765. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16766. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16767. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16768. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16769. /**
  16770. * Defines the delay in milliseconds before starting the system (0 by default)
  16771. */
  16772. startDelay: number;
  16773. /**
  16774. * Gets the current list of drag gradients.
  16775. * You must use addDragGradient and removeDragGradient to udpate this list
  16776. * @returns the list of drag gradients
  16777. */
  16778. getDragGradients(): Nullable<Array<FactorGradient>>;
  16779. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16780. limitVelocityDamping: number;
  16781. /**
  16782. * Gets the current list of limit velocity gradients.
  16783. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16784. * @returns the list of limit velocity gradients
  16785. */
  16786. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16787. /**
  16788. * Gets the current list of color gradients.
  16789. * You must use addColorGradient and removeColorGradient to udpate this list
  16790. * @returns the list of color gradients
  16791. */
  16792. getColorGradients(): Nullable<Array<ColorGradient>>;
  16793. /**
  16794. * Gets the current list of size gradients.
  16795. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16796. * @returns the list of size gradients
  16797. */
  16798. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16799. /**
  16800. * Gets the current list of color remap gradients.
  16801. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16802. * @returns the list of color remap gradients
  16803. */
  16804. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16805. /**
  16806. * Gets the current list of alpha remap gradients.
  16807. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16808. * @returns the list of alpha remap gradients
  16809. */
  16810. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16811. /**
  16812. * Gets the current list of life time gradients.
  16813. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16814. * @returns the list of life time gradients
  16815. */
  16816. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16817. /**
  16818. * Gets the current list of angular speed gradients.
  16819. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16820. * @returns the list of angular speed gradients
  16821. */
  16822. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16823. /**
  16824. * Gets the current list of velocity gradients.
  16825. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16826. * @returns the list of velocity gradients
  16827. */
  16828. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16829. /**
  16830. * Gets the current list of start size gradients.
  16831. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16832. * @returns the list of start size gradients
  16833. */
  16834. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16835. /**
  16836. * Gets the current list of emit rate gradients.
  16837. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16838. * @returns the list of emit rate gradients
  16839. */
  16840. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  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. direction1: Vector3;
  16846. /**
  16847. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16848. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16849. */
  16850. direction2: Vector3;
  16851. /**
  16852. * 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.
  16853. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16854. */
  16855. minEmitBox: Vector3;
  16856. /**
  16857. * 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.
  16858. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16859. */
  16860. maxEmitBox: Vector3;
  16861. /**
  16862. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16863. */
  16864. color1: Color4;
  16865. /**
  16866. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16867. */
  16868. color2: Color4;
  16869. /**
  16870. * Color the particle will have at the end of its lifetime
  16871. */
  16872. colorDead: Color4;
  16873. /**
  16874. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16875. */
  16876. textureMask: Color4;
  16877. /**
  16878. * The particle emitter type defines the emitter used by the particle system.
  16879. * It can be for example box, sphere, or cone...
  16880. */
  16881. particleEmitterType: IParticleEmitterType;
  16882. /** @hidden */
  16883. _isSubEmitter: boolean;
  16884. /**
  16885. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16886. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16887. */
  16888. billboardMode: number;
  16889. protected _isBillboardBased: boolean;
  16890. /**
  16891. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16892. */
  16893. isBillboardBased: boolean;
  16894. /**
  16895. * The scene the particle system belongs to.
  16896. */
  16897. protected _scene: Scene;
  16898. /**
  16899. * Local cache of defines for image processing.
  16900. */
  16901. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16902. /**
  16903. * Default configuration related to image processing available in the standard Material.
  16904. */
  16905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16906. /**
  16907. * Gets the image processing configuration used either in this material.
  16908. */
  16909. /**
  16910. * Sets the Default image processing configuration used either in the this material.
  16911. *
  16912. * If sets to null, the scene one is in use.
  16913. */
  16914. imageProcessingConfiguration: ImageProcessingConfiguration;
  16915. /**
  16916. * Attaches a new image processing configuration to the Standard Material.
  16917. * @param configuration
  16918. */
  16919. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16920. /** @hidden */
  16921. protected _reset(): void;
  16922. /** @hidden */
  16923. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16924. /**
  16925. * Instantiates a particle system.
  16926. * 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.
  16927. * @param name The name of the particle system
  16928. */
  16929. constructor(name: string);
  16930. /**
  16931. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16932. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16933. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16934. * @returns the emitter
  16935. */
  16936. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16937. /**
  16938. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16939. * @param radius The radius of the hemisphere to emit from
  16940. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16941. * @returns the emitter
  16942. */
  16943. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16944. /**
  16945. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16946. * @param radius The radius of the sphere to emit from
  16947. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16948. * @returns the emitter
  16949. */
  16950. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16951. /**
  16952. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16953. * @param radius The radius of the sphere to emit from
  16954. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16955. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16956. * @returns the emitter
  16957. */
  16958. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16959. /**
  16960. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16961. * @param radius The radius of the emission cylinder
  16962. * @param height The height of the emission cylinder
  16963. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16964. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16965. * @returns the emitter
  16966. */
  16967. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16968. /**
  16969. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16970. * @param radius The radius of the cylinder to emit from
  16971. * @param height The height of the emission cylinder
  16972. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16973. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16974. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16975. * @returns the emitter
  16976. */
  16977. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16978. /**
  16979. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16980. * @param radius The radius of the cone to emit from
  16981. * @param angle The base angle of the cone
  16982. * @returns the emitter
  16983. */
  16984. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16985. /**
  16986. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16987. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16988. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16989. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16990. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16991. * @returns the emitter
  16992. */
  16993. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16994. }
  16995. }
  16996. declare module "babylonjs/Particles/subEmitter" {
  16997. import { Scene } from "babylonjs/scene";
  16998. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  16999. /**
  17000. * Type of sub emitter
  17001. */
  17002. export enum SubEmitterType {
  17003. /**
  17004. * Attached to the particle over it's lifetime
  17005. */
  17006. ATTACHED = 0,
  17007. /**
  17008. * Created when the particle dies
  17009. */
  17010. END = 1
  17011. }
  17012. /**
  17013. * Sub emitter class used to emit particles from an existing particle
  17014. */
  17015. export class SubEmitter {
  17016. /**
  17017. * the particle system to be used by the sub emitter
  17018. */
  17019. particleSystem: ParticleSystem;
  17020. /**
  17021. * Type of the submitter (Default: END)
  17022. */
  17023. type: SubEmitterType;
  17024. /**
  17025. * 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)
  17026. * Note: This only is supported when using an emitter of type Mesh
  17027. */
  17028. inheritDirection: boolean;
  17029. /**
  17030. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17031. */
  17032. inheritedVelocityAmount: number;
  17033. /**
  17034. * Creates a sub emitter
  17035. * @param particleSystem the particle system to be used by the sub emitter
  17036. */
  17037. constructor(
  17038. /**
  17039. * the particle system to be used by the sub emitter
  17040. */
  17041. particleSystem: ParticleSystem);
  17042. /**
  17043. * Clones the sub emitter
  17044. * @returns the cloned sub emitter
  17045. */
  17046. clone(): SubEmitter;
  17047. /**
  17048. * Serialize current object to a JSON object
  17049. * @returns the serialized object
  17050. */
  17051. serialize(): any;
  17052. /** @hidden */
  17053. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17054. /**
  17055. * Creates a new SubEmitter from a serialized JSON version
  17056. * @param serializationObject defines the JSON object to read from
  17057. * @param scene defines the hosting scene
  17058. * @param rootUrl defines the rootUrl for data loading
  17059. * @returns a new SubEmitter
  17060. */
  17061. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17062. /** Release associated resources */
  17063. dispose(): void;
  17064. }
  17065. }
  17066. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17067. /** @hidden */
  17068. export var clipPlaneFragmentDeclaration: {
  17069. name: string;
  17070. shader: string;
  17071. };
  17072. }
  17073. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17074. /** @hidden */
  17075. export var imageProcessingDeclaration: {
  17076. name: string;
  17077. shader: string;
  17078. };
  17079. }
  17080. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17081. /** @hidden */
  17082. export var imageProcessingFunctions: {
  17083. name: string;
  17084. shader: string;
  17085. };
  17086. }
  17087. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17088. /** @hidden */
  17089. export var clipPlaneFragment: {
  17090. name: string;
  17091. shader: string;
  17092. };
  17093. }
  17094. declare module "babylonjs/Shaders/particles.fragment" {
  17095. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17096. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17098. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17099. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17100. /** @hidden */
  17101. export var particlesPixelShader: {
  17102. name: string;
  17103. shader: string;
  17104. };
  17105. }
  17106. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17107. /** @hidden */
  17108. export var clipPlaneVertexDeclaration: {
  17109. name: string;
  17110. shader: string;
  17111. };
  17112. }
  17113. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17114. /** @hidden */
  17115. export var clipPlaneVertex: {
  17116. name: string;
  17117. shader: string;
  17118. };
  17119. }
  17120. declare module "babylonjs/Shaders/particles.vertex" {
  17121. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17122. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17123. /** @hidden */
  17124. export var particlesVertexShader: {
  17125. name: string;
  17126. shader: string;
  17127. };
  17128. }
  17129. declare module "babylonjs/Particles/particleSystem" {
  17130. import { Nullable } from "babylonjs/types";
  17131. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17132. import { Observable } from "babylonjs/Misc/observable";
  17133. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17134. import { Effect } from "babylonjs/Materials/effect";
  17135. import { Scene, IDisposable } from "babylonjs/scene";
  17136. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17137. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17138. import { Particle } from "babylonjs/Particles/particle";
  17139. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17140. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17141. import "babylonjs/Shaders/particles.fragment";
  17142. import "babylonjs/Shaders/particles.vertex";
  17143. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17144. /**
  17145. * This represents a particle system in Babylon.
  17146. * 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.
  17147. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17148. * @example https://doc.babylonjs.com/babylon101/particles
  17149. */
  17150. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17151. /**
  17152. * Billboard mode will only apply to Y axis
  17153. */
  17154. static readonly BILLBOARDMODE_Y: number;
  17155. /**
  17156. * Billboard mode will apply to all axes
  17157. */
  17158. static readonly BILLBOARDMODE_ALL: number;
  17159. /**
  17160. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17161. */
  17162. static readonly BILLBOARDMODE_STRETCHED: number;
  17163. /**
  17164. * This function can be defined to provide custom update for active particles.
  17165. * This function will be called instead of regular update (age, position, color, etc.).
  17166. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17167. */
  17168. updateFunction: (particles: Particle[]) => void;
  17169. private _emitterWorldMatrix;
  17170. /**
  17171. * This function can be defined to specify initial direction for every new particle.
  17172. * It by default use the emitterType defined function
  17173. */
  17174. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17175. /**
  17176. * This function can be defined to specify initial position for every new particle.
  17177. * It by default use the emitterType defined function
  17178. */
  17179. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17180. /**
  17181. * @hidden
  17182. */
  17183. _inheritedVelocityOffset: Vector3;
  17184. /**
  17185. * An event triggered when the system is disposed
  17186. */
  17187. onDisposeObservable: Observable<ParticleSystem>;
  17188. private _onDisposeObserver;
  17189. /**
  17190. * Sets a callback that will be triggered when the system is disposed
  17191. */
  17192. onDispose: () => void;
  17193. private _particles;
  17194. private _epsilon;
  17195. private _capacity;
  17196. private _stockParticles;
  17197. private _newPartsExcess;
  17198. private _vertexData;
  17199. private _vertexBuffer;
  17200. private _vertexBuffers;
  17201. private _spriteBuffer;
  17202. private _indexBuffer;
  17203. private _effect;
  17204. private _customEffect;
  17205. private _cachedDefines;
  17206. private _scaledColorStep;
  17207. private _colorDiff;
  17208. private _scaledDirection;
  17209. private _scaledGravity;
  17210. private _currentRenderId;
  17211. private _alive;
  17212. private _useInstancing;
  17213. private _started;
  17214. private _stopped;
  17215. private _actualFrame;
  17216. private _scaledUpdateSpeed;
  17217. private _vertexBufferSize;
  17218. /** @hidden */
  17219. _currentEmitRateGradient: Nullable<FactorGradient>;
  17220. /** @hidden */
  17221. _currentEmitRate1: number;
  17222. /** @hidden */
  17223. _currentEmitRate2: number;
  17224. /** @hidden */
  17225. _currentStartSizeGradient: Nullable<FactorGradient>;
  17226. /** @hidden */
  17227. _currentStartSize1: number;
  17228. /** @hidden */
  17229. _currentStartSize2: number;
  17230. private readonly _rawTextureWidth;
  17231. private _rampGradientsTexture;
  17232. private _useRampGradients;
  17233. /** Gets or sets a boolean indicating that ramp gradients must be used
  17234. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17235. */
  17236. useRampGradients: boolean;
  17237. /**
  17238. * 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.
  17239. * 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: [])
  17240. */
  17241. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17242. private _subEmitters;
  17243. /**
  17244. * @hidden
  17245. * If the particle systems emitter should be disposed when the particle system is disposed
  17246. */
  17247. _disposeEmitterOnDispose: boolean;
  17248. /**
  17249. * The current active Sub-systems, this property is used by the root particle system only.
  17250. */
  17251. activeSubSystems: Array<ParticleSystem>;
  17252. private _rootParticleSystem;
  17253. /**
  17254. * Gets the current list of active particles
  17255. */
  17256. readonly particles: Particle[];
  17257. /**
  17258. * Returns the string "ParticleSystem"
  17259. * @returns a string containing the class name
  17260. */
  17261. getClassName(): string;
  17262. /**
  17263. * Instantiates a particle system.
  17264. * 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.
  17265. * @param name The name of the particle system
  17266. * @param capacity The max number of particles alive at the same time
  17267. * @param scene The scene the particle system belongs to
  17268. * @param customEffect a custom effect used to change the way particles are rendered by default
  17269. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17270. * @param epsilon Offset used to render the particles
  17271. */
  17272. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17273. private _addFactorGradient;
  17274. private _removeFactorGradient;
  17275. /**
  17276. * Adds a new life time gradient
  17277. * @param gradient defines the gradient to use (between 0 and 1)
  17278. * @param factor defines the life time factor to affect to the specified gradient
  17279. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17280. * @returns the current particle system
  17281. */
  17282. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17283. /**
  17284. * Remove a specific life time gradient
  17285. * @param gradient defines the gradient to remove
  17286. * @returns the current particle system
  17287. */
  17288. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17289. /**
  17290. * Adds a new size gradient
  17291. * @param gradient defines the gradient to use (between 0 and 1)
  17292. * @param factor defines the size factor to affect to the specified gradient
  17293. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17294. * @returns the current particle system
  17295. */
  17296. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17297. /**
  17298. * Remove a specific size gradient
  17299. * @param gradient defines the gradient to remove
  17300. * @returns the current particle system
  17301. */
  17302. removeSizeGradient(gradient: number): IParticleSystem;
  17303. /**
  17304. * Adds a new color remap gradient
  17305. * @param gradient defines the gradient to use (between 0 and 1)
  17306. * @param min defines the color remap minimal range
  17307. * @param max defines the color remap maximal range
  17308. * @returns the current particle system
  17309. */
  17310. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17311. /**
  17312. * Remove a specific color remap gradient
  17313. * @param gradient defines the gradient to remove
  17314. * @returns the current particle system
  17315. */
  17316. removeColorRemapGradient(gradient: number): IParticleSystem;
  17317. /**
  17318. * Adds a new alpha remap gradient
  17319. * @param gradient defines the gradient to use (between 0 and 1)
  17320. * @param min defines the alpha remap minimal range
  17321. * @param max defines the alpha remap maximal range
  17322. * @returns the current particle system
  17323. */
  17324. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17325. /**
  17326. * Remove a specific alpha remap gradient
  17327. * @param gradient defines the gradient to remove
  17328. * @returns the current particle system
  17329. */
  17330. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17331. /**
  17332. * Adds a new angular speed gradient
  17333. * @param gradient defines the gradient to use (between 0 and 1)
  17334. * @param factor defines the angular speed to affect to the specified gradient
  17335. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17336. * @returns the current particle system
  17337. */
  17338. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17339. /**
  17340. * Remove a specific angular speed gradient
  17341. * @param gradient defines the gradient to remove
  17342. * @returns the current particle system
  17343. */
  17344. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17345. /**
  17346. * Adds a new velocity gradient
  17347. * @param gradient defines the gradient to use (between 0 and 1)
  17348. * @param factor defines the velocity to affect to the specified gradient
  17349. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17350. * @returns the current particle system
  17351. */
  17352. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17353. /**
  17354. * Remove a specific velocity gradient
  17355. * @param gradient defines the gradient to remove
  17356. * @returns the current particle system
  17357. */
  17358. removeVelocityGradient(gradient: number): IParticleSystem;
  17359. /**
  17360. * Adds a new limit velocity gradient
  17361. * @param gradient defines the gradient to use (between 0 and 1)
  17362. * @param factor defines the limit velocity value to affect to the specified gradient
  17363. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17364. * @returns the current particle system
  17365. */
  17366. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17367. /**
  17368. * Remove a specific limit velocity gradient
  17369. * @param gradient defines the gradient to remove
  17370. * @returns the current particle system
  17371. */
  17372. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17373. /**
  17374. * Adds a new drag gradient
  17375. * @param gradient defines the gradient to use (between 0 and 1)
  17376. * @param factor defines the drag value to affect to the specified gradient
  17377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17378. * @returns the current particle system
  17379. */
  17380. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17381. /**
  17382. * Remove a specific drag gradient
  17383. * @param gradient defines the gradient to remove
  17384. * @returns the current particle system
  17385. */
  17386. removeDragGradient(gradient: number): IParticleSystem;
  17387. /**
  17388. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17389. * @param gradient defines the gradient to use (between 0 and 1)
  17390. * @param factor defines the emit rate value to affect to the specified gradient
  17391. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17392. * @returns the current particle system
  17393. */
  17394. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17395. /**
  17396. * Remove a specific emit rate gradient
  17397. * @param gradient defines the gradient to remove
  17398. * @returns the current particle system
  17399. */
  17400. removeEmitRateGradient(gradient: number): IParticleSystem;
  17401. /**
  17402. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17403. * @param gradient defines the gradient to use (between 0 and 1)
  17404. * @param factor defines the start size value to affect to the specified gradient
  17405. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17406. * @returns the current particle system
  17407. */
  17408. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17409. /**
  17410. * Remove a specific start size gradient
  17411. * @param gradient defines the gradient to remove
  17412. * @returns the current particle system
  17413. */
  17414. removeStartSizeGradient(gradient: number): IParticleSystem;
  17415. private _createRampGradientTexture;
  17416. /**
  17417. * Gets the current list of ramp gradients.
  17418. * You must use addRampGradient and removeRampGradient to udpate this list
  17419. * @returns the list of ramp gradients
  17420. */
  17421. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17422. /**
  17423. * Adds a new ramp gradient used to remap particle colors
  17424. * @param gradient defines the gradient to use (between 0 and 1)
  17425. * @param color defines the color to affect to the specified gradient
  17426. * @returns the current particle system
  17427. */
  17428. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17429. /**
  17430. * Remove a specific ramp gradient
  17431. * @param gradient defines the gradient to remove
  17432. * @returns the current particle system
  17433. */
  17434. removeRampGradient(gradient: number): ParticleSystem;
  17435. /**
  17436. * Adds a new color gradient
  17437. * @param gradient defines the gradient to use (between 0 and 1)
  17438. * @param color1 defines the color to affect to the specified gradient
  17439. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17440. * @returns this particle system
  17441. */
  17442. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17443. /**
  17444. * Remove a specific color gradient
  17445. * @param gradient defines the gradient to remove
  17446. * @returns this particle system
  17447. */
  17448. removeColorGradient(gradient: number): IParticleSystem;
  17449. private _fetchR;
  17450. protected _reset(): void;
  17451. private _resetEffect;
  17452. private _createVertexBuffers;
  17453. private _createIndexBuffer;
  17454. /**
  17455. * Gets the maximum number of particles active at the same time.
  17456. * @returns The max number of active particles.
  17457. */
  17458. getCapacity(): number;
  17459. /**
  17460. * Gets whether there are still active particles in the system.
  17461. * @returns True if it is alive, otherwise false.
  17462. */
  17463. isAlive(): boolean;
  17464. /**
  17465. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17466. * @returns True if it has been started, otherwise false.
  17467. */
  17468. isStarted(): boolean;
  17469. private _prepareSubEmitterInternalArray;
  17470. /**
  17471. * Starts the particle system and begins to emit
  17472. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17473. */
  17474. start(delay?: number): void;
  17475. /**
  17476. * Stops the particle system.
  17477. * @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.
  17478. */
  17479. stop(stopSubEmitters?: boolean): void;
  17480. /**
  17481. * Remove all active particles
  17482. */
  17483. reset(): void;
  17484. /**
  17485. * @hidden (for internal use only)
  17486. */
  17487. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17488. /**
  17489. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17490. * Its lifetime will start back at 0.
  17491. */
  17492. recycleParticle: (particle: Particle) => void;
  17493. private _stopSubEmitters;
  17494. private _createParticle;
  17495. private _removeFromRoot;
  17496. private _emitFromParticle;
  17497. private _update;
  17498. /** @hidden */
  17499. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17500. /** @hidden */
  17501. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17502. /** @hidden */
  17503. private _getEffect;
  17504. /**
  17505. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17506. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17507. */
  17508. animate(preWarmOnly?: boolean): void;
  17509. private _appendParticleVertices;
  17510. /**
  17511. * Rebuilds the particle system.
  17512. */
  17513. rebuild(): void;
  17514. /**
  17515. * Is this system ready to be used/rendered
  17516. * @return true if the system is ready
  17517. */
  17518. isReady(): boolean;
  17519. private _render;
  17520. /**
  17521. * Renders the particle system in its current state.
  17522. * @returns the current number of particles
  17523. */
  17524. render(): number;
  17525. /**
  17526. * Disposes the particle system and free the associated resources
  17527. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17528. */
  17529. dispose(disposeTexture?: boolean): void;
  17530. /**
  17531. * Clones the particle system.
  17532. * @param name The name of the cloned object
  17533. * @param newEmitter The new emitter to use
  17534. * @returns the cloned particle system
  17535. */
  17536. clone(name: string, newEmitter: any): ParticleSystem;
  17537. /**
  17538. * Serializes the particle system to a JSON object.
  17539. * @returns the JSON object
  17540. */
  17541. serialize(): any;
  17542. /** @hidden */
  17543. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17544. /** @hidden */
  17545. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17546. /**
  17547. * Parses a JSON object to create a particle system.
  17548. * @param parsedParticleSystem The JSON object to parse
  17549. * @param scene The scene to create the particle system in
  17550. * @param rootUrl The root url to use to load external dependencies like texture
  17551. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17552. * @returns the Parsed particle system
  17553. */
  17554. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17555. }
  17556. }
  17557. declare module "babylonjs/Particles/particle" {
  17558. import { Nullable } from "babylonjs/types";
  17559. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17560. import { Color4 } from "babylonjs/Maths/math.color";
  17561. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17562. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17563. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17564. /**
  17565. * A particle represents one of the element emitted by a particle system.
  17566. * This is mainly define by its coordinates, direction, velocity and age.
  17567. */
  17568. export class Particle {
  17569. /**
  17570. * The particle system the particle belongs to.
  17571. */
  17572. particleSystem: ParticleSystem;
  17573. private static _Count;
  17574. /**
  17575. * Unique ID of the particle
  17576. */
  17577. id: number;
  17578. /**
  17579. * The world position of the particle in the scene.
  17580. */
  17581. position: Vector3;
  17582. /**
  17583. * The world direction of the particle in the scene.
  17584. */
  17585. direction: Vector3;
  17586. /**
  17587. * The color of the particle.
  17588. */
  17589. color: Color4;
  17590. /**
  17591. * The color change of the particle per step.
  17592. */
  17593. colorStep: Color4;
  17594. /**
  17595. * Defines how long will the life of the particle be.
  17596. */
  17597. lifeTime: number;
  17598. /**
  17599. * The current age of the particle.
  17600. */
  17601. age: number;
  17602. /**
  17603. * The current size of the particle.
  17604. */
  17605. size: number;
  17606. /**
  17607. * The current scale of the particle.
  17608. */
  17609. scale: Vector2;
  17610. /**
  17611. * The current angle of the particle.
  17612. */
  17613. angle: number;
  17614. /**
  17615. * Defines how fast is the angle changing.
  17616. */
  17617. angularSpeed: number;
  17618. /**
  17619. * Defines the cell index used by the particle to be rendered from a sprite.
  17620. */
  17621. cellIndex: number;
  17622. /**
  17623. * The information required to support color remapping
  17624. */
  17625. remapData: Vector4;
  17626. /** @hidden */
  17627. _randomCellOffset?: number;
  17628. /** @hidden */
  17629. _initialDirection: Nullable<Vector3>;
  17630. /** @hidden */
  17631. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17632. /** @hidden */
  17633. _initialStartSpriteCellID: number;
  17634. /** @hidden */
  17635. _initialEndSpriteCellID: number;
  17636. /** @hidden */
  17637. _currentColorGradient: Nullable<ColorGradient>;
  17638. /** @hidden */
  17639. _currentColor1: Color4;
  17640. /** @hidden */
  17641. _currentColor2: Color4;
  17642. /** @hidden */
  17643. _currentSizeGradient: Nullable<FactorGradient>;
  17644. /** @hidden */
  17645. _currentSize1: number;
  17646. /** @hidden */
  17647. _currentSize2: number;
  17648. /** @hidden */
  17649. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17650. /** @hidden */
  17651. _currentAngularSpeed1: number;
  17652. /** @hidden */
  17653. _currentAngularSpeed2: number;
  17654. /** @hidden */
  17655. _currentVelocityGradient: Nullable<FactorGradient>;
  17656. /** @hidden */
  17657. _currentVelocity1: number;
  17658. /** @hidden */
  17659. _currentVelocity2: number;
  17660. /** @hidden */
  17661. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17662. /** @hidden */
  17663. _currentLimitVelocity1: number;
  17664. /** @hidden */
  17665. _currentLimitVelocity2: number;
  17666. /** @hidden */
  17667. _currentDragGradient: Nullable<FactorGradient>;
  17668. /** @hidden */
  17669. _currentDrag1: number;
  17670. /** @hidden */
  17671. _currentDrag2: number;
  17672. /** @hidden */
  17673. _randomNoiseCoordinates1: Vector3;
  17674. /** @hidden */
  17675. _randomNoiseCoordinates2: Vector3;
  17676. /**
  17677. * Creates a new instance Particle
  17678. * @param particleSystem the particle system the particle belongs to
  17679. */
  17680. constructor(
  17681. /**
  17682. * The particle system the particle belongs to.
  17683. */
  17684. particleSystem: ParticleSystem);
  17685. private updateCellInfoFromSystem;
  17686. /**
  17687. * Defines how the sprite cell index is updated for the particle
  17688. */
  17689. updateCellIndex(): void;
  17690. /** @hidden */
  17691. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17692. /** @hidden */
  17693. _inheritParticleInfoToSubEmitters(): void;
  17694. /** @hidden */
  17695. _reset(): void;
  17696. /**
  17697. * Copy the properties of particle to another one.
  17698. * @param other the particle to copy the information to.
  17699. */
  17700. copyTo(other: Particle): void;
  17701. }
  17702. }
  17703. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17704. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17705. import { Effect } from "babylonjs/Materials/effect";
  17706. import { Particle } from "babylonjs/Particles/particle";
  17707. /**
  17708. * Particle emitter represents a volume emitting particles.
  17709. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17710. */
  17711. export interface IParticleEmitterType {
  17712. /**
  17713. * Called by the particle System when the direction is computed for the created particle.
  17714. * @param worldMatrix is the world matrix of the particle system
  17715. * @param directionToUpdate is the direction vector to update with the result
  17716. * @param particle is the particle we are computed the direction for
  17717. */
  17718. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17719. /**
  17720. * Called by the particle System when the position is computed for the created particle.
  17721. * @param worldMatrix is the world matrix of the particle system
  17722. * @param positionToUpdate is the position vector to update with the result
  17723. * @param particle is the particle we are computed the position for
  17724. */
  17725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17726. /**
  17727. * Clones the current emitter and returns a copy of it
  17728. * @returns the new emitter
  17729. */
  17730. clone(): IParticleEmitterType;
  17731. /**
  17732. * Called by the GPUParticleSystem to setup the update shader
  17733. * @param effect defines the update shader
  17734. */
  17735. applyToShader(effect: Effect): void;
  17736. /**
  17737. * Returns a string to use to update the GPU particles update shader
  17738. * @returns the effect defines string
  17739. */
  17740. getEffectDefines(): string;
  17741. /**
  17742. * Returns a string representing the class name
  17743. * @returns a string containing the class name
  17744. */
  17745. getClassName(): string;
  17746. /**
  17747. * Serializes the particle system to a JSON object.
  17748. * @returns the JSON object
  17749. */
  17750. serialize(): any;
  17751. /**
  17752. * Parse properties from a JSON object
  17753. * @param serializationObject defines the JSON object
  17754. */
  17755. parse(serializationObject: any): void;
  17756. }
  17757. }
  17758. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  17759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17760. import { Effect } from "babylonjs/Materials/effect";
  17761. import { Particle } from "babylonjs/Particles/particle";
  17762. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17763. /**
  17764. * Particle emitter emitting particles from the inside of a box.
  17765. * It emits the particles randomly between 2 given directions.
  17766. */
  17767. export class BoxParticleEmitter implements IParticleEmitterType {
  17768. /**
  17769. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17770. */
  17771. direction1: Vector3;
  17772. /**
  17773. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17774. */
  17775. direction2: Vector3;
  17776. /**
  17777. * 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.
  17778. */
  17779. minEmitBox: Vector3;
  17780. /**
  17781. * 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.
  17782. */
  17783. maxEmitBox: Vector3;
  17784. /**
  17785. * Creates a new instance BoxParticleEmitter
  17786. */
  17787. constructor();
  17788. /**
  17789. * Called by the particle System when the direction is computed for the created particle.
  17790. * @param worldMatrix is the world matrix of the particle system
  17791. * @param directionToUpdate is the direction vector to update with the result
  17792. * @param particle is the particle we are computed the direction for
  17793. */
  17794. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17795. /**
  17796. * Called by the particle System when the position is computed for the created particle.
  17797. * @param worldMatrix is the world matrix of the particle system
  17798. * @param positionToUpdate is the position vector to update with the result
  17799. * @param particle is the particle we are computed the position for
  17800. */
  17801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17802. /**
  17803. * Clones the current emitter and returns a copy of it
  17804. * @returns the new emitter
  17805. */
  17806. clone(): BoxParticleEmitter;
  17807. /**
  17808. * Called by the GPUParticleSystem to setup the update shader
  17809. * @param effect defines the update shader
  17810. */
  17811. applyToShader(effect: Effect): void;
  17812. /**
  17813. * Returns a string to use to update the GPU particles update shader
  17814. * @returns a string containng the defines string
  17815. */
  17816. getEffectDefines(): string;
  17817. /**
  17818. * Returns the string "BoxParticleEmitter"
  17819. * @returns a string containing the class name
  17820. */
  17821. getClassName(): string;
  17822. /**
  17823. * Serializes the particle system to a JSON object.
  17824. * @returns the JSON object
  17825. */
  17826. serialize(): any;
  17827. /**
  17828. * Parse properties from a JSON object
  17829. * @param serializationObject defines the JSON object
  17830. */
  17831. parse(serializationObject: any): void;
  17832. }
  17833. }
  17834. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  17835. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17836. import { Effect } from "babylonjs/Materials/effect";
  17837. import { Particle } from "babylonjs/Particles/particle";
  17838. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17839. /**
  17840. * Particle emitter emitting particles from the inside of a cone.
  17841. * It emits the particles alongside the cone volume from the base to the particle.
  17842. * The emission direction might be randomized.
  17843. */
  17844. export class ConeParticleEmitter implements IParticleEmitterType {
  17845. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17846. directionRandomizer: number;
  17847. private _radius;
  17848. private _angle;
  17849. private _height;
  17850. /**
  17851. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17852. */
  17853. radiusRange: number;
  17854. /**
  17855. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17856. */
  17857. heightRange: number;
  17858. /**
  17859. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17860. */
  17861. emitFromSpawnPointOnly: boolean;
  17862. /**
  17863. * Gets or sets the radius of the emission cone
  17864. */
  17865. radius: number;
  17866. /**
  17867. * Gets or sets the angle of the emission cone
  17868. */
  17869. angle: number;
  17870. private _buildHeight;
  17871. /**
  17872. * Creates a new instance ConeParticleEmitter
  17873. * @param radius the radius of the emission cone (1 by default)
  17874. * @param angle the cone base angle (PI by default)
  17875. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17876. */
  17877. constructor(radius?: number, angle?: number,
  17878. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17879. directionRandomizer?: number);
  17880. /**
  17881. * Called by the particle System when the direction is computed for the created particle.
  17882. * @param worldMatrix is the world matrix of the particle system
  17883. * @param directionToUpdate is the direction vector to update with the result
  17884. * @param particle is the particle we are computed the direction for
  17885. */
  17886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17887. /**
  17888. * Called by the particle System when the position is computed for the created particle.
  17889. * @param worldMatrix is the world matrix of the particle system
  17890. * @param positionToUpdate is the position vector to update with the result
  17891. * @param particle is the particle we are computed the position for
  17892. */
  17893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17894. /**
  17895. * Clones the current emitter and returns a copy of it
  17896. * @returns the new emitter
  17897. */
  17898. clone(): ConeParticleEmitter;
  17899. /**
  17900. * Called by the GPUParticleSystem to setup the update shader
  17901. * @param effect defines the update shader
  17902. */
  17903. applyToShader(effect: Effect): void;
  17904. /**
  17905. * Returns a string to use to update the GPU particles update shader
  17906. * @returns a string containng the defines string
  17907. */
  17908. getEffectDefines(): string;
  17909. /**
  17910. * Returns the string "ConeParticleEmitter"
  17911. * @returns a string containing the class name
  17912. */
  17913. getClassName(): string;
  17914. /**
  17915. * Serializes the particle system to a JSON object.
  17916. * @returns the JSON object
  17917. */
  17918. serialize(): any;
  17919. /**
  17920. * Parse properties from a JSON object
  17921. * @param serializationObject defines the JSON object
  17922. */
  17923. parse(serializationObject: any): void;
  17924. }
  17925. }
  17926. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  17927. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17928. import { Effect } from "babylonjs/Materials/effect";
  17929. import { Particle } from "babylonjs/Particles/particle";
  17930. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  17931. /**
  17932. * Particle emitter emitting particles from the inside of a cylinder.
  17933. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17934. */
  17935. export class CylinderParticleEmitter implements IParticleEmitterType {
  17936. /**
  17937. * The radius of the emission cylinder.
  17938. */
  17939. radius: number;
  17940. /**
  17941. * The height of the emission cylinder.
  17942. */
  17943. height: number;
  17944. /**
  17945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17946. */
  17947. radiusRange: number;
  17948. /**
  17949. * How much to randomize the particle direction [0-1].
  17950. */
  17951. directionRandomizer: number;
  17952. /**
  17953. * Creates a new instance CylinderParticleEmitter
  17954. * @param radius the radius of the emission cylinder (1 by default)
  17955. * @param height the height of the emission cylinder (1 by default)
  17956. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17957. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17958. */
  17959. constructor(
  17960. /**
  17961. * The radius of the emission cylinder.
  17962. */
  17963. radius?: number,
  17964. /**
  17965. * The height of the emission cylinder.
  17966. */
  17967. height?: number,
  17968. /**
  17969. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17970. */
  17971. radiusRange?: number,
  17972. /**
  17973. * How much to randomize the particle direction [0-1].
  17974. */
  17975. directionRandomizer?: number);
  17976. /**
  17977. * Called by the particle System when the direction is computed for the created particle.
  17978. * @param worldMatrix is the world matrix of the particle system
  17979. * @param directionToUpdate is the direction vector to update with the result
  17980. * @param particle is the particle we are computed the direction for
  17981. */
  17982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17983. /**
  17984. * Called by the particle System when the position is computed for the created particle.
  17985. * @param worldMatrix is the world matrix of the particle system
  17986. * @param positionToUpdate is the position vector to update with the result
  17987. * @param particle is the particle we are computed the position for
  17988. */
  17989. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17990. /**
  17991. * Clones the current emitter and returns a copy of it
  17992. * @returns the new emitter
  17993. */
  17994. clone(): CylinderParticleEmitter;
  17995. /**
  17996. * Called by the GPUParticleSystem to setup the update shader
  17997. * @param effect defines the update shader
  17998. */
  17999. applyToShader(effect: Effect): void;
  18000. /**
  18001. * Returns a string to use to update the GPU particles update shader
  18002. * @returns a string containng the defines string
  18003. */
  18004. getEffectDefines(): string;
  18005. /**
  18006. * Returns the string "CylinderParticleEmitter"
  18007. * @returns a string containing the class name
  18008. */
  18009. getClassName(): string;
  18010. /**
  18011. * Serializes the particle system to a JSON object.
  18012. * @returns the JSON object
  18013. */
  18014. serialize(): any;
  18015. /**
  18016. * Parse properties from a JSON object
  18017. * @param serializationObject defines the JSON object
  18018. */
  18019. parse(serializationObject: any): void;
  18020. }
  18021. /**
  18022. * Particle emitter emitting particles from the inside of a cylinder.
  18023. * It emits the particles randomly between two vectors.
  18024. */
  18025. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18026. /**
  18027. * The min limit of the emission direction.
  18028. */
  18029. direction1: Vector3;
  18030. /**
  18031. * The max limit of the emission direction.
  18032. */
  18033. direction2: Vector3;
  18034. /**
  18035. * Creates a new instance CylinderDirectedParticleEmitter
  18036. * @param radius the radius of the emission cylinder (1 by default)
  18037. * @param height the height of the emission cylinder (1 by default)
  18038. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18039. * @param direction1 the min limit of the emission direction (up vector by default)
  18040. * @param direction2 the max limit of the emission direction (up vector by default)
  18041. */
  18042. constructor(radius?: number, height?: number, radiusRange?: number,
  18043. /**
  18044. * The min limit of the emission direction.
  18045. */
  18046. direction1?: Vector3,
  18047. /**
  18048. * The max limit of the emission direction.
  18049. */
  18050. direction2?: Vector3);
  18051. /**
  18052. * Called by the particle System when the direction is computed for the created particle.
  18053. * @param worldMatrix is the world matrix of the particle system
  18054. * @param directionToUpdate is the direction vector to update with the result
  18055. * @param particle is the particle we are computed the direction for
  18056. */
  18057. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18058. /**
  18059. * Clones the current emitter and returns a copy of it
  18060. * @returns the new emitter
  18061. */
  18062. clone(): CylinderDirectedParticleEmitter;
  18063. /**
  18064. * Called by the GPUParticleSystem to setup the update shader
  18065. * @param effect defines the update shader
  18066. */
  18067. applyToShader(effect: Effect): void;
  18068. /**
  18069. * Returns a string to use to update the GPU particles update shader
  18070. * @returns a string containng the defines string
  18071. */
  18072. getEffectDefines(): string;
  18073. /**
  18074. * Returns the string "CylinderDirectedParticleEmitter"
  18075. * @returns a string containing the class name
  18076. */
  18077. getClassName(): string;
  18078. /**
  18079. * Serializes the particle system to a JSON object.
  18080. * @returns the JSON object
  18081. */
  18082. serialize(): any;
  18083. /**
  18084. * Parse properties from a JSON object
  18085. * @param serializationObject defines the JSON object
  18086. */
  18087. parse(serializationObject: any): void;
  18088. }
  18089. }
  18090. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18091. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18092. import { Effect } from "babylonjs/Materials/effect";
  18093. import { Particle } from "babylonjs/Particles/particle";
  18094. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18095. /**
  18096. * Particle emitter emitting particles from the inside of a hemisphere.
  18097. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18098. */
  18099. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18100. /**
  18101. * The radius of the emission hemisphere.
  18102. */
  18103. radius: number;
  18104. /**
  18105. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18106. */
  18107. radiusRange: number;
  18108. /**
  18109. * How much to randomize the particle direction [0-1].
  18110. */
  18111. directionRandomizer: number;
  18112. /**
  18113. * Creates a new instance HemisphericParticleEmitter
  18114. * @param radius the radius of the emission hemisphere (1 by default)
  18115. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18116. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18117. */
  18118. constructor(
  18119. /**
  18120. * The radius of the emission hemisphere.
  18121. */
  18122. radius?: number,
  18123. /**
  18124. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18125. */
  18126. radiusRange?: number,
  18127. /**
  18128. * How much to randomize the particle direction [0-1].
  18129. */
  18130. directionRandomizer?: number);
  18131. /**
  18132. * Called by the particle System when the direction is computed for the created particle.
  18133. * @param worldMatrix is the world matrix of the particle system
  18134. * @param directionToUpdate is the direction vector to update with the result
  18135. * @param particle is the particle we are computed the direction for
  18136. */
  18137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18138. /**
  18139. * Called by the particle System when the position is computed for the created particle.
  18140. * @param worldMatrix is the world matrix of the particle system
  18141. * @param positionToUpdate is the position vector to update with the result
  18142. * @param particle is the particle we are computed the position for
  18143. */
  18144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18145. /**
  18146. * Clones the current emitter and returns a copy of it
  18147. * @returns the new emitter
  18148. */
  18149. clone(): HemisphericParticleEmitter;
  18150. /**
  18151. * Called by the GPUParticleSystem to setup the update shader
  18152. * @param effect defines the update shader
  18153. */
  18154. applyToShader(effect: Effect): void;
  18155. /**
  18156. * Returns a string to use to update the GPU particles update shader
  18157. * @returns a string containng the defines string
  18158. */
  18159. getEffectDefines(): string;
  18160. /**
  18161. * Returns the string "HemisphericParticleEmitter"
  18162. * @returns a string containing the class name
  18163. */
  18164. getClassName(): string;
  18165. /**
  18166. * Serializes the particle system to a JSON object.
  18167. * @returns the JSON object
  18168. */
  18169. serialize(): any;
  18170. /**
  18171. * Parse properties from a JSON object
  18172. * @param serializationObject defines the JSON object
  18173. */
  18174. parse(serializationObject: any): void;
  18175. }
  18176. }
  18177. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18178. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18179. import { Effect } from "babylonjs/Materials/effect";
  18180. import { Particle } from "babylonjs/Particles/particle";
  18181. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18182. /**
  18183. * Particle emitter emitting particles from a point.
  18184. * It emits the particles randomly between 2 given directions.
  18185. */
  18186. export class PointParticleEmitter implements IParticleEmitterType {
  18187. /**
  18188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18189. */
  18190. direction1: Vector3;
  18191. /**
  18192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18193. */
  18194. direction2: Vector3;
  18195. /**
  18196. * Creates a new instance PointParticleEmitter
  18197. */
  18198. constructor();
  18199. /**
  18200. * Called by the particle System when the direction is computed for the created particle.
  18201. * @param worldMatrix is the world matrix of the particle system
  18202. * @param directionToUpdate is the direction vector to update with the result
  18203. * @param particle is the particle we are computed the direction for
  18204. */
  18205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18206. /**
  18207. * Called by the particle System when the position is computed for the created particle.
  18208. * @param worldMatrix is the world matrix of the particle system
  18209. * @param positionToUpdate is the position vector to update with the result
  18210. * @param particle is the particle we are computed the position for
  18211. */
  18212. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18213. /**
  18214. * Clones the current emitter and returns a copy of it
  18215. * @returns the new emitter
  18216. */
  18217. clone(): PointParticleEmitter;
  18218. /**
  18219. * Called by the GPUParticleSystem to setup the update shader
  18220. * @param effect defines the update shader
  18221. */
  18222. applyToShader(effect: Effect): void;
  18223. /**
  18224. * Returns a string to use to update the GPU particles update shader
  18225. * @returns a string containng the defines string
  18226. */
  18227. getEffectDefines(): string;
  18228. /**
  18229. * Returns the string "PointParticleEmitter"
  18230. * @returns a string containing the class name
  18231. */
  18232. getClassName(): string;
  18233. /**
  18234. * Serializes the particle system to a JSON object.
  18235. * @returns the JSON object
  18236. */
  18237. serialize(): any;
  18238. /**
  18239. * Parse properties from a JSON object
  18240. * @param serializationObject defines the JSON object
  18241. */
  18242. parse(serializationObject: any): void;
  18243. }
  18244. }
  18245. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18246. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18247. import { Effect } from "babylonjs/Materials/effect";
  18248. import { Particle } from "babylonjs/Particles/particle";
  18249. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18250. /**
  18251. * Particle emitter emitting particles from the inside of a sphere.
  18252. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18253. */
  18254. export class SphereParticleEmitter implements IParticleEmitterType {
  18255. /**
  18256. * The radius of the emission sphere.
  18257. */
  18258. radius: number;
  18259. /**
  18260. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18261. */
  18262. radiusRange: number;
  18263. /**
  18264. * How much to randomize the particle direction [0-1].
  18265. */
  18266. directionRandomizer: number;
  18267. /**
  18268. * Creates a new instance SphereParticleEmitter
  18269. * @param radius the radius of the emission sphere (1 by default)
  18270. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18271. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18272. */
  18273. constructor(
  18274. /**
  18275. * The radius of the emission sphere.
  18276. */
  18277. radius?: number,
  18278. /**
  18279. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18280. */
  18281. radiusRange?: number,
  18282. /**
  18283. * How much to randomize the particle direction [0-1].
  18284. */
  18285. directionRandomizer?: number);
  18286. /**
  18287. * Called by the particle System when the direction is computed for the created particle.
  18288. * @param worldMatrix is the world matrix of the particle system
  18289. * @param directionToUpdate is the direction vector to update with the result
  18290. * @param particle is the particle we are computed the direction for
  18291. */
  18292. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18293. /**
  18294. * Called by the particle System when the position is computed for the created particle.
  18295. * @param worldMatrix is the world matrix of the particle system
  18296. * @param positionToUpdate is the position vector to update with the result
  18297. * @param particle is the particle we are computed the position for
  18298. */
  18299. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18300. /**
  18301. * Clones the current emitter and returns a copy of it
  18302. * @returns the new emitter
  18303. */
  18304. clone(): SphereParticleEmitter;
  18305. /**
  18306. * Called by the GPUParticleSystem to setup the update shader
  18307. * @param effect defines the update shader
  18308. */
  18309. applyToShader(effect: Effect): void;
  18310. /**
  18311. * Returns a string to use to update the GPU particles update shader
  18312. * @returns a string containng the defines string
  18313. */
  18314. getEffectDefines(): string;
  18315. /**
  18316. * Returns the string "SphereParticleEmitter"
  18317. * @returns a string containing the class name
  18318. */
  18319. getClassName(): string;
  18320. /**
  18321. * Serializes the particle system to a JSON object.
  18322. * @returns the JSON object
  18323. */
  18324. serialize(): any;
  18325. /**
  18326. * Parse properties from a JSON object
  18327. * @param serializationObject defines the JSON object
  18328. */
  18329. parse(serializationObject: any): void;
  18330. }
  18331. /**
  18332. * Particle emitter emitting particles from the inside of a sphere.
  18333. * It emits the particles randomly between two vectors.
  18334. */
  18335. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18336. /**
  18337. * The min limit of the emission direction.
  18338. */
  18339. direction1: Vector3;
  18340. /**
  18341. * The max limit of the emission direction.
  18342. */
  18343. direction2: Vector3;
  18344. /**
  18345. * Creates a new instance SphereDirectedParticleEmitter
  18346. * @param radius the radius of the emission sphere (1 by default)
  18347. * @param direction1 the min limit of the emission direction (up vector by default)
  18348. * @param direction2 the max limit of the emission direction (up vector by default)
  18349. */
  18350. constructor(radius?: number,
  18351. /**
  18352. * The min limit of the emission direction.
  18353. */
  18354. direction1?: Vector3,
  18355. /**
  18356. * The max limit of the emission direction.
  18357. */
  18358. direction2?: Vector3);
  18359. /**
  18360. * Called by the particle System when the direction is computed for the created particle.
  18361. * @param worldMatrix is the world matrix of the particle system
  18362. * @param directionToUpdate is the direction vector to update with the result
  18363. * @param particle is the particle we are computed the direction for
  18364. */
  18365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18366. /**
  18367. * Clones the current emitter and returns a copy of it
  18368. * @returns the new emitter
  18369. */
  18370. clone(): SphereDirectedParticleEmitter;
  18371. /**
  18372. * Called by the GPUParticleSystem to setup the update shader
  18373. * @param effect defines the update shader
  18374. */
  18375. applyToShader(effect: Effect): void;
  18376. /**
  18377. * Returns a string to use to update the GPU particles update shader
  18378. * @returns a string containng the defines string
  18379. */
  18380. getEffectDefines(): string;
  18381. /**
  18382. * Returns the string "SphereDirectedParticleEmitter"
  18383. * @returns a string containing the class name
  18384. */
  18385. getClassName(): string;
  18386. /**
  18387. * Serializes the particle system to a JSON object.
  18388. * @returns the JSON object
  18389. */
  18390. serialize(): any;
  18391. /**
  18392. * Parse properties from a JSON object
  18393. * @param serializationObject defines the JSON object
  18394. */
  18395. parse(serializationObject: any): void;
  18396. }
  18397. }
  18398. declare module "babylonjs/Particles/EmitterTypes/index" {
  18399. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18400. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18401. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18402. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18403. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18404. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18405. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18406. }
  18407. declare module "babylonjs/Particles/IParticleSystem" {
  18408. import { Nullable } from "babylonjs/types";
  18409. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18410. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18413. import { Texture } from "babylonjs/Materials/Textures/texture";
  18414. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18415. import { Scene } from "babylonjs/scene";
  18416. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18417. import { Animation } from "babylonjs/Animations/animation";
  18418. /**
  18419. * Interface representing a particle system in Babylon.js.
  18420. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18421. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18422. */
  18423. export interface IParticleSystem {
  18424. /**
  18425. * List of animations used by the particle system.
  18426. */
  18427. animations: Animation[];
  18428. /**
  18429. * The id of the Particle system.
  18430. */
  18431. id: string;
  18432. /**
  18433. * The name of the Particle system.
  18434. */
  18435. name: string;
  18436. /**
  18437. * The emitter represents the Mesh or position we are attaching the particle system to.
  18438. */
  18439. emitter: Nullable<AbstractMesh | Vector3>;
  18440. /**
  18441. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18442. */
  18443. isBillboardBased: boolean;
  18444. /**
  18445. * The rendering group used by the Particle system to chose when to render.
  18446. */
  18447. renderingGroupId: number;
  18448. /**
  18449. * The layer mask we are rendering the particles through.
  18450. */
  18451. layerMask: number;
  18452. /**
  18453. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18454. */
  18455. updateSpeed: number;
  18456. /**
  18457. * The amount of time the particle system is running (depends of the overall update speed).
  18458. */
  18459. targetStopDuration: number;
  18460. /**
  18461. * The texture used to render each particle. (this can be a spritesheet)
  18462. */
  18463. particleTexture: Nullable<Texture>;
  18464. /**
  18465. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18466. */
  18467. blendMode: number;
  18468. /**
  18469. * Minimum life time of emitting particles.
  18470. */
  18471. minLifeTime: number;
  18472. /**
  18473. * Maximum life time of emitting particles.
  18474. */
  18475. maxLifeTime: number;
  18476. /**
  18477. * Minimum Size of emitting particles.
  18478. */
  18479. minSize: number;
  18480. /**
  18481. * Maximum Size of emitting particles.
  18482. */
  18483. maxSize: number;
  18484. /**
  18485. * Minimum scale of emitting particles on X axis.
  18486. */
  18487. minScaleX: number;
  18488. /**
  18489. * Maximum scale of emitting particles on X axis.
  18490. */
  18491. maxScaleX: number;
  18492. /**
  18493. * Minimum scale of emitting particles on Y axis.
  18494. */
  18495. minScaleY: number;
  18496. /**
  18497. * Maximum scale of emitting particles on Y axis.
  18498. */
  18499. maxScaleY: number;
  18500. /**
  18501. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18502. */
  18503. color1: Color4;
  18504. /**
  18505. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18506. */
  18507. color2: Color4;
  18508. /**
  18509. * Color the particle will have at the end of its lifetime.
  18510. */
  18511. colorDead: Color4;
  18512. /**
  18513. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18514. */
  18515. emitRate: number;
  18516. /**
  18517. * You can use gravity if you want to give an orientation to your particles.
  18518. */
  18519. gravity: Vector3;
  18520. /**
  18521. * Minimum power of emitting particles.
  18522. */
  18523. minEmitPower: number;
  18524. /**
  18525. * Maximum power of emitting particles.
  18526. */
  18527. maxEmitPower: number;
  18528. /**
  18529. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18530. */
  18531. minAngularSpeed: number;
  18532. /**
  18533. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18534. */
  18535. maxAngularSpeed: number;
  18536. /**
  18537. * Gets or sets the minimal initial rotation in radians.
  18538. */
  18539. minInitialRotation: number;
  18540. /**
  18541. * Gets or sets the maximal initial rotation in radians.
  18542. */
  18543. maxInitialRotation: number;
  18544. /**
  18545. * The particle emitter type defines the emitter used by the particle system.
  18546. * It can be for example box, sphere, or cone...
  18547. */
  18548. particleEmitterType: Nullable<IParticleEmitterType>;
  18549. /**
  18550. * Defines the delay in milliseconds before starting the system (0 by default)
  18551. */
  18552. startDelay: number;
  18553. /**
  18554. * 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
  18555. */
  18556. preWarmCycles: number;
  18557. /**
  18558. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18559. */
  18560. preWarmStepOffset: number;
  18561. /**
  18562. * 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)
  18563. */
  18564. spriteCellChangeSpeed: number;
  18565. /**
  18566. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18567. */
  18568. startSpriteCellID: number;
  18569. /**
  18570. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18571. */
  18572. endSpriteCellID: number;
  18573. /**
  18574. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18575. */
  18576. spriteCellWidth: number;
  18577. /**
  18578. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18579. */
  18580. spriteCellHeight: number;
  18581. /**
  18582. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18583. */
  18584. spriteRandomStartCell: boolean;
  18585. /**
  18586. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18587. */
  18588. isAnimationSheetEnabled: boolean;
  18589. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18590. translationPivot: Vector2;
  18591. /**
  18592. * Gets or sets a texture used to add random noise to particle positions
  18593. */
  18594. noiseTexture: Nullable<BaseTexture>;
  18595. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18596. noiseStrength: Vector3;
  18597. /**
  18598. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18599. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18600. */
  18601. billboardMode: number;
  18602. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18603. limitVelocityDamping: number;
  18604. /**
  18605. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18606. */
  18607. beginAnimationOnStart: boolean;
  18608. /**
  18609. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18610. */
  18611. beginAnimationFrom: number;
  18612. /**
  18613. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18614. */
  18615. beginAnimationTo: number;
  18616. /**
  18617. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18618. */
  18619. beginAnimationLoop: boolean;
  18620. /**
  18621. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18622. */
  18623. disposeOnStop: boolean;
  18624. /**
  18625. * Gets the maximum number of particles active at the same time.
  18626. * @returns The max number of active particles.
  18627. */
  18628. getCapacity(): number;
  18629. /**
  18630. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18631. * @returns True if it has been started, otherwise false.
  18632. */
  18633. isStarted(): boolean;
  18634. /**
  18635. * Animates the particle system for this frame.
  18636. */
  18637. animate(): void;
  18638. /**
  18639. * Renders the particle system in its current state.
  18640. * @returns the current number of particles
  18641. */
  18642. render(): number;
  18643. /**
  18644. * Dispose the particle system and frees its associated resources.
  18645. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18646. */
  18647. dispose(disposeTexture?: boolean): void;
  18648. /**
  18649. * Clones the particle system.
  18650. * @param name The name of the cloned object
  18651. * @param newEmitter The new emitter to use
  18652. * @returns the cloned particle system
  18653. */
  18654. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18655. /**
  18656. * Serializes the particle system to a JSON object.
  18657. * @returns the JSON object
  18658. */
  18659. serialize(): any;
  18660. /**
  18661. * Rebuild the particle system
  18662. */
  18663. rebuild(): void;
  18664. /**
  18665. * Starts the particle system and begins to emit
  18666. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18667. */
  18668. start(delay?: number): void;
  18669. /**
  18670. * Stops the particle system.
  18671. */
  18672. stop(): void;
  18673. /**
  18674. * Remove all active particles
  18675. */
  18676. reset(): void;
  18677. /**
  18678. * Is this system ready to be used/rendered
  18679. * @return true if the system is ready
  18680. */
  18681. isReady(): boolean;
  18682. /**
  18683. * Adds a new color gradient
  18684. * @param gradient defines the gradient to use (between 0 and 1)
  18685. * @param color1 defines the color to affect to the specified gradient
  18686. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18687. * @returns the current particle system
  18688. */
  18689. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18690. /**
  18691. * Remove a specific color gradient
  18692. * @param gradient defines the gradient to remove
  18693. * @returns the current particle system
  18694. */
  18695. removeColorGradient(gradient: number): IParticleSystem;
  18696. /**
  18697. * Adds a new size gradient
  18698. * @param gradient defines the gradient to use (between 0 and 1)
  18699. * @param factor defines the size factor to affect to the specified gradient
  18700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18701. * @returns the current particle system
  18702. */
  18703. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18704. /**
  18705. * Remove a specific size gradient
  18706. * @param gradient defines the gradient to remove
  18707. * @returns the current particle system
  18708. */
  18709. removeSizeGradient(gradient: number): IParticleSystem;
  18710. /**
  18711. * Gets the current list of color gradients.
  18712. * You must use addColorGradient and removeColorGradient to udpate this list
  18713. * @returns the list of color gradients
  18714. */
  18715. getColorGradients(): Nullable<Array<ColorGradient>>;
  18716. /**
  18717. * Gets the current list of size gradients.
  18718. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18719. * @returns the list of size gradients
  18720. */
  18721. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18722. /**
  18723. * Gets the current list of angular speed gradients.
  18724. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18725. * @returns the list of angular speed gradients
  18726. */
  18727. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18728. /**
  18729. * Adds a new angular speed gradient
  18730. * @param gradient defines the gradient to use (between 0 and 1)
  18731. * @param factor defines the angular speed to affect to the specified gradient
  18732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18733. * @returns the current particle system
  18734. */
  18735. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18736. /**
  18737. * Remove a specific angular speed gradient
  18738. * @param gradient defines the gradient to remove
  18739. * @returns the current particle system
  18740. */
  18741. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18742. /**
  18743. * Gets the current list of velocity gradients.
  18744. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18745. * @returns the list of velocity gradients
  18746. */
  18747. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18748. /**
  18749. * Adds a new velocity gradient
  18750. * @param gradient defines the gradient to use (between 0 and 1)
  18751. * @param factor defines the velocity to affect to the specified gradient
  18752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18753. * @returns the current particle system
  18754. */
  18755. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18756. /**
  18757. * Remove a specific velocity gradient
  18758. * @param gradient defines the gradient to remove
  18759. * @returns the current particle system
  18760. */
  18761. removeVelocityGradient(gradient: number): IParticleSystem;
  18762. /**
  18763. * Gets the current list of limit velocity gradients.
  18764. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18765. * @returns the list of limit velocity gradients
  18766. */
  18767. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18768. /**
  18769. * Adds a new limit velocity gradient
  18770. * @param gradient defines the gradient to use (between 0 and 1)
  18771. * @param factor defines the limit velocity to affect to the specified gradient
  18772. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18773. * @returns the current particle system
  18774. */
  18775. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18776. /**
  18777. * Remove a specific limit velocity gradient
  18778. * @param gradient defines the gradient to remove
  18779. * @returns the current particle system
  18780. */
  18781. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18782. /**
  18783. * Adds a new drag gradient
  18784. * @param gradient defines the gradient to use (between 0 and 1)
  18785. * @param factor defines the drag to affect to the specified gradient
  18786. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18787. * @returns the current particle system
  18788. */
  18789. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18790. /**
  18791. * Remove a specific drag gradient
  18792. * @param gradient defines the gradient to remove
  18793. * @returns the current particle system
  18794. */
  18795. removeDragGradient(gradient: number): IParticleSystem;
  18796. /**
  18797. * Gets the current list of drag gradients.
  18798. * You must use addDragGradient and removeDragGradient to udpate this list
  18799. * @returns the list of drag gradients
  18800. */
  18801. getDragGradients(): Nullable<Array<FactorGradient>>;
  18802. /**
  18803. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18804. * @param gradient defines the gradient to use (between 0 and 1)
  18805. * @param factor defines the emit rate to affect to the specified gradient
  18806. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18807. * @returns the current particle system
  18808. */
  18809. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18810. /**
  18811. * Remove a specific emit rate gradient
  18812. * @param gradient defines the gradient to remove
  18813. * @returns the current particle system
  18814. */
  18815. removeEmitRateGradient(gradient: number): IParticleSystem;
  18816. /**
  18817. * Gets the current list of emit rate gradients.
  18818. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18819. * @returns the list of emit rate gradients
  18820. */
  18821. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18822. /**
  18823. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18824. * @param gradient defines the gradient to use (between 0 and 1)
  18825. * @param factor defines the start size to affect to the specified gradient
  18826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18827. * @returns the current particle system
  18828. */
  18829. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18830. /**
  18831. * Remove a specific start size gradient
  18832. * @param gradient defines the gradient to remove
  18833. * @returns the current particle system
  18834. */
  18835. removeStartSizeGradient(gradient: number): IParticleSystem;
  18836. /**
  18837. * Gets the current list of start size gradients.
  18838. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18839. * @returns the list of start size gradients
  18840. */
  18841. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18842. /**
  18843. * Adds a new life time gradient
  18844. * @param gradient defines the gradient to use (between 0 and 1)
  18845. * @param factor defines the life time factor to affect to the specified gradient
  18846. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18847. * @returns the current particle system
  18848. */
  18849. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18850. /**
  18851. * Remove a specific life time gradient
  18852. * @param gradient defines the gradient to remove
  18853. * @returns the current particle system
  18854. */
  18855. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18856. /**
  18857. * Gets the current list of life time gradients.
  18858. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18859. * @returns the list of life time gradients
  18860. */
  18861. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18862. /**
  18863. * Gets the current list of color gradients.
  18864. * You must use addColorGradient and removeColorGradient to udpate this list
  18865. * @returns the list of color gradients
  18866. */
  18867. getColorGradients(): Nullable<Array<ColorGradient>>;
  18868. /**
  18869. * Adds a new ramp gradient used to remap particle colors
  18870. * @param gradient defines the gradient to use (between 0 and 1)
  18871. * @param color defines the color to affect to the specified gradient
  18872. * @returns the current particle system
  18873. */
  18874. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18875. /**
  18876. * Gets the current list of ramp gradients.
  18877. * You must use addRampGradient and removeRampGradient to udpate this list
  18878. * @returns the list of ramp gradients
  18879. */
  18880. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18881. /** Gets or sets a boolean indicating that ramp gradients must be used
  18882. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18883. */
  18884. useRampGradients: boolean;
  18885. /**
  18886. * Adds a new color remap gradient
  18887. * @param gradient defines the gradient to use (between 0 and 1)
  18888. * @param min defines the color remap minimal range
  18889. * @param max defines the color remap maximal range
  18890. * @returns the current particle system
  18891. */
  18892. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18893. /**
  18894. * Gets the current list of color remap gradients.
  18895. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18896. * @returns the list of color remap gradients
  18897. */
  18898. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18899. /**
  18900. * Adds a new alpha remap gradient
  18901. * @param gradient defines the gradient to use (between 0 and 1)
  18902. * @param min defines the alpha remap minimal range
  18903. * @param max defines the alpha remap maximal range
  18904. * @returns the current particle system
  18905. */
  18906. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18907. /**
  18908. * Gets the current list of alpha remap gradients.
  18909. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18910. * @returns the list of alpha remap gradients
  18911. */
  18912. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18913. /**
  18914. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18915. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18916. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18917. * @returns the emitter
  18918. */
  18919. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18920. /**
  18921. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18922. * @param radius The radius of the hemisphere to emit from
  18923. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18924. * @returns the emitter
  18925. */
  18926. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18927. /**
  18928. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18929. * @param radius The radius of the sphere to emit from
  18930. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18931. * @returns the emitter
  18932. */
  18933. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18934. /**
  18935. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18936. * @param radius The radius of the sphere to emit from
  18937. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18938. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18939. * @returns the emitter
  18940. */
  18941. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18942. /**
  18943. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18944. * @param radius The radius of the emission cylinder
  18945. * @param height The height of the emission cylinder
  18946. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18947. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18948. * @returns the emitter
  18949. */
  18950. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18951. /**
  18952. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18953. * @param radius The radius of the cylinder to emit from
  18954. * @param height The height of the emission cylinder
  18955. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18956. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18957. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18958. * @returns the emitter
  18959. */
  18960. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18961. /**
  18962. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18963. * @param radius The radius of the cone to emit from
  18964. * @param angle The base angle of the cone
  18965. * @returns the emitter
  18966. */
  18967. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18968. /**
  18969. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18970. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18971. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18972. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18973. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18974. * @returns the emitter
  18975. */
  18976. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18977. /**
  18978. * Get hosting scene
  18979. * @returns the scene
  18980. */
  18981. getScene(): Scene;
  18982. }
  18983. }
  18984. declare module "babylonjs/Meshes/instancedMesh" {
  18985. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  18986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18987. import { Camera } from "babylonjs/Cameras/camera";
  18988. import { Node } from "babylonjs/node";
  18989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18990. import { Mesh } from "babylonjs/Meshes/mesh";
  18991. import { Material } from "babylonjs/Materials/material";
  18992. import { Skeleton } from "babylonjs/Bones/skeleton";
  18993. import { Light } from "babylonjs/Lights/light";
  18994. /**
  18995. * Creates an instance based on a source mesh.
  18996. */
  18997. export class InstancedMesh extends AbstractMesh {
  18998. private _sourceMesh;
  18999. private _currentLOD;
  19000. /** @hidden */
  19001. _indexInSourceMeshInstanceArray: number;
  19002. constructor(name: string, source: Mesh);
  19003. /**
  19004. * Returns the string "InstancedMesh".
  19005. */
  19006. getClassName(): string;
  19007. /** Gets the list of lights affecting that mesh */
  19008. readonly lightSources: Light[];
  19009. _resyncLightSources(): void;
  19010. _resyncLighSource(light: Light): void;
  19011. _removeLightSource(light: Light): void;
  19012. /**
  19013. * If the source mesh receives shadows
  19014. */
  19015. readonly receiveShadows: boolean;
  19016. /**
  19017. * The material of the source mesh
  19018. */
  19019. readonly material: Nullable<Material>;
  19020. /**
  19021. * Visibility of the source mesh
  19022. */
  19023. readonly visibility: number;
  19024. /**
  19025. * Skeleton of the source mesh
  19026. */
  19027. readonly skeleton: Nullable<Skeleton>;
  19028. /**
  19029. * Rendering ground id of the source mesh
  19030. */
  19031. renderingGroupId: number;
  19032. /**
  19033. * Returns the total number of vertices (integer).
  19034. */
  19035. getTotalVertices(): number;
  19036. /**
  19037. * Returns a positive integer : the total number of indices in this mesh geometry.
  19038. * @returns the numner of indices or zero if the mesh has no geometry.
  19039. */
  19040. getTotalIndices(): number;
  19041. /**
  19042. * The source mesh of the instance
  19043. */
  19044. readonly sourceMesh: Mesh;
  19045. /**
  19046. * Is this node ready to be used/rendered
  19047. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19048. * @return {boolean} is it ready
  19049. */
  19050. isReady(completeCheck?: boolean): boolean;
  19051. /**
  19052. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19053. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19054. * @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.
  19055. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19056. */
  19057. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19058. /**
  19059. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19060. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19061. * The `data` are either a numeric array either a Float32Array.
  19062. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19063. * 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).
  19064. * Note that a new underlying VertexBuffer object is created each call.
  19065. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19066. *
  19067. * Possible `kind` values :
  19068. * - VertexBuffer.PositionKind
  19069. * - VertexBuffer.UVKind
  19070. * - VertexBuffer.UV2Kind
  19071. * - VertexBuffer.UV3Kind
  19072. * - VertexBuffer.UV4Kind
  19073. * - VertexBuffer.UV5Kind
  19074. * - VertexBuffer.UV6Kind
  19075. * - VertexBuffer.ColorKind
  19076. * - VertexBuffer.MatricesIndicesKind
  19077. * - VertexBuffer.MatricesIndicesExtraKind
  19078. * - VertexBuffer.MatricesWeightsKind
  19079. * - VertexBuffer.MatricesWeightsExtraKind
  19080. *
  19081. * Returns the Mesh.
  19082. */
  19083. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19084. /**
  19085. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19086. * If the mesh has no geometry, it is simply returned as it is.
  19087. * The `data` are either a numeric array either a Float32Array.
  19088. * No new underlying VertexBuffer object is created.
  19089. * 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.
  19090. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19091. *
  19092. * Possible `kind` values :
  19093. * - VertexBuffer.PositionKind
  19094. * - VertexBuffer.UVKind
  19095. * - VertexBuffer.UV2Kind
  19096. * - VertexBuffer.UV3Kind
  19097. * - VertexBuffer.UV4Kind
  19098. * - VertexBuffer.UV5Kind
  19099. * - VertexBuffer.UV6Kind
  19100. * - VertexBuffer.ColorKind
  19101. * - VertexBuffer.MatricesIndicesKind
  19102. * - VertexBuffer.MatricesIndicesExtraKind
  19103. * - VertexBuffer.MatricesWeightsKind
  19104. * - VertexBuffer.MatricesWeightsExtraKind
  19105. *
  19106. * Returns the Mesh.
  19107. */
  19108. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19109. /**
  19110. * Sets the mesh indices.
  19111. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19112. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19113. * This method creates a new index buffer each call.
  19114. * Returns the Mesh.
  19115. */
  19116. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19117. /**
  19118. * Boolean : True if the mesh owns the requested kind of data.
  19119. */
  19120. isVerticesDataPresent(kind: string): boolean;
  19121. /**
  19122. * Returns an array of indices (IndicesArray).
  19123. */
  19124. getIndices(): Nullable<IndicesArray>;
  19125. readonly _positions: Nullable<Vector3[]>;
  19126. /**
  19127. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19128. * This means the mesh underlying bounding box and sphere are recomputed.
  19129. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19130. * @returns the current mesh
  19131. */
  19132. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19133. /** @hidden */
  19134. _preActivate(): InstancedMesh;
  19135. /** @hidden */
  19136. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19137. /** @hidden */
  19138. _postActivate(): void;
  19139. getWorldMatrix(): Matrix;
  19140. readonly isAnInstance: boolean;
  19141. /**
  19142. * Returns the current associated LOD AbstractMesh.
  19143. */
  19144. getLOD(camera: Camera): AbstractMesh;
  19145. /** @hidden */
  19146. _syncSubMeshes(): InstancedMesh;
  19147. /** @hidden */
  19148. _generatePointsArray(): boolean;
  19149. /**
  19150. * Creates a new InstancedMesh from the current mesh.
  19151. * - name (string) : the cloned mesh name
  19152. * - newParent (optional Node) : the optional Node to parent the clone to.
  19153. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19154. *
  19155. * Returns the clone.
  19156. */
  19157. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  19158. /**
  19159. * Disposes the InstancedMesh.
  19160. * Returns nothing.
  19161. */
  19162. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19163. }
  19164. }
  19165. declare module "babylonjs/Materials/shaderMaterial" {
  19166. import { Scene } from "babylonjs/scene";
  19167. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19169. import { Mesh } from "babylonjs/Meshes/mesh";
  19170. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19171. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19172. import { Texture } from "babylonjs/Materials/Textures/texture";
  19173. import { Material } from "babylonjs/Materials/material";
  19174. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19175. /**
  19176. * Defines the options associated with the creation of a shader material.
  19177. */
  19178. export interface IShaderMaterialOptions {
  19179. /**
  19180. * Does the material work in alpha blend mode
  19181. */
  19182. needAlphaBlending: boolean;
  19183. /**
  19184. * Does the material work in alpha test mode
  19185. */
  19186. needAlphaTesting: boolean;
  19187. /**
  19188. * The list of attribute names used in the shader
  19189. */
  19190. attributes: string[];
  19191. /**
  19192. * The list of unifrom names used in the shader
  19193. */
  19194. uniforms: string[];
  19195. /**
  19196. * The list of UBO names used in the shader
  19197. */
  19198. uniformBuffers: string[];
  19199. /**
  19200. * The list of sampler names used in the shader
  19201. */
  19202. samplers: string[];
  19203. /**
  19204. * The list of defines used in the shader
  19205. */
  19206. defines: string[];
  19207. }
  19208. /**
  19209. * 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.
  19210. *
  19211. * This returned material effects how the mesh will look based on the code in the shaders.
  19212. *
  19213. * @see http://doc.babylonjs.com/how_to/shader_material
  19214. */
  19215. export class ShaderMaterial extends Material {
  19216. private _shaderPath;
  19217. private _options;
  19218. private _textures;
  19219. private _textureArrays;
  19220. private _floats;
  19221. private _ints;
  19222. private _floatsArrays;
  19223. private _colors3;
  19224. private _colors3Arrays;
  19225. private _colors4;
  19226. private _colors4Arrays;
  19227. private _vectors2;
  19228. private _vectors3;
  19229. private _vectors4;
  19230. private _matrices;
  19231. private _matrices3x3;
  19232. private _matrices2x2;
  19233. private _vectors2Arrays;
  19234. private _vectors3Arrays;
  19235. private _vectors4Arrays;
  19236. private _cachedWorldViewMatrix;
  19237. private _cachedWorldViewProjectionMatrix;
  19238. private _renderId;
  19239. /**
  19240. * Instantiate a new shader material.
  19241. * 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.
  19242. * This returned material effects how the mesh will look based on the code in the shaders.
  19243. * @see http://doc.babylonjs.com/how_to/shader_material
  19244. * @param name Define the name of the material in the scene
  19245. * @param scene Define the scene the material belongs to
  19246. * @param shaderPath Defines the route to the shader code in one of three ways:
  19247. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19248. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  19249. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19250. * @param options Define the options used to create the shader
  19251. */
  19252. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19253. /**
  19254. * Gets the options used to compile the shader.
  19255. * They can be modified to trigger a new compilation
  19256. */
  19257. readonly options: IShaderMaterialOptions;
  19258. /**
  19259. * Gets the current class name of the material e.g. "ShaderMaterial"
  19260. * Mainly use in serialization.
  19261. * @returns the class name
  19262. */
  19263. getClassName(): string;
  19264. /**
  19265. * Specifies if the material will require alpha blending
  19266. * @returns a boolean specifying if alpha blending is needed
  19267. */
  19268. needAlphaBlending(): boolean;
  19269. /**
  19270. * Specifies if this material should be rendered in alpha test mode
  19271. * @returns a boolean specifying if an alpha test is needed.
  19272. */
  19273. needAlphaTesting(): boolean;
  19274. private _checkUniform;
  19275. /**
  19276. * Set a texture in the shader.
  19277. * @param name Define the name of the uniform samplers as defined in the shader
  19278. * @param texture Define the texture to bind to this sampler
  19279. * @return the material itself allowing "fluent" like uniform updates
  19280. */
  19281. setTexture(name: string, texture: Texture): ShaderMaterial;
  19282. /**
  19283. * Set a texture array in the shader.
  19284. * @param name Define the name of the uniform sampler array as defined in the shader
  19285. * @param textures Define the list of textures to bind to this sampler
  19286. * @return the material itself allowing "fluent" like uniform updates
  19287. */
  19288. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19289. /**
  19290. * Set a float in the shader.
  19291. * @param name Define the name of the uniform as defined in the shader
  19292. * @param value Define the value to give to the uniform
  19293. * @return the material itself allowing "fluent" like uniform updates
  19294. */
  19295. setFloat(name: string, value: number): ShaderMaterial;
  19296. /**
  19297. * Set a int in the shader.
  19298. * @param name Define the name of the uniform as defined in the shader
  19299. * @param value Define the value to give to the uniform
  19300. * @return the material itself allowing "fluent" like uniform updates
  19301. */
  19302. setInt(name: string, value: number): ShaderMaterial;
  19303. /**
  19304. * Set an array of floats in the shader.
  19305. * @param name Define the name of the uniform as defined in the shader
  19306. * @param value Define the value to give to the uniform
  19307. * @return the material itself allowing "fluent" like uniform updates
  19308. */
  19309. setFloats(name: string, value: number[]): ShaderMaterial;
  19310. /**
  19311. * Set a vec3 in the shader from a Color3.
  19312. * @param name Define the name of the uniform as defined in the shader
  19313. * @param value Define the value to give to the uniform
  19314. * @return the material itself allowing "fluent" like uniform updates
  19315. */
  19316. setColor3(name: string, value: Color3): ShaderMaterial;
  19317. /**
  19318. * Set a vec3 array in the shader from a Color3 array.
  19319. * @param name Define the name of the uniform as defined in the shader
  19320. * @param value Define the value to give to the uniform
  19321. * @return the material itself allowing "fluent" like uniform updates
  19322. */
  19323. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19324. /**
  19325. * Set a vec4 in the shader from a Color4.
  19326. * @param name Define the name of the uniform as defined in the shader
  19327. * @param value Define the value to give to the uniform
  19328. * @return the material itself allowing "fluent" like uniform updates
  19329. */
  19330. setColor4(name: string, value: Color4): ShaderMaterial;
  19331. /**
  19332. * Set a vec4 array in the shader from a Color4 array.
  19333. * @param name Define the name of the uniform as defined in the shader
  19334. * @param value Define the value to give to the uniform
  19335. * @return the material itself allowing "fluent" like uniform updates
  19336. */
  19337. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19338. /**
  19339. * Set a vec2 in the shader from a Vector2.
  19340. * @param name Define the name of the uniform as defined in the shader
  19341. * @param value Define the value to give to the uniform
  19342. * @return the material itself allowing "fluent" like uniform updates
  19343. */
  19344. setVector2(name: string, value: Vector2): ShaderMaterial;
  19345. /**
  19346. * Set a vec3 in the shader from a Vector3.
  19347. * @param name Define the name of the uniform as defined in the shader
  19348. * @param value Define the value to give to the uniform
  19349. * @return the material itself allowing "fluent" like uniform updates
  19350. */
  19351. setVector3(name: string, value: Vector3): ShaderMaterial;
  19352. /**
  19353. * Set a vec4 in the shader from a Vector4.
  19354. * @param name Define the name of the uniform as defined in the shader
  19355. * @param value Define the value to give to the uniform
  19356. * @return the material itself allowing "fluent" like uniform updates
  19357. */
  19358. setVector4(name: string, value: Vector4): ShaderMaterial;
  19359. /**
  19360. * Set a mat4 in the shader from a Matrix.
  19361. * @param name Define the name of the uniform as defined in the shader
  19362. * @param value Define the value to give to the uniform
  19363. * @return the material itself allowing "fluent" like uniform updates
  19364. */
  19365. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19366. /**
  19367. * Set a mat3 in the shader from a Float32Array.
  19368. * @param name Define the name of the uniform as defined in the shader
  19369. * @param value Define the value to give to the uniform
  19370. * @return the material itself allowing "fluent" like uniform updates
  19371. */
  19372. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19373. /**
  19374. * Set a mat2 in the shader from a Float32Array.
  19375. * @param name Define the name of the uniform as defined in the shader
  19376. * @param value Define the value to give to the uniform
  19377. * @return the material itself allowing "fluent" like uniform updates
  19378. */
  19379. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19380. /**
  19381. * Set a vec2 array in the shader from a number array.
  19382. * @param name Define the name of the uniform as defined in the shader
  19383. * @param value Define the value to give to the uniform
  19384. * @return the material itself allowing "fluent" like uniform updates
  19385. */
  19386. setArray2(name: string, value: number[]): ShaderMaterial;
  19387. /**
  19388. * Set a vec3 array in the shader from a number array.
  19389. * @param name Define the name of the uniform as defined in the shader
  19390. * @param value Define the value to give to the uniform
  19391. * @return the material itself allowing "fluent" like uniform updates
  19392. */
  19393. setArray3(name: string, value: number[]): ShaderMaterial;
  19394. /**
  19395. * Set a vec4 array in the shader from a number array.
  19396. * @param name Define the name of the uniform as defined in the shader
  19397. * @param value Define the value to give to the uniform
  19398. * @return the material itself allowing "fluent" like uniform updates
  19399. */
  19400. setArray4(name: string, value: number[]): ShaderMaterial;
  19401. private _checkCache;
  19402. /**
  19403. * Specifies that the submesh is ready to be used
  19404. * @param mesh defines the mesh to check
  19405. * @param subMesh defines which submesh to check
  19406. * @param useInstances specifies that instances should be used
  19407. * @returns a boolean indicating that the submesh is ready or not
  19408. */
  19409. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19410. /**
  19411. * Checks if the material is ready to render the requested mesh
  19412. * @param mesh Define the mesh to render
  19413. * @param useInstances Define whether or not the material is used with instances
  19414. * @returns true if ready, otherwise false
  19415. */
  19416. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19417. /**
  19418. * Binds the world matrix to the material
  19419. * @param world defines the world transformation matrix
  19420. */
  19421. bindOnlyWorldMatrix(world: Matrix): void;
  19422. /**
  19423. * Binds the material to the mesh
  19424. * @param world defines the world transformation matrix
  19425. * @param mesh defines the mesh to bind the material to
  19426. */
  19427. bind(world: Matrix, mesh?: Mesh): void;
  19428. /**
  19429. * Gets the active textures from the material
  19430. * @returns an array of textures
  19431. */
  19432. getActiveTextures(): BaseTexture[];
  19433. /**
  19434. * Specifies if the material uses a texture
  19435. * @param texture defines the texture to check against the material
  19436. * @returns a boolean specifying if the material uses the texture
  19437. */
  19438. hasTexture(texture: BaseTexture): boolean;
  19439. /**
  19440. * Makes a duplicate of the material, and gives it a new name
  19441. * @param name defines the new name for the duplicated material
  19442. * @returns the cloned material
  19443. */
  19444. clone(name: string): ShaderMaterial;
  19445. /**
  19446. * Disposes the material
  19447. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19448. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19449. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19450. */
  19451. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19452. /**
  19453. * Serializes this material in a JSON representation
  19454. * @returns the serialized material object
  19455. */
  19456. serialize(): any;
  19457. /**
  19458. * Creates a shader material from parsed shader material data
  19459. * @param source defines the JSON represnetation of the material
  19460. * @param scene defines the hosting scene
  19461. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19462. * @returns a new material
  19463. */
  19464. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19465. }
  19466. }
  19467. declare module "babylonjs/Shaders/color.fragment" {
  19468. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19469. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19470. /** @hidden */
  19471. export var colorPixelShader: {
  19472. name: string;
  19473. shader: string;
  19474. };
  19475. }
  19476. declare module "babylonjs/Shaders/color.vertex" {
  19477. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19478. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19479. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19480. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19481. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19482. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19483. /** @hidden */
  19484. export var colorVertexShader: {
  19485. name: string;
  19486. shader: string;
  19487. };
  19488. }
  19489. declare module "babylonjs/Meshes/linesMesh" {
  19490. import { Nullable } from "babylonjs/types";
  19491. import { Scene } from "babylonjs/scene";
  19492. import { Color3 } from "babylonjs/Maths/math.color";
  19493. import { Node } from "babylonjs/node";
  19494. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19495. import { Mesh } from "babylonjs/Meshes/mesh";
  19496. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19497. import { Effect } from "babylonjs/Materials/effect";
  19498. import { Material } from "babylonjs/Materials/material";
  19499. import "babylonjs/Shaders/color.fragment";
  19500. import "babylonjs/Shaders/color.vertex";
  19501. /**
  19502. * Line mesh
  19503. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19504. */
  19505. export class LinesMesh extends Mesh {
  19506. /**
  19507. * If vertex color should be applied to the mesh
  19508. */
  19509. readonly useVertexColor?: boolean | undefined;
  19510. /**
  19511. * If vertex alpha should be applied to the mesh
  19512. */
  19513. readonly useVertexAlpha?: boolean | undefined;
  19514. /**
  19515. * Color of the line (Default: White)
  19516. */
  19517. color: Color3;
  19518. /**
  19519. * Alpha of the line (Default: 1)
  19520. */
  19521. alpha: number;
  19522. /**
  19523. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19524. * This margin is expressed in world space coordinates, so its value may vary.
  19525. * Default value is 0.1
  19526. */
  19527. intersectionThreshold: number;
  19528. private _colorShader;
  19529. private color4;
  19530. /**
  19531. * Creates a new LinesMesh
  19532. * @param name defines the name
  19533. * @param scene defines the hosting scene
  19534. * @param parent defines the parent mesh if any
  19535. * @param source defines the optional source LinesMesh used to clone data from
  19536. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19537. * When false, achieved by calling a clone(), also passing False.
  19538. * This will make creation of children, recursive.
  19539. * @param useVertexColor defines if this LinesMesh supports vertex color
  19540. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19541. */
  19542. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  19543. /**
  19544. * If vertex color should be applied to the mesh
  19545. */
  19546. useVertexColor?: boolean | undefined,
  19547. /**
  19548. * If vertex alpha should be applied to the mesh
  19549. */
  19550. useVertexAlpha?: boolean | undefined);
  19551. private _addClipPlaneDefine;
  19552. private _removeClipPlaneDefine;
  19553. isReady(): boolean;
  19554. /**
  19555. * Returns the string "LineMesh"
  19556. */
  19557. getClassName(): string;
  19558. /**
  19559. * @hidden
  19560. */
  19561. /**
  19562. * @hidden
  19563. */
  19564. material: Material;
  19565. /**
  19566. * @hidden
  19567. */
  19568. readonly checkCollisions: boolean;
  19569. /** @hidden */
  19570. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  19571. /** @hidden */
  19572. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  19573. /**
  19574. * Disposes of the line mesh
  19575. * @param doNotRecurse If children should be disposed
  19576. */
  19577. dispose(doNotRecurse?: boolean): void;
  19578. /**
  19579. * Returns a new LineMesh object cloned from the current one.
  19580. */
  19581. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  19582. /**
  19583. * Creates a new InstancedLinesMesh object from the mesh model.
  19584. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19585. * @param name defines the name of the new instance
  19586. * @returns a new InstancedLinesMesh
  19587. */
  19588. createInstance(name: string): InstancedLinesMesh;
  19589. }
  19590. /**
  19591. * Creates an instance based on a source LinesMesh
  19592. */
  19593. export class InstancedLinesMesh extends InstancedMesh {
  19594. /**
  19595. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19596. * This margin is expressed in world space coordinates, so its value may vary.
  19597. * Initilized with the intersectionThreshold value of the source LinesMesh
  19598. */
  19599. intersectionThreshold: number;
  19600. constructor(name: string, source: LinesMesh);
  19601. /**
  19602. * Returns the string "InstancedLinesMesh".
  19603. */
  19604. getClassName(): string;
  19605. }
  19606. }
  19607. declare module "babylonjs/Shaders/line.fragment" {
  19608. /** @hidden */
  19609. export var linePixelShader: {
  19610. name: string;
  19611. shader: string;
  19612. };
  19613. }
  19614. declare module "babylonjs/Shaders/line.vertex" {
  19615. /** @hidden */
  19616. export var lineVertexShader: {
  19617. name: string;
  19618. shader: string;
  19619. };
  19620. }
  19621. declare module "babylonjs/Rendering/edgesRenderer" {
  19622. import { Nullable } from "babylonjs/types";
  19623. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19625. import { Vector3 } from "babylonjs/Maths/math.vector";
  19626. import { IDisposable } from "babylonjs/scene";
  19627. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19628. import "babylonjs/Shaders/line.fragment";
  19629. import "babylonjs/Shaders/line.vertex";
  19630. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19631. module "babylonjs/Meshes/abstractMesh" {
  19632. interface AbstractMesh {
  19633. /**
  19634. * Gets the edgesRenderer associated with the mesh
  19635. */
  19636. edgesRenderer: Nullable<EdgesRenderer>;
  19637. }
  19638. }
  19639. module "babylonjs/Meshes/linesMesh" {
  19640. interface LinesMesh {
  19641. /**
  19642. * Enables the edge rendering mode on the mesh.
  19643. * This mode makes the mesh edges visible
  19644. * @param epsilon defines the maximal distance between two angles to detect a face
  19645. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19646. * @returns the currentAbstractMesh
  19647. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19648. */
  19649. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19650. }
  19651. }
  19652. module "babylonjs/Meshes/linesMesh" {
  19653. interface InstancedLinesMesh {
  19654. /**
  19655. * Enables the edge rendering mode on the mesh.
  19656. * This mode makes the mesh edges visible
  19657. * @param epsilon defines the maximal distance between two angles to detect a face
  19658. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19659. * @returns the current InstancedLinesMesh
  19660. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19661. */
  19662. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19663. }
  19664. }
  19665. /**
  19666. * Defines the minimum contract an Edges renderer should follow.
  19667. */
  19668. export interface IEdgesRenderer extends IDisposable {
  19669. /**
  19670. * Gets or sets a boolean indicating if the edgesRenderer is active
  19671. */
  19672. isEnabled: boolean;
  19673. /**
  19674. * Renders the edges of the attached mesh,
  19675. */
  19676. render(): void;
  19677. /**
  19678. * Checks wether or not the edges renderer is ready to render.
  19679. * @return true if ready, otherwise false.
  19680. */
  19681. isReady(): boolean;
  19682. }
  19683. /**
  19684. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19685. */
  19686. export class EdgesRenderer implements IEdgesRenderer {
  19687. /**
  19688. * Define the size of the edges with an orthographic camera
  19689. */
  19690. edgesWidthScalerForOrthographic: number;
  19691. /**
  19692. * Define the size of the edges with a perspective camera
  19693. */
  19694. edgesWidthScalerForPerspective: number;
  19695. protected _source: AbstractMesh;
  19696. protected _linesPositions: number[];
  19697. protected _linesNormals: number[];
  19698. protected _linesIndices: number[];
  19699. protected _epsilon: number;
  19700. protected _indicesCount: number;
  19701. protected _lineShader: ShaderMaterial;
  19702. protected _ib: DataBuffer;
  19703. protected _buffers: {
  19704. [key: string]: Nullable<VertexBuffer>;
  19705. };
  19706. protected _checkVerticesInsteadOfIndices: boolean;
  19707. private _meshRebuildObserver;
  19708. private _meshDisposeObserver;
  19709. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19710. isEnabled: boolean;
  19711. /**
  19712. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19713. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19714. * @param source Mesh used to create edges
  19715. * @param epsilon sum of angles in adjacency to check for edge
  19716. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19717. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19718. */
  19719. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19720. protected _prepareRessources(): void;
  19721. /** @hidden */
  19722. _rebuild(): void;
  19723. /**
  19724. * Releases the required resources for the edges renderer
  19725. */
  19726. dispose(): void;
  19727. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19728. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19729. /**
  19730. * Checks if the pair of p0 and p1 is en edge
  19731. * @param faceIndex
  19732. * @param edge
  19733. * @param faceNormals
  19734. * @param p0
  19735. * @param p1
  19736. * @private
  19737. */
  19738. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19739. /**
  19740. * push line into the position, normal and index buffer
  19741. * @protected
  19742. */
  19743. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19744. /**
  19745. * Generates lines edges from adjacencjes
  19746. * @private
  19747. */
  19748. _generateEdgesLines(): void;
  19749. /**
  19750. * Checks wether or not the edges renderer is ready to render.
  19751. * @return true if ready, otherwise false.
  19752. */
  19753. isReady(): boolean;
  19754. /**
  19755. * Renders the edges of the attached mesh,
  19756. */
  19757. render(): void;
  19758. }
  19759. /**
  19760. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  19761. */
  19762. export class LineEdgesRenderer extends EdgesRenderer {
  19763. /**
  19764. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  19765. * @param source LineMesh used to generate edges
  19766. * @param epsilon not important (specified angle for edge detection)
  19767. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19768. */
  19769. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19770. /**
  19771. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19772. */
  19773. _generateEdgesLines(): void;
  19774. }
  19775. }
  19776. declare module "babylonjs/Rendering/renderingGroup" {
  19777. import { SmartArray } from "babylonjs/Misc/smartArray";
  19778. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19780. import { Nullable } from "babylonjs/types";
  19781. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19782. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  19783. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19784. import { Material } from "babylonjs/Materials/material";
  19785. import { Scene } from "babylonjs/scene";
  19786. /**
  19787. * This represents the object necessary to create a rendering group.
  19788. * This is exclusively used and created by the rendering manager.
  19789. * To modify the behavior, you use the available helpers in your scene or meshes.
  19790. * @hidden
  19791. */
  19792. export class RenderingGroup {
  19793. index: number;
  19794. private static _zeroVector;
  19795. private _scene;
  19796. private _opaqueSubMeshes;
  19797. private _transparentSubMeshes;
  19798. private _alphaTestSubMeshes;
  19799. private _depthOnlySubMeshes;
  19800. private _particleSystems;
  19801. private _spriteManagers;
  19802. private _opaqueSortCompareFn;
  19803. private _alphaTestSortCompareFn;
  19804. private _transparentSortCompareFn;
  19805. private _renderOpaque;
  19806. private _renderAlphaTest;
  19807. private _renderTransparent;
  19808. /** @hidden */
  19809. _edgesRenderers: SmartArray<IEdgesRenderer>;
  19810. onBeforeTransparentRendering: () => void;
  19811. /**
  19812. * Set the opaque sort comparison function.
  19813. * If null the sub meshes will be render in the order they were created
  19814. */
  19815. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19816. /**
  19817. * Set the alpha test sort comparison function.
  19818. * If null the sub meshes will be render in the order they were created
  19819. */
  19820. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19821. /**
  19822. * Set the transparent sort comparison function.
  19823. * If null the sub meshes will be render in the order they were created
  19824. */
  19825. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19826. /**
  19827. * Creates a new rendering group.
  19828. * @param index The rendering group index
  19829. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19830. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19831. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19832. */
  19833. 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>);
  19834. /**
  19835. * Render all the sub meshes contained in the group.
  19836. * @param customRenderFunction Used to override the default render behaviour of the group.
  19837. * @returns true if rendered some submeshes.
  19838. */
  19839. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19840. /**
  19841. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19842. * @param subMeshes The submeshes to render
  19843. */
  19844. private renderOpaqueSorted;
  19845. /**
  19846. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19847. * @param subMeshes The submeshes to render
  19848. */
  19849. private renderAlphaTestSorted;
  19850. /**
  19851. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19852. * @param subMeshes The submeshes to render
  19853. */
  19854. private renderTransparentSorted;
  19855. /**
  19856. * Renders the submeshes in a specified order.
  19857. * @param subMeshes The submeshes to sort before render
  19858. * @param sortCompareFn The comparison function use to sort
  19859. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19860. * @param transparent Specifies to activate blending if true
  19861. */
  19862. private static renderSorted;
  19863. /**
  19864. * Renders the submeshes in the order they were dispatched (no sort applied).
  19865. * @param subMeshes The submeshes to render
  19866. */
  19867. private static renderUnsorted;
  19868. /**
  19869. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19870. * are rendered back to front if in the same alpha index.
  19871. *
  19872. * @param a The first submesh
  19873. * @param b The second submesh
  19874. * @returns The result of the comparison
  19875. */
  19876. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19877. /**
  19878. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19879. * are rendered back to front.
  19880. *
  19881. * @param a The first submesh
  19882. * @param b The second submesh
  19883. * @returns The result of the comparison
  19884. */
  19885. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19886. /**
  19887. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19888. * are rendered front to back (prevent overdraw).
  19889. *
  19890. * @param a The first submesh
  19891. * @param b The second submesh
  19892. * @returns The result of the comparison
  19893. */
  19894. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19895. /**
  19896. * Resets the different lists of submeshes to prepare a new frame.
  19897. */
  19898. prepare(): void;
  19899. dispose(): void;
  19900. /**
  19901. * Inserts the submesh in its correct queue depending on its material.
  19902. * @param subMesh The submesh to dispatch
  19903. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19904. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19905. */
  19906. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19907. dispatchSprites(spriteManager: ISpriteManager): void;
  19908. dispatchParticles(particleSystem: IParticleSystem): void;
  19909. private _renderParticles;
  19910. private _renderSprites;
  19911. }
  19912. }
  19913. declare module "babylonjs/Rendering/renderingManager" {
  19914. import { Nullable } from "babylonjs/types";
  19915. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19917. import { SmartArray } from "babylonjs/Misc/smartArray";
  19918. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  19919. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  19920. import { Material } from "babylonjs/Materials/material";
  19921. import { Scene } from "babylonjs/scene";
  19922. import { Camera } from "babylonjs/Cameras/camera";
  19923. /**
  19924. * Interface describing the different options available in the rendering manager
  19925. * regarding Auto Clear between groups.
  19926. */
  19927. export interface IRenderingManagerAutoClearSetup {
  19928. /**
  19929. * Defines whether or not autoclear is enable.
  19930. */
  19931. autoClear: boolean;
  19932. /**
  19933. * Defines whether or not to autoclear the depth buffer.
  19934. */
  19935. depth: boolean;
  19936. /**
  19937. * Defines whether or not to autoclear the stencil buffer.
  19938. */
  19939. stencil: boolean;
  19940. }
  19941. /**
  19942. * This class is used by the onRenderingGroupObservable
  19943. */
  19944. export class RenderingGroupInfo {
  19945. /**
  19946. * The Scene that being rendered
  19947. */
  19948. scene: Scene;
  19949. /**
  19950. * The camera currently used for the rendering pass
  19951. */
  19952. camera: Nullable<Camera>;
  19953. /**
  19954. * The ID of the renderingGroup being processed
  19955. */
  19956. renderingGroupId: number;
  19957. }
  19958. /**
  19959. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19960. * It is enable to manage the different groups as well as the different necessary sort functions.
  19961. * This should not be used directly aside of the few static configurations
  19962. */
  19963. export class RenderingManager {
  19964. /**
  19965. * The max id used for rendering groups (not included)
  19966. */
  19967. static MAX_RENDERINGGROUPS: number;
  19968. /**
  19969. * The min id used for rendering groups (included)
  19970. */
  19971. static MIN_RENDERINGGROUPS: number;
  19972. /**
  19973. * Used to globally prevent autoclearing scenes.
  19974. */
  19975. static AUTOCLEAR: boolean;
  19976. /**
  19977. * @hidden
  19978. */
  19979. _useSceneAutoClearSetup: boolean;
  19980. private _scene;
  19981. private _renderingGroups;
  19982. private _depthStencilBufferAlreadyCleaned;
  19983. private _autoClearDepthStencil;
  19984. private _customOpaqueSortCompareFn;
  19985. private _customAlphaTestSortCompareFn;
  19986. private _customTransparentSortCompareFn;
  19987. private _renderingGroupInfo;
  19988. /**
  19989. * Instantiates a new rendering group for a particular scene
  19990. * @param scene Defines the scene the groups belongs to
  19991. */
  19992. constructor(scene: Scene);
  19993. private _clearDepthStencilBuffer;
  19994. /**
  19995. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19996. * @hidden
  19997. */
  19998. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19999. /**
  20000. * Resets the different information of the group to prepare a new frame
  20001. * @hidden
  20002. */
  20003. reset(): void;
  20004. /**
  20005. * Dispose and release the group and its associated resources.
  20006. * @hidden
  20007. */
  20008. dispose(): void;
  20009. /**
  20010. * Clear the info related to rendering groups preventing retention points during dispose.
  20011. */
  20012. freeRenderingGroups(): void;
  20013. private _prepareRenderingGroup;
  20014. /**
  20015. * Add a sprite manager to the rendering manager in order to render it this frame.
  20016. * @param spriteManager Define the sprite manager to render
  20017. */
  20018. dispatchSprites(spriteManager: ISpriteManager): void;
  20019. /**
  20020. * Add a particle system to the rendering manager in order to render it this frame.
  20021. * @param particleSystem Define the particle system to render
  20022. */
  20023. dispatchParticles(particleSystem: IParticleSystem): void;
  20024. /**
  20025. * Add a submesh to the manager in order to render it this frame
  20026. * @param subMesh The submesh to dispatch
  20027. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20028. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20029. */
  20030. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20031. /**
  20032. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20033. * This allowed control for front to back rendering or reversly depending of the special needs.
  20034. *
  20035. * @param renderingGroupId The rendering group id corresponding to its index
  20036. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20037. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20038. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20039. */
  20040. 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;
  20041. /**
  20042. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20043. *
  20044. * @param renderingGroupId The rendering group id corresponding to its index
  20045. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20046. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20047. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20048. */
  20049. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20050. /**
  20051. * Gets the current auto clear configuration for one rendering group of the rendering
  20052. * manager.
  20053. * @param index the rendering group index to get the information for
  20054. * @returns The auto clear setup for the requested rendering group
  20055. */
  20056. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20057. }
  20058. }
  20059. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20060. import { Observable } from "babylonjs/Misc/observable";
  20061. import { SmartArray } from "babylonjs/Misc/smartArray";
  20062. import { Nullable } from "babylonjs/types";
  20063. import { Camera } from "babylonjs/Cameras/camera";
  20064. import { Scene } from "babylonjs/scene";
  20065. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20066. import { Color4 } from "babylonjs/Maths/math.color";
  20067. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20069. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20070. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20071. import { Texture } from "babylonjs/Materials/Textures/texture";
  20072. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20073. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20074. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20075. import { Engine } from "babylonjs/Engines/engine";
  20076. /**
  20077. * This Helps creating a texture that will be created from a camera in your scene.
  20078. * It is basically a dynamic texture that could be used to create special effects for instance.
  20079. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20080. */
  20081. export class RenderTargetTexture extends Texture {
  20082. isCube: boolean;
  20083. /**
  20084. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20085. */
  20086. static readonly REFRESHRATE_RENDER_ONCE: number;
  20087. /**
  20088. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20089. */
  20090. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20091. /**
  20092. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20093. * the central point of your effect and can save a lot of performances.
  20094. */
  20095. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20096. /**
  20097. * Use this predicate to dynamically define the list of mesh you want to render.
  20098. * If set, the renderList property will be overwritten.
  20099. */
  20100. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20101. private _renderList;
  20102. /**
  20103. * Use this list to define the list of mesh you want to render.
  20104. */
  20105. renderList: Nullable<Array<AbstractMesh>>;
  20106. private _hookArray;
  20107. /**
  20108. * Define if particles should be rendered in your texture.
  20109. */
  20110. renderParticles: boolean;
  20111. /**
  20112. * Define if sprites should be rendered in your texture.
  20113. */
  20114. renderSprites: boolean;
  20115. /**
  20116. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20117. */
  20118. coordinatesMode: number;
  20119. /**
  20120. * Define the camera used to render the texture.
  20121. */
  20122. activeCamera: Nullable<Camera>;
  20123. /**
  20124. * Override the render function of the texture with your own one.
  20125. */
  20126. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20127. /**
  20128. * Define if camera post processes should be use while rendering the texture.
  20129. */
  20130. useCameraPostProcesses: boolean;
  20131. /**
  20132. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20133. */
  20134. ignoreCameraViewport: boolean;
  20135. private _postProcessManager;
  20136. private _postProcesses;
  20137. private _resizeObserver;
  20138. /**
  20139. * An event triggered when the texture is unbind.
  20140. */
  20141. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20142. /**
  20143. * An event triggered when the texture is unbind.
  20144. */
  20145. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20146. private _onAfterUnbindObserver;
  20147. /**
  20148. * Set a after unbind callback in the texture.
  20149. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20150. */
  20151. onAfterUnbind: () => void;
  20152. /**
  20153. * An event triggered before rendering the texture
  20154. */
  20155. onBeforeRenderObservable: Observable<number>;
  20156. private _onBeforeRenderObserver;
  20157. /**
  20158. * Set a before render callback in the texture.
  20159. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20160. */
  20161. onBeforeRender: (faceIndex: number) => void;
  20162. /**
  20163. * An event triggered after rendering the texture
  20164. */
  20165. onAfterRenderObservable: Observable<number>;
  20166. private _onAfterRenderObserver;
  20167. /**
  20168. * Set a after render callback in the texture.
  20169. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20170. */
  20171. onAfterRender: (faceIndex: number) => void;
  20172. /**
  20173. * An event triggered after the texture clear
  20174. */
  20175. onClearObservable: Observable<Engine>;
  20176. private _onClearObserver;
  20177. /**
  20178. * Set a clear callback in the texture.
  20179. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20180. */
  20181. onClear: (Engine: Engine) => void;
  20182. /**
  20183. * Define the clear color of the Render Target if it should be different from the scene.
  20184. */
  20185. clearColor: Color4;
  20186. protected _size: number | {
  20187. width: number;
  20188. height: number;
  20189. };
  20190. protected _initialSizeParameter: number | {
  20191. width: number;
  20192. height: number;
  20193. } | {
  20194. ratio: number;
  20195. };
  20196. protected _sizeRatio: Nullable<number>;
  20197. /** @hidden */
  20198. _generateMipMaps: boolean;
  20199. protected _renderingManager: RenderingManager;
  20200. /** @hidden */
  20201. _waitingRenderList: string[];
  20202. protected _doNotChangeAspectRatio: boolean;
  20203. protected _currentRefreshId: number;
  20204. protected _refreshRate: number;
  20205. protected _textureMatrix: Matrix;
  20206. protected _samples: number;
  20207. protected _renderTargetOptions: RenderTargetCreationOptions;
  20208. /**
  20209. * Gets render target creation options that were used.
  20210. */
  20211. readonly renderTargetOptions: RenderTargetCreationOptions;
  20212. protected _engine: Engine;
  20213. protected _onRatioRescale(): void;
  20214. /**
  20215. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20216. * It must define where the camera used to render the texture is set
  20217. */
  20218. boundingBoxPosition: Vector3;
  20219. private _boundingBoxSize;
  20220. /**
  20221. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20222. * When defined, the cubemap will switch to local mode
  20223. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20224. * @example https://www.babylonjs-playground.com/#RNASML
  20225. */
  20226. boundingBoxSize: Vector3;
  20227. /**
  20228. * In case the RTT has been created with a depth texture, get the associated
  20229. * depth texture.
  20230. * Otherwise, return null.
  20231. */
  20232. depthStencilTexture: Nullable<InternalTexture>;
  20233. /**
  20234. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20235. * or used a shadow, depth texture...
  20236. * @param name The friendly name of the texture
  20237. * @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)
  20238. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20239. * @param generateMipMaps True if mip maps need to be generated after render.
  20240. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20241. * @param type The type of the buffer in the RTT (int, half float, float...)
  20242. * @param isCube True if a cube texture needs to be created
  20243. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20244. * @param generateDepthBuffer True to generate a depth buffer
  20245. * @param generateStencilBuffer True to generate a stencil buffer
  20246. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20247. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20248. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20249. */
  20250. constructor(name: string, size: number | {
  20251. width: number;
  20252. height: number;
  20253. } | {
  20254. ratio: number;
  20255. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20256. /**
  20257. * Creates a depth stencil texture.
  20258. * This is only available in WebGL 2 or with the depth texture extension available.
  20259. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20260. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20261. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20262. */
  20263. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20264. private _processSizeParameter;
  20265. /**
  20266. * Define the number of samples to use in case of MSAA.
  20267. * It defaults to one meaning no MSAA has been enabled.
  20268. */
  20269. samples: number;
  20270. /**
  20271. * Resets the refresh counter of the texture and start bak from scratch.
  20272. * Could be useful to regenerate the texture if it is setup to render only once.
  20273. */
  20274. resetRefreshCounter(): void;
  20275. /**
  20276. * Define the refresh rate of the texture or the rendering frequency.
  20277. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20278. */
  20279. refreshRate: number;
  20280. /**
  20281. * Adds a post process to the render target rendering passes.
  20282. * @param postProcess define the post process to add
  20283. */
  20284. addPostProcess(postProcess: PostProcess): void;
  20285. /**
  20286. * Clear all the post processes attached to the render target
  20287. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20288. */
  20289. clearPostProcesses(dispose?: boolean): void;
  20290. /**
  20291. * Remove one of the post process from the list of attached post processes to the texture
  20292. * @param postProcess define the post process to remove from the list
  20293. */
  20294. removePostProcess(postProcess: PostProcess): void;
  20295. /** @hidden */
  20296. _shouldRender(): boolean;
  20297. /**
  20298. * Gets the actual render size of the texture.
  20299. * @returns the width of the render size
  20300. */
  20301. getRenderSize(): number;
  20302. /**
  20303. * Gets the actual render width of the texture.
  20304. * @returns the width of the render size
  20305. */
  20306. getRenderWidth(): number;
  20307. /**
  20308. * Gets the actual render height of the texture.
  20309. * @returns the height of the render size
  20310. */
  20311. getRenderHeight(): number;
  20312. /**
  20313. * Get if the texture can be rescaled or not.
  20314. */
  20315. readonly canRescale: boolean;
  20316. /**
  20317. * Resize the texture using a ratio.
  20318. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20319. */
  20320. scale(ratio: number): void;
  20321. /**
  20322. * Get the texture reflection matrix used to rotate/transform the reflection.
  20323. * @returns the reflection matrix
  20324. */
  20325. getReflectionTextureMatrix(): Matrix;
  20326. /**
  20327. * Resize the texture to a new desired size.
  20328. * Be carrefull as it will recreate all the data in the new texture.
  20329. * @param size Define the new size. It can be:
  20330. * - a number for squared texture,
  20331. * - an object containing { width: number, height: number }
  20332. * - or an object containing a ratio { ratio: number }
  20333. */
  20334. resize(size: number | {
  20335. width: number;
  20336. height: number;
  20337. } | {
  20338. ratio: number;
  20339. }): void;
  20340. /**
  20341. * Renders all the objects from the render list into the texture.
  20342. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20343. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20344. */
  20345. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20346. private _bestReflectionRenderTargetDimension;
  20347. /**
  20348. * @hidden
  20349. * @param faceIndex face index to bind to if this is a cubetexture
  20350. */
  20351. _bindFrameBuffer(faceIndex?: number): void;
  20352. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20353. private renderToTarget;
  20354. /**
  20355. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20356. * This allowed control for front to back rendering or reversly depending of the special needs.
  20357. *
  20358. * @param renderingGroupId The rendering group id corresponding to its index
  20359. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20360. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20361. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20362. */
  20363. 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;
  20364. /**
  20365. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20366. *
  20367. * @param renderingGroupId The rendering group id corresponding to its index
  20368. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20369. */
  20370. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20371. /**
  20372. * Clones the texture.
  20373. * @returns the cloned texture
  20374. */
  20375. clone(): RenderTargetTexture;
  20376. /**
  20377. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20378. * @returns The JSON representation of the texture
  20379. */
  20380. serialize(): any;
  20381. /**
  20382. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20383. */
  20384. disposeFramebufferObjects(): void;
  20385. /**
  20386. * Dispose the texture and release its associated resources.
  20387. */
  20388. dispose(): void;
  20389. /** @hidden */
  20390. _rebuild(): void;
  20391. /**
  20392. * Clear the info related to rendering groups preventing retention point in material dispose.
  20393. */
  20394. freeRenderingGroups(): void;
  20395. /**
  20396. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20397. * @returns the view count
  20398. */
  20399. getViewCount(): number;
  20400. }
  20401. }
  20402. declare module "babylonjs/Materials/material" {
  20403. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20404. import { SmartArray } from "babylonjs/Misc/smartArray";
  20405. import { Observable } from "babylonjs/Misc/observable";
  20406. import { Nullable } from "babylonjs/types";
  20407. import { Scene } from "babylonjs/scene";
  20408. import { Matrix } from "babylonjs/Maths/math.vector";
  20409. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20411. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20412. import { Effect } from "babylonjs/Materials/effect";
  20413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20415. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20416. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20417. import { Mesh } from "babylonjs/Meshes/mesh";
  20418. import { Animation } from "babylonjs/Animations/animation";
  20419. /**
  20420. * Base class for the main features of a material in Babylon.js
  20421. */
  20422. export class Material implements IAnimatable {
  20423. /**
  20424. * Returns the triangle fill mode
  20425. */
  20426. static readonly TriangleFillMode: number;
  20427. /**
  20428. * Returns the wireframe mode
  20429. */
  20430. static readonly WireFrameFillMode: number;
  20431. /**
  20432. * Returns the point fill mode
  20433. */
  20434. static readonly PointFillMode: number;
  20435. /**
  20436. * Returns the point list draw mode
  20437. */
  20438. static readonly PointListDrawMode: number;
  20439. /**
  20440. * Returns the line list draw mode
  20441. */
  20442. static readonly LineListDrawMode: number;
  20443. /**
  20444. * Returns the line loop draw mode
  20445. */
  20446. static readonly LineLoopDrawMode: number;
  20447. /**
  20448. * Returns the line strip draw mode
  20449. */
  20450. static readonly LineStripDrawMode: number;
  20451. /**
  20452. * Returns the triangle strip draw mode
  20453. */
  20454. static readonly TriangleStripDrawMode: number;
  20455. /**
  20456. * Returns the triangle fan draw mode
  20457. */
  20458. static readonly TriangleFanDrawMode: number;
  20459. /**
  20460. * Stores the clock-wise side orientation
  20461. */
  20462. static readonly ClockWiseSideOrientation: number;
  20463. /**
  20464. * Stores the counter clock-wise side orientation
  20465. */
  20466. static readonly CounterClockWiseSideOrientation: number;
  20467. /**
  20468. * The dirty texture flag value
  20469. */
  20470. static readonly TextureDirtyFlag: number;
  20471. /**
  20472. * The dirty light flag value
  20473. */
  20474. static readonly LightDirtyFlag: number;
  20475. /**
  20476. * The dirty fresnel flag value
  20477. */
  20478. static readonly FresnelDirtyFlag: number;
  20479. /**
  20480. * The dirty attribute flag value
  20481. */
  20482. static readonly AttributesDirtyFlag: number;
  20483. /**
  20484. * The dirty misc flag value
  20485. */
  20486. static readonly MiscDirtyFlag: number;
  20487. /**
  20488. * The all dirty flag value
  20489. */
  20490. static readonly AllDirtyFlag: number;
  20491. /**
  20492. * The ID of the material
  20493. */
  20494. id: string;
  20495. /**
  20496. * Gets or sets the unique id of the material
  20497. */
  20498. uniqueId: number;
  20499. /**
  20500. * The name of the material
  20501. */
  20502. name: string;
  20503. /**
  20504. * Gets or sets user defined metadata
  20505. */
  20506. metadata: any;
  20507. /**
  20508. * For internal use only. Please do not use.
  20509. */
  20510. reservedDataStore: any;
  20511. /**
  20512. * Specifies if the ready state should be checked on each call
  20513. */
  20514. checkReadyOnEveryCall: boolean;
  20515. /**
  20516. * Specifies if the ready state should be checked once
  20517. */
  20518. checkReadyOnlyOnce: boolean;
  20519. /**
  20520. * The state of the material
  20521. */
  20522. state: string;
  20523. /**
  20524. * The alpha value of the material
  20525. */
  20526. protected _alpha: number;
  20527. /**
  20528. * List of inspectable custom properties (used by the Inspector)
  20529. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20530. */
  20531. inspectableCustomProperties: IInspectable[];
  20532. /**
  20533. * Sets the alpha value of the material
  20534. */
  20535. /**
  20536. * Gets the alpha value of the material
  20537. */
  20538. alpha: number;
  20539. /**
  20540. * Specifies if back face culling is enabled
  20541. */
  20542. protected _backFaceCulling: boolean;
  20543. /**
  20544. * Sets the back-face culling state
  20545. */
  20546. /**
  20547. * Gets the back-face culling state
  20548. */
  20549. backFaceCulling: boolean;
  20550. /**
  20551. * Stores the value for side orientation
  20552. */
  20553. sideOrientation: number;
  20554. /**
  20555. * Callback triggered when the material is compiled
  20556. */
  20557. onCompiled: Nullable<(effect: Effect) => void>;
  20558. /**
  20559. * Callback triggered when an error occurs
  20560. */
  20561. onError: Nullable<(effect: Effect, errors: string) => void>;
  20562. /**
  20563. * Callback triggered to get the render target textures
  20564. */
  20565. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20566. /**
  20567. * Gets a boolean indicating that current material needs to register RTT
  20568. */
  20569. readonly hasRenderTargetTextures: boolean;
  20570. /**
  20571. * Specifies if the material should be serialized
  20572. */
  20573. doNotSerialize: boolean;
  20574. /**
  20575. * @hidden
  20576. */
  20577. _storeEffectOnSubMeshes: boolean;
  20578. /**
  20579. * Stores the animations for the material
  20580. */
  20581. animations: Nullable<Array<Animation>>;
  20582. /**
  20583. * An event triggered when the material is disposed
  20584. */
  20585. onDisposeObservable: Observable<Material>;
  20586. /**
  20587. * An observer which watches for dispose events
  20588. */
  20589. private _onDisposeObserver;
  20590. private _onUnBindObservable;
  20591. /**
  20592. * Called during a dispose event
  20593. */
  20594. onDispose: () => void;
  20595. private _onBindObservable;
  20596. /**
  20597. * An event triggered when the material is bound
  20598. */
  20599. readonly onBindObservable: Observable<AbstractMesh>;
  20600. /**
  20601. * An observer which watches for bind events
  20602. */
  20603. private _onBindObserver;
  20604. /**
  20605. * Called during a bind event
  20606. */
  20607. onBind: (Mesh: AbstractMesh) => void;
  20608. /**
  20609. * An event triggered when the material is unbound
  20610. */
  20611. readonly onUnBindObservable: Observable<Material>;
  20612. /**
  20613. * Stores the value of the alpha mode
  20614. */
  20615. private _alphaMode;
  20616. /**
  20617. * Sets the value of the alpha mode.
  20618. *
  20619. * | Value | Type | Description |
  20620. * | --- | --- | --- |
  20621. * | 0 | ALPHA_DISABLE | |
  20622. * | 1 | ALPHA_ADD | |
  20623. * | 2 | ALPHA_COMBINE | |
  20624. * | 3 | ALPHA_SUBTRACT | |
  20625. * | 4 | ALPHA_MULTIPLY | |
  20626. * | 5 | ALPHA_MAXIMIZED | |
  20627. * | 6 | ALPHA_ONEONE | |
  20628. * | 7 | ALPHA_PREMULTIPLIED | |
  20629. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20630. * | 9 | ALPHA_INTERPOLATE | |
  20631. * | 10 | ALPHA_SCREENMODE | |
  20632. *
  20633. */
  20634. /**
  20635. * Gets the value of the alpha mode
  20636. */
  20637. alphaMode: number;
  20638. /**
  20639. * Stores the state of the need depth pre-pass value
  20640. */
  20641. private _needDepthPrePass;
  20642. /**
  20643. * Sets the need depth pre-pass value
  20644. */
  20645. /**
  20646. * Gets the depth pre-pass value
  20647. */
  20648. needDepthPrePass: boolean;
  20649. /**
  20650. * Specifies if depth writing should be disabled
  20651. */
  20652. disableDepthWrite: boolean;
  20653. /**
  20654. * Specifies if depth writing should be forced
  20655. */
  20656. forceDepthWrite: boolean;
  20657. /**
  20658. * Specifies if there should be a separate pass for culling
  20659. */
  20660. separateCullingPass: boolean;
  20661. /**
  20662. * Stores the state specifing if fog should be enabled
  20663. */
  20664. private _fogEnabled;
  20665. /**
  20666. * Sets the state for enabling fog
  20667. */
  20668. /**
  20669. * Gets the value of the fog enabled state
  20670. */
  20671. fogEnabled: boolean;
  20672. /**
  20673. * Stores the size of points
  20674. */
  20675. pointSize: number;
  20676. /**
  20677. * Stores the z offset value
  20678. */
  20679. zOffset: number;
  20680. /**
  20681. * Gets a value specifying if wireframe mode is enabled
  20682. */
  20683. /**
  20684. * Sets the state of wireframe mode
  20685. */
  20686. wireframe: boolean;
  20687. /**
  20688. * Gets the value specifying if point clouds are enabled
  20689. */
  20690. /**
  20691. * Sets the state of point cloud mode
  20692. */
  20693. pointsCloud: boolean;
  20694. /**
  20695. * Gets the material fill mode
  20696. */
  20697. /**
  20698. * Sets the material fill mode
  20699. */
  20700. fillMode: number;
  20701. /**
  20702. * @hidden
  20703. * Stores the effects for the material
  20704. */
  20705. _effect: Nullable<Effect>;
  20706. /**
  20707. * @hidden
  20708. * Specifies if the material was previously ready
  20709. */
  20710. _wasPreviouslyReady: boolean;
  20711. /**
  20712. * Specifies if uniform buffers should be used
  20713. */
  20714. private _useUBO;
  20715. /**
  20716. * Stores a reference to the scene
  20717. */
  20718. private _scene;
  20719. /**
  20720. * Stores the fill mode state
  20721. */
  20722. private _fillMode;
  20723. /**
  20724. * Specifies if the depth write state should be cached
  20725. */
  20726. private _cachedDepthWriteState;
  20727. /**
  20728. * Stores the uniform buffer
  20729. */
  20730. protected _uniformBuffer: UniformBuffer;
  20731. /** @hidden */
  20732. _indexInSceneMaterialArray: number;
  20733. /** @hidden */
  20734. meshMap: Nullable<{
  20735. [id: string]: AbstractMesh | undefined;
  20736. }>;
  20737. /**
  20738. * Creates a material instance
  20739. * @param name defines the name of the material
  20740. * @param scene defines the scene to reference
  20741. * @param doNotAdd specifies if the material should be added to the scene
  20742. */
  20743. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20744. /**
  20745. * Returns a string representation of the current material
  20746. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20747. * @returns a string with material information
  20748. */
  20749. toString(fullDetails?: boolean): string;
  20750. /**
  20751. * Gets the class name of the material
  20752. * @returns a string with the class name of the material
  20753. */
  20754. getClassName(): string;
  20755. /**
  20756. * Specifies if updates for the material been locked
  20757. */
  20758. readonly isFrozen: boolean;
  20759. /**
  20760. * Locks updates for the material
  20761. */
  20762. freeze(): void;
  20763. /**
  20764. * Unlocks updates for the material
  20765. */
  20766. unfreeze(): void;
  20767. /**
  20768. * Specifies if the material is ready to be used
  20769. * @param mesh defines the mesh to check
  20770. * @param useInstances specifies if instances should be used
  20771. * @returns a boolean indicating if the material is ready to be used
  20772. */
  20773. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20774. /**
  20775. * Specifies that the submesh is ready to be used
  20776. * @param mesh defines the mesh to check
  20777. * @param subMesh defines which submesh to check
  20778. * @param useInstances specifies that instances should be used
  20779. * @returns a boolean indicating that the submesh is ready or not
  20780. */
  20781. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20782. /**
  20783. * Returns the material effect
  20784. * @returns the effect associated with the material
  20785. */
  20786. getEffect(): Nullable<Effect>;
  20787. /**
  20788. * Returns the current scene
  20789. * @returns a Scene
  20790. */
  20791. getScene(): Scene;
  20792. /**
  20793. * Specifies if the material will require alpha blending
  20794. * @returns a boolean specifying if alpha blending is needed
  20795. */
  20796. needAlphaBlending(): boolean;
  20797. /**
  20798. * Specifies if the mesh will require alpha blending
  20799. * @param mesh defines the mesh to check
  20800. * @returns a boolean specifying if alpha blending is needed for the mesh
  20801. */
  20802. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20803. /**
  20804. * Specifies if this material should be rendered in alpha test mode
  20805. * @returns a boolean specifying if an alpha test is needed.
  20806. */
  20807. needAlphaTesting(): boolean;
  20808. /**
  20809. * Gets the texture used for the alpha test
  20810. * @returns the texture to use for alpha testing
  20811. */
  20812. getAlphaTestTexture(): Nullable<BaseTexture>;
  20813. /**
  20814. * Marks the material to indicate that it needs to be re-calculated
  20815. */
  20816. markDirty(): void;
  20817. /** @hidden */
  20818. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  20819. /**
  20820. * Binds the material to the mesh
  20821. * @param world defines the world transformation matrix
  20822. * @param mesh defines the mesh to bind the material to
  20823. */
  20824. bind(world: Matrix, mesh?: Mesh): void;
  20825. /**
  20826. * Binds the submesh to the material
  20827. * @param world defines the world transformation matrix
  20828. * @param mesh defines the mesh containing the submesh
  20829. * @param subMesh defines the submesh to bind the material to
  20830. */
  20831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20832. /**
  20833. * Binds the world matrix to the material
  20834. * @param world defines the world transformation matrix
  20835. */
  20836. bindOnlyWorldMatrix(world: Matrix): void;
  20837. /**
  20838. * Binds the scene's uniform buffer to the effect.
  20839. * @param effect defines the effect to bind to the scene uniform buffer
  20840. * @param sceneUbo defines the uniform buffer storing scene data
  20841. */
  20842. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20843. /**
  20844. * Binds the view matrix to the effect
  20845. * @param effect defines the effect to bind the view matrix to
  20846. */
  20847. bindView(effect: Effect): void;
  20848. /**
  20849. * Binds the view projection matrix to the effect
  20850. * @param effect defines the effect to bind the view projection matrix to
  20851. */
  20852. bindViewProjection(effect: Effect): void;
  20853. /**
  20854. * Specifies if material alpha testing should be turned on for the mesh
  20855. * @param mesh defines the mesh to check
  20856. */
  20857. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20858. /**
  20859. * Processes to execute after binding the material to a mesh
  20860. * @param mesh defines the rendered mesh
  20861. */
  20862. protected _afterBind(mesh?: Mesh): void;
  20863. /**
  20864. * Unbinds the material from the mesh
  20865. */
  20866. unbind(): void;
  20867. /**
  20868. * Gets the active textures from the material
  20869. * @returns an array of textures
  20870. */
  20871. getActiveTextures(): BaseTexture[];
  20872. /**
  20873. * Specifies if the material uses a texture
  20874. * @param texture defines the texture to check against the material
  20875. * @returns a boolean specifying if the material uses the texture
  20876. */
  20877. hasTexture(texture: BaseTexture): boolean;
  20878. /**
  20879. * Makes a duplicate of the material, and gives it a new name
  20880. * @param name defines the new name for the duplicated material
  20881. * @returns the cloned material
  20882. */
  20883. clone(name: string): Nullable<Material>;
  20884. /**
  20885. * Gets the meshes bound to the material
  20886. * @returns an array of meshes bound to the material
  20887. */
  20888. getBindedMeshes(): AbstractMesh[];
  20889. /**
  20890. * Force shader compilation
  20891. * @param mesh defines the mesh associated with this material
  20892. * @param onCompiled defines a function to execute once the material is compiled
  20893. * @param options defines the options to configure the compilation
  20894. */
  20895. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20896. clipPlane: boolean;
  20897. }>): void;
  20898. /**
  20899. * Force shader compilation
  20900. * @param mesh defines the mesh that will use this material
  20901. * @param options defines additional options for compiling the shaders
  20902. * @returns a promise that resolves when the compilation completes
  20903. */
  20904. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20905. clipPlane: boolean;
  20906. }>): Promise<void>;
  20907. private static readonly _AllDirtyCallBack;
  20908. private static readonly _ImageProcessingDirtyCallBack;
  20909. private static readonly _TextureDirtyCallBack;
  20910. private static readonly _FresnelDirtyCallBack;
  20911. private static readonly _MiscDirtyCallBack;
  20912. private static readonly _LightsDirtyCallBack;
  20913. private static readonly _AttributeDirtyCallBack;
  20914. private static _FresnelAndMiscDirtyCallBack;
  20915. private static _TextureAndMiscDirtyCallBack;
  20916. private static readonly _DirtyCallbackArray;
  20917. private static readonly _RunDirtyCallBacks;
  20918. /**
  20919. * Marks a define in the material to indicate that it needs to be re-computed
  20920. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20921. */
  20922. markAsDirty(flag: number): void;
  20923. /**
  20924. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20925. * @param func defines a function which checks material defines against the submeshes
  20926. */
  20927. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20928. /**
  20929. * Indicates that we need to re-calculated for all submeshes
  20930. */
  20931. protected _markAllSubMeshesAsAllDirty(): void;
  20932. /**
  20933. * Indicates that image processing needs to be re-calculated for all submeshes
  20934. */
  20935. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20936. /**
  20937. * Indicates that textures need to be re-calculated for all submeshes
  20938. */
  20939. protected _markAllSubMeshesAsTexturesDirty(): void;
  20940. /**
  20941. * Indicates that fresnel needs to be re-calculated for all submeshes
  20942. */
  20943. protected _markAllSubMeshesAsFresnelDirty(): void;
  20944. /**
  20945. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20946. */
  20947. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20948. /**
  20949. * Indicates that lights need to be re-calculated for all submeshes
  20950. */
  20951. protected _markAllSubMeshesAsLightsDirty(): void;
  20952. /**
  20953. * Indicates that attributes need to be re-calculated for all submeshes
  20954. */
  20955. protected _markAllSubMeshesAsAttributesDirty(): void;
  20956. /**
  20957. * Indicates that misc needs to be re-calculated for all submeshes
  20958. */
  20959. protected _markAllSubMeshesAsMiscDirty(): void;
  20960. /**
  20961. * Indicates that textures and misc need to be re-calculated for all submeshes
  20962. */
  20963. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20964. /**
  20965. * Disposes the material
  20966. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20967. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20968. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20969. */
  20970. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20971. /** @hidden */
  20972. private releaseVertexArrayObject;
  20973. /**
  20974. * Serializes this material
  20975. * @returns the serialized material object
  20976. */
  20977. serialize(): any;
  20978. /**
  20979. * Creates a material from parsed material data
  20980. * @param parsedMaterial defines parsed material data
  20981. * @param scene defines the hosting scene
  20982. * @param rootUrl defines the root URL to use to load textures
  20983. * @returns a new material
  20984. */
  20985. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20986. }
  20987. }
  20988. declare module "babylonjs/Materials/multiMaterial" {
  20989. import { Nullable } from "babylonjs/types";
  20990. import { Scene } from "babylonjs/scene";
  20991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20992. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  20993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20994. import { Material } from "babylonjs/Materials/material";
  20995. /**
  20996. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20997. * separate meshes. This can be use to improve performances.
  20998. * @see http://doc.babylonjs.com/how_to/multi_materials
  20999. */
  21000. export class MultiMaterial extends Material {
  21001. private _subMaterials;
  21002. /**
  21003. * Gets or Sets the list of Materials used within the multi material.
  21004. * They need to be ordered according to the submeshes order in the associated mesh
  21005. */
  21006. subMaterials: Nullable<Material>[];
  21007. /**
  21008. * Function used to align with Node.getChildren()
  21009. * @returns the list of Materials used within the multi material
  21010. */
  21011. getChildren(): Nullable<Material>[];
  21012. /**
  21013. * Instantiates a new Multi Material
  21014. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21015. * separate meshes. This can be use to improve performances.
  21016. * @see http://doc.babylonjs.com/how_to/multi_materials
  21017. * @param name Define the name in the scene
  21018. * @param scene Define the scene the material belongs to
  21019. */
  21020. constructor(name: string, scene: Scene);
  21021. private _hookArray;
  21022. /**
  21023. * Get one of the submaterial by its index in the submaterials array
  21024. * @param index The index to look the sub material at
  21025. * @returns The Material if the index has been defined
  21026. */
  21027. getSubMaterial(index: number): Nullable<Material>;
  21028. /**
  21029. * Get the list of active textures for the whole sub materials list.
  21030. * @returns All the textures that will be used during the rendering
  21031. */
  21032. getActiveTextures(): BaseTexture[];
  21033. /**
  21034. * Gets the current class name of the material e.g. "MultiMaterial"
  21035. * Mainly use in serialization.
  21036. * @returns the class name
  21037. */
  21038. getClassName(): string;
  21039. /**
  21040. * Checks if the material is ready to render the requested sub mesh
  21041. * @param mesh Define the mesh the submesh belongs to
  21042. * @param subMesh Define the sub mesh to look readyness for
  21043. * @param useInstances Define whether or not the material is used with instances
  21044. * @returns true if ready, otherwise false
  21045. */
  21046. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21047. /**
  21048. * Clones the current material and its related sub materials
  21049. * @param name Define the name of the newly cloned material
  21050. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21051. * @returns the cloned material
  21052. */
  21053. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21054. /**
  21055. * Serializes the materials into a JSON representation.
  21056. * @returns the JSON representation
  21057. */
  21058. serialize(): any;
  21059. /**
  21060. * Dispose the material and release its associated resources
  21061. * @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)
  21062. * @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)
  21063. * @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)
  21064. */
  21065. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21066. /**
  21067. * Creates a MultiMaterial from parsed MultiMaterial data.
  21068. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21069. * @param scene defines the hosting scene
  21070. * @returns a new MultiMaterial
  21071. */
  21072. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21073. }
  21074. }
  21075. declare module "babylonjs/Meshes/subMesh" {
  21076. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21077. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21078. import { Engine } from "babylonjs/Engines/engine";
  21079. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21080. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21081. import { Effect } from "babylonjs/Materials/effect";
  21082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21083. import { Plane } from "babylonjs/Maths/math.plane";
  21084. import { Collider } from "babylonjs/Collisions/collider";
  21085. import { Material } from "babylonjs/Materials/material";
  21086. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21087. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21088. import { Mesh } from "babylonjs/Meshes/mesh";
  21089. import { Ray } from "babylonjs/Culling/ray";
  21090. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21091. /**
  21092. * Base class for submeshes
  21093. */
  21094. export class BaseSubMesh {
  21095. /** @hidden */
  21096. _materialDefines: Nullable<MaterialDefines>;
  21097. /** @hidden */
  21098. _materialEffect: Nullable<Effect>;
  21099. /**
  21100. * Gets associated effect
  21101. */
  21102. readonly effect: Nullable<Effect>;
  21103. /**
  21104. * Sets associated effect (effect used to render this submesh)
  21105. * @param effect defines the effect to associate with
  21106. * @param defines defines the set of defines used to compile this effect
  21107. */
  21108. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21109. }
  21110. /**
  21111. * Defines a subdivision inside a mesh
  21112. */
  21113. export class SubMesh extends BaseSubMesh implements ICullable {
  21114. /** the material index to use */
  21115. materialIndex: number;
  21116. /** vertex index start */
  21117. verticesStart: number;
  21118. /** vertices count */
  21119. verticesCount: number;
  21120. /** index start */
  21121. indexStart: number;
  21122. /** indices count */
  21123. indexCount: number;
  21124. /** @hidden */
  21125. _linesIndexCount: number;
  21126. private _mesh;
  21127. private _renderingMesh;
  21128. private _boundingInfo;
  21129. private _linesIndexBuffer;
  21130. /** @hidden */
  21131. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21132. /** @hidden */
  21133. _trianglePlanes: Plane[];
  21134. /** @hidden */
  21135. _lastColliderTransformMatrix: Nullable<Matrix>;
  21136. /** @hidden */
  21137. _renderId: number;
  21138. /** @hidden */
  21139. _alphaIndex: number;
  21140. /** @hidden */
  21141. _distanceToCamera: number;
  21142. /** @hidden */
  21143. _id: number;
  21144. private _currentMaterial;
  21145. /**
  21146. * Add a new submesh to a mesh
  21147. * @param materialIndex defines the material index to use
  21148. * @param verticesStart defines vertex index start
  21149. * @param verticesCount defines vertices count
  21150. * @param indexStart defines index start
  21151. * @param indexCount defines indices count
  21152. * @param mesh defines the parent mesh
  21153. * @param renderingMesh defines an optional rendering mesh
  21154. * @param createBoundingBox defines if bounding box should be created for this submesh
  21155. * @returns the new submesh
  21156. */
  21157. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21158. /**
  21159. * Creates a new submesh
  21160. * @param materialIndex defines the material index to use
  21161. * @param verticesStart defines vertex index start
  21162. * @param verticesCount defines vertices count
  21163. * @param indexStart defines index start
  21164. * @param indexCount defines indices count
  21165. * @param mesh defines the parent mesh
  21166. * @param renderingMesh defines an optional rendering mesh
  21167. * @param createBoundingBox defines if bounding box should be created for this submesh
  21168. */
  21169. constructor(
  21170. /** the material index to use */
  21171. materialIndex: number,
  21172. /** vertex index start */
  21173. verticesStart: number,
  21174. /** vertices count */
  21175. verticesCount: number,
  21176. /** index start */
  21177. indexStart: number,
  21178. /** indices count */
  21179. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21180. /**
  21181. * Returns true if this submesh covers the entire parent mesh
  21182. * @ignorenaming
  21183. */
  21184. readonly IsGlobal: boolean;
  21185. /**
  21186. * Returns the submesh BoudingInfo object
  21187. * @returns current bounding info (or mesh's one if the submesh is global)
  21188. */
  21189. getBoundingInfo(): BoundingInfo;
  21190. /**
  21191. * Sets the submesh BoundingInfo
  21192. * @param boundingInfo defines the new bounding info to use
  21193. * @returns the SubMesh
  21194. */
  21195. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21196. /**
  21197. * Returns the mesh of the current submesh
  21198. * @return the parent mesh
  21199. */
  21200. getMesh(): AbstractMesh;
  21201. /**
  21202. * Returns the rendering mesh of the submesh
  21203. * @returns the rendering mesh (could be different from parent mesh)
  21204. */
  21205. getRenderingMesh(): Mesh;
  21206. /**
  21207. * Returns the submesh material
  21208. * @returns null or the current material
  21209. */
  21210. getMaterial(): Nullable<Material>;
  21211. /**
  21212. * Sets a new updated BoundingInfo object to the submesh
  21213. * @param data defines an optional position array to use to determine the bounding info
  21214. * @returns the SubMesh
  21215. */
  21216. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21217. /** @hidden */
  21218. _checkCollision(collider: Collider): boolean;
  21219. /**
  21220. * Updates the submesh BoundingInfo
  21221. * @param world defines the world matrix to use to update the bounding info
  21222. * @returns the submesh
  21223. */
  21224. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21225. /**
  21226. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21227. * @param frustumPlanes defines the frustum planes
  21228. * @returns true if the submesh is intersecting with the frustum
  21229. */
  21230. isInFrustum(frustumPlanes: Plane[]): boolean;
  21231. /**
  21232. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21233. * @param frustumPlanes defines the frustum planes
  21234. * @returns true if the submesh is inside the frustum
  21235. */
  21236. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21237. /**
  21238. * Renders the submesh
  21239. * @param enableAlphaMode defines if alpha needs to be used
  21240. * @returns the submesh
  21241. */
  21242. render(enableAlphaMode: boolean): SubMesh;
  21243. /**
  21244. * @hidden
  21245. */
  21246. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21247. /**
  21248. * Checks if the submesh intersects with a ray
  21249. * @param ray defines the ray to test
  21250. * @returns true is the passed ray intersects the submesh bounding box
  21251. */
  21252. canIntersects(ray: Ray): boolean;
  21253. /**
  21254. * Intersects current submesh with a ray
  21255. * @param ray defines the ray to test
  21256. * @param positions defines mesh's positions array
  21257. * @param indices defines mesh's indices array
  21258. * @param fastCheck defines if only bounding info should be used
  21259. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21260. * @returns intersection info or null if no intersection
  21261. */
  21262. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21263. /** @hidden */
  21264. private _intersectLines;
  21265. /** @hidden */
  21266. private _intersectUnIndexedLines;
  21267. /** @hidden */
  21268. private _intersectTriangles;
  21269. /** @hidden */
  21270. private _intersectUnIndexedTriangles;
  21271. /** @hidden */
  21272. _rebuild(): void;
  21273. /**
  21274. * Creates a new submesh from the passed mesh
  21275. * @param newMesh defines the new hosting mesh
  21276. * @param newRenderingMesh defines an optional rendering mesh
  21277. * @returns the new submesh
  21278. */
  21279. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21280. /**
  21281. * Release associated resources
  21282. */
  21283. dispose(): void;
  21284. /**
  21285. * Gets the class name
  21286. * @returns the string "SubMesh".
  21287. */
  21288. getClassName(): string;
  21289. /**
  21290. * Creates a new submesh from indices data
  21291. * @param materialIndex the index of the main mesh material
  21292. * @param startIndex the index where to start the copy in the mesh indices array
  21293. * @param indexCount the number of indices to copy then from the startIndex
  21294. * @param mesh the main mesh to create the submesh from
  21295. * @param renderingMesh the optional rendering mesh
  21296. * @returns a new submesh
  21297. */
  21298. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21299. }
  21300. }
  21301. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21302. /**
  21303. * Class used to represent data loading progression
  21304. */
  21305. export class SceneLoaderFlags {
  21306. private static _ForceFullSceneLoadingForIncremental;
  21307. private static _ShowLoadingScreen;
  21308. private static _CleanBoneMatrixWeights;
  21309. private static _loggingLevel;
  21310. /**
  21311. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21312. */
  21313. static ForceFullSceneLoadingForIncremental: boolean;
  21314. /**
  21315. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21316. */
  21317. static ShowLoadingScreen: boolean;
  21318. /**
  21319. * Defines the current logging level (while loading the scene)
  21320. * @ignorenaming
  21321. */
  21322. static loggingLevel: number;
  21323. /**
  21324. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21325. */
  21326. static CleanBoneMatrixWeights: boolean;
  21327. }
  21328. }
  21329. declare module "babylonjs/Meshes/geometry" {
  21330. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21331. import { Scene } from "babylonjs/scene";
  21332. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21333. import { Engine } from "babylonjs/Engines/engine";
  21334. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21335. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21336. import { Effect } from "babylonjs/Materials/effect";
  21337. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21338. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21339. import { Mesh } from "babylonjs/Meshes/mesh";
  21340. /**
  21341. * Class used to store geometry data (vertex buffers + index buffer)
  21342. */
  21343. export class Geometry implements IGetSetVerticesData {
  21344. /**
  21345. * Gets or sets the ID of the geometry
  21346. */
  21347. id: string;
  21348. /**
  21349. * Gets or sets the unique ID of the geometry
  21350. */
  21351. uniqueId: number;
  21352. /**
  21353. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21354. */
  21355. delayLoadState: number;
  21356. /**
  21357. * Gets the file containing the data to load when running in delay load state
  21358. */
  21359. delayLoadingFile: Nullable<string>;
  21360. /**
  21361. * Callback called when the geometry is updated
  21362. */
  21363. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21364. private _scene;
  21365. private _engine;
  21366. private _meshes;
  21367. private _totalVertices;
  21368. /** @hidden */
  21369. _indices: IndicesArray;
  21370. /** @hidden */
  21371. _vertexBuffers: {
  21372. [key: string]: VertexBuffer;
  21373. };
  21374. private _isDisposed;
  21375. private _extend;
  21376. private _boundingBias;
  21377. /** @hidden */
  21378. _delayInfo: Array<string>;
  21379. private _indexBuffer;
  21380. private _indexBufferIsUpdatable;
  21381. /** @hidden */
  21382. _boundingInfo: Nullable<BoundingInfo>;
  21383. /** @hidden */
  21384. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21385. /** @hidden */
  21386. _softwareSkinningFrameId: number;
  21387. private _vertexArrayObjects;
  21388. private _updatable;
  21389. /** @hidden */
  21390. _positions: Nullable<Vector3[]>;
  21391. /**
  21392. * 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
  21393. */
  21394. /**
  21395. * 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
  21396. */
  21397. boundingBias: Vector2;
  21398. /**
  21399. * Static function used to attach a new empty geometry to a mesh
  21400. * @param mesh defines the mesh to attach the geometry to
  21401. * @returns the new Geometry
  21402. */
  21403. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21404. /**
  21405. * Creates a new geometry
  21406. * @param id defines the unique ID
  21407. * @param scene defines the hosting scene
  21408. * @param vertexData defines the VertexData used to get geometry data
  21409. * @param updatable defines if geometry must be updatable (false by default)
  21410. * @param mesh defines the mesh that will be associated with the geometry
  21411. */
  21412. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21413. /**
  21414. * Gets the current extend of the geometry
  21415. */
  21416. readonly extend: {
  21417. minimum: Vector3;
  21418. maximum: Vector3;
  21419. };
  21420. /**
  21421. * Gets the hosting scene
  21422. * @returns the hosting Scene
  21423. */
  21424. getScene(): Scene;
  21425. /**
  21426. * Gets the hosting engine
  21427. * @returns the hosting Engine
  21428. */
  21429. getEngine(): Engine;
  21430. /**
  21431. * Defines if the geometry is ready to use
  21432. * @returns true if the geometry is ready to be used
  21433. */
  21434. isReady(): boolean;
  21435. /**
  21436. * Gets a value indicating that the geometry should not be serialized
  21437. */
  21438. readonly doNotSerialize: boolean;
  21439. /** @hidden */
  21440. _rebuild(): void;
  21441. /**
  21442. * Affects all geometry data in one call
  21443. * @param vertexData defines the geometry data
  21444. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21445. */
  21446. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21447. /**
  21448. * Set specific vertex data
  21449. * @param kind defines the data kind (Position, normal, etc...)
  21450. * @param data defines the vertex data to use
  21451. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21452. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21453. */
  21454. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21455. /**
  21456. * Removes a specific vertex data
  21457. * @param kind defines the data kind (Position, normal, etc...)
  21458. */
  21459. removeVerticesData(kind: string): void;
  21460. /**
  21461. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21462. * @param buffer defines the vertex buffer to use
  21463. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21464. */
  21465. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21466. /**
  21467. * Update a specific vertex buffer
  21468. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21469. * It will do nothing if the buffer is not updatable
  21470. * @param kind defines the data kind (Position, normal, etc...)
  21471. * @param data defines the data to use
  21472. * @param offset defines the offset in the target buffer where to store the data
  21473. * @param useBytes set to true if the offset is in bytes
  21474. */
  21475. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21476. /**
  21477. * Update a specific vertex buffer
  21478. * This function will create a new buffer if the current one is not updatable
  21479. * @param kind defines the data kind (Position, normal, etc...)
  21480. * @param data defines the data to use
  21481. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21482. */
  21483. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21484. private _updateBoundingInfo;
  21485. /** @hidden */
  21486. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21487. /**
  21488. * Gets total number of vertices
  21489. * @returns the total number of vertices
  21490. */
  21491. getTotalVertices(): number;
  21492. /**
  21493. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21494. * @param kind defines the data kind (Position, normal, etc...)
  21495. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21496. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21497. * @returns a float array containing vertex data
  21498. */
  21499. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21500. /**
  21501. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21502. * @param kind defines the data kind (Position, normal, etc...)
  21503. * @returns true if the vertex buffer with the specified kind is updatable
  21504. */
  21505. isVertexBufferUpdatable(kind: string): boolean;
  21506. /**
  21507. * Gets a specific vertex buffer
  21508. * @param kind defines the data kind (Position, normal, etc...)
  21509. * @returns a VertexBuffer
  21510. */
  21511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21512. /**
  21513. * Returns all vertex buffers
  21514. * @return an object holding all vertex buffers indexed by kind
  21515. */
  21516. getVertexBuffers(): Nullable<{
  21517. [key: string]: VertexBuffer;
  21518. }>;
  21519. /**
  21520. * Gets a boolean indicating if specific vertex buffer is present
  21521. * @param kind defines the data kind (Position, normal, etc...)
  21522. * @returns true if data is present
  21523. */
  21524. isVerticesDataPresent(kind: string): boolean;
  21525. /**
  21526. * Gets a list of all attached data kinds (Position, normal, etc...)
  21527. * @returns a list of string containing all kinds
  21528. */
  21529. getVerticesDataKinds(): string[];
  21530. /**
  21531. * Update index buffer
  21532. * @param indices defines the indices to store in the index buffer
  21533. * @param offset defines the offset in the target buffer where to store the data
  21534. * @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)
  21535. */
  21536. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21537. /**
  21538. * Creates a new index buffer
  21539. * @param indices defines the indices to store in the index buffer
  21540. * @param totalVertices defines the total number of vertices (could be null)
  21541. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21542. */
  21543. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21544. /**
  21545. * Return the total number of indices
  21546. * @returns the total number of indices
  21547. */
  21548. getTotalIndices(): number;
  21549. /**
  21550. * Gets the index buffer array
  21551. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21552. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21553. * @returns the index buffer array
  21554. */
  21555. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21556. /**
  21557. * Gets the index buffer
  21558. * @return the index buffer
  21559. */
  21560. getIndexBuffer(): Nullable<DataBuffer>;
  21561. /** @hidden */
  21562. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21563. /**
  21564. * Release the associated resources for a specific mesh
  21565. * @param mesh defines the source mesh
  21566. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21567. */
  21568. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21569. /**
  21570. * Apply current geometry to a given mesh
  21571. * @param mesh defines the mesh to apply geometry to
  21572. */
  21573. applyToMesh(mesh: Mesh): void;
  21574. private _updateExtend;
  21575. private _applyToMesh;
  21576. private notifyUpdate;
  21577. /**
  21578. * Load the geometry if it was flagged as delay loaded
  21579. * @param scene defines the hosting scene
  21580. * @param onLoaded defines a callback called when the geometry is loaded
  21581. */
  21582. load(scene: Scene, onLoaded?: () => void): void;
  21583. private _queueLoad;
  21584. /**
  21585. * Invert the geometry to move from a right handed system to a left handed one.
  21586. */
  21587. toLeftHanded(): void;
  21588. /** @hidden */
  21589. _resetPointsArrayCache(): void;
  21590. /** @hidden */
  21591. _generatePointsArray(): boolean;
  21592. /**
  21593. * Gets a value indicating if the geometry is disposed
  21594. * @returns true if the geometry was disposed
  21595. */
  21596. isDisposed(): boolean;
  21597. private _disposeVertexArrayObjects;
  21598. /**
  21599. * Free all associated resources
  21600. */
  21601. dispose(): void;
  21602. /**
  21603. * Clone the current geometry into a new geometry
  21604. * @param id defines the unique ID of the new geometry
  21605. * @returns a new geometry object
  21606. */
  21607. copy(id: string): Geometry;
  21608. /**
  21609. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21610. * @return a JSON representation of the current geometry data (without the vertices data)
  21611. */
  21612. serialize(): any;
  21613. private toNumberArray;
  21614. /**
  21615. * Serialize all vertices data into a JSON oject
  21616. * @returns a JSON representation of the current geometry data
  21617. */
  21618. serializeVerticeData(): any;
  21619. /**
  21620. * Extracts a clone of a mesh geometry
  21621. * @param mesh defines the source mesh
  21622. * @param id defines the unique ID of the new geometry object
  21623. * @returns the new geometry object
  21624. */
  21625. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21626. /**
  21627. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21628. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21629. * Be aware Math.random() could cause collisions, but:
  21630. * "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"
  21631. * @returns a string containing a new GUID
  21632. */
  21633. static RandomId(): string;
  21634. /** @hidden */
  21635. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21636. private static _CleanMatricesWeights;
  21637. /**
  21638. * Create a new geometry from persisted data (Using .babylon file format)
  21639. * @param parsedVertexData defines the persisted data
  21640. * @param scene defines the hosting scene
  21641. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21642. * @returns the new geometry object
  21643. */
  21644. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21645. }
  21646. }
  21647. declare module "babylonjs/Meshes/mesh.vertexData" {
  21648. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21649. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21650. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21651. import { Geometry } from "babylonjs/Meshes/geometry";
  21652. import { Mesh } from "babylonjs/Meshes/mesh";
  21653. /**
  21654. * Define an interface for all classes that will get and set the data on vertices
  21655. */
  21656. export interface IGetSetVerticesData {
  21657. /**
  21658. * Gets a boolean indicating if specific vertex data is present
  21659. * @param kind defines the vertex data kind to use
  21660. * @returns true is data kind is present
  21661. */
  21662. isVerticesDataPresent(kind: string): boolean;
  21663. /**
  21664. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21665. * @param kind defines the data kind (Position, normal, etc...)
  21666. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21667. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21668. * @returns a float array containing vertex data
  21669. */
  21670. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21671. /**
  21672. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21673. * @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.
  21674. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21675. * @returns the indices array or an empty array if the mesh has no geometry
  21676. */
  21677. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21678. /**
  21679. * Set specific vertex data
  21680. * @param kind defines the data kind (Position, normal, etc...)
  21681. * @param data defines the vertex data to use
  21682. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21683. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21684. */
  21685. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21686. /**
  21687. * Update a specific associated vertex buffer
  21688. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21689. * - VertexBuffer.PositionKind
  21690. * - VertexBuffer.UVKind
  21691. * - VertexBuffer.UV2Kind
  21692. * - VertexBuffer.UV3Kind
  21693. * - VertexBuffer.UV4Kind
  21694. * - VertexBuffer.UV5Kind
  21695. * - VertexBuffer.UV6Kind
  21696. * - VertexBuffer.ColorKind
  21697. * - VertexBuffer.MatricesIndicesKind
  21698. * - VertexBuffer.MatricesIndicesExtraKind
  21699. * - VertexBuffer.MatricesWeightsKind
  21700. * - VertexBuffer.MatricesWeightsExtraKind
  21701. * @param data defines the data source
  21702. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21703. * @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)
  21704. */
  21705. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21706. /**
  21707. * Creates a new index buffer
  21708. * @param indices defines the indices to store in the index buffer
  21709. * @param totalVertices defines the total number of vertices (could be null)
  21710. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21711. */
  21712. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21713. }
  21714. /**
  21715. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21716. */
  21717. export class VertexData {
  21718. /**
  21719. * Mesh side orientation : usually the external or front surface
  21720. */
  21721. static readonly FRONTSIDE: number;
  21722. /**
  21723. * Mesh side orientation : usually the internal or back surface
  21724. */
  21725. static readonly BACKSIDE: number;
  21726. /**
  21727. * Mesh side orientation : both internal and external or front and back surfaces
  21728. */
  21729. static readonly DOUBLESIDE: number;
  21730. /**
  21731. * Mesh side orientation : by default, `FRONTSIDE`
  21732. */
  21733. static readonly DEFAULTSIDE: number;
  21734. /**
  21735. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21736. */
  21737. positions: Nullable<FloatArray>;
  21738. /**
  21739. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21740. */
  21741. normals: Nullable<FloatArray>;
  21742. /**
  21743. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21744. */
  21745. tangents: Nullable<FloatArray>;
  21746. /**
  21747. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21748. */
  21749. uvs: Nullable<FloatArray>;
  21750. /**
  21751. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21752. */
  21753. uvs2: Nullable<FloatArray>;
  21754. /**
  21755. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21756. */
  21757. uvs3: Nullable<FloatArray>;
  21758. /**
  21759. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21760. */
  21761. uvs4: Nullable<FloatArray>;
  21762. /**
  21763. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21764. */
  21765. uvs5: Nullable<FloatArray>;
  21766. /**
  21767. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21768. */
  21769. uvs6: Nullable<FloatArray>;
  21770. /**
  21771. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21772. */
  21773. colors: Nullable<FloatArray>;
  21774. /**
  21775. * 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).
  21776. */
  21777. matricesIndices: Nullable<FloatArray>;
  21778. /**
  21779. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21780. */
  21781. matricesWeights: Nullable<FloatArray>;
  21782. /**
  21783. * An array extending the number of possible indices
  21784. */
  21785. matricesIndicesExtra: Nullable<FloatArray>;
  21786. /**
  21787. * An array extending the number of possible weights when the number of indices is extended
  21788. */
  21789. matricesWeightsExtra: Nullable<FloatArray>;
  21790. /**
  21791. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21792. */
  21793. indices: Nullable<IndicesArray>;
  21794. /**
  21795. * Uses the passed data array to set the set the values for the specified kind of data
  21796. * @param data a linear array of floating numbers
  21797. * @param kind the type of data that is being set, eg positions, colors etc
  21798. */
  21799. set(data: FloatArray, kind: string): void;
  21800. /**
  21801. * Associates the vertexData to the passed Mesh.
  21802. * Sets it as updatable or not (default `false`)
  21803. * @param mesh the mesh the vertexData is applied to
  21804. * @param updatable when used and having the value true allows new data to update the vertexData
  21805. * @returns the VertexData
  21806. */
  21807. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21808. /**
  21809. * Associates the vertexData to the passed Geometry.
  21810. * Sets it as updatable or not (default `false`)
  21811. * @param geometry the geometry the vertexData is applied to
  21812. * @param updatable when used and having the value true allows new data to update the vertexData
  21813. * @returns VertexData
  21814. */
  21815. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21816. /**
  21817. * Updates the associated mesh
  21818. * @param mesh the mesh to be updated
  21819. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21820. * @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
  21821. * @returns VertexData
  21822. */
  21823. updateMesh(mesh: Mesh): VertexData;
  21824. /**
  21825. * Updates the associated geometry
  21826. * @param geometry the geometry to be updated
  21827. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21828. * @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
  21829. * @returns VertexData.
  21830. */
  21831. updateGeometry(geometry: Geometry): VertexData;
  21832. private _applyTo;
  21833. private _update;
  21834. /**
  21835. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21836. * @param matrix the transforming matrix
  21837. * @returns the VertexData
  21838. */
  21839. transform(matrix: Matrix): VertexData;
  21840. /**
  21841. * Merges the passed VertexData into the current one
  21842. * @param other the VertexData to be merged into the current one
  21843. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21844. * @returns the modified VertexData
  21845. */
  21846. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21847. private _mergeElement;
  21848. private _validate;
  21849. /**
  21850. * Serializes the VertexData
  21851. * @returns a serialized object
  21852. */
  21853. serialize(): any;
  21854. /**
  21855. * Extracts the vertexData from a mesh
  21856. * @param mesh the mesh from which to extract the VertexData
  21857. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21858. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21859. * @returns the object VertexData associated to the passed mesh
  21860. */
  21861. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21862. /**
  21863. * Extracts the vertexData from the geometry
  21864. * @param geometry the geometry from which to extract the VertexData
  21865. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  21866. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21867. * @returns the object VertexData associated to the passed mesh
  21868. */
  21869. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21870. private static _ExtractFrom;
  21871. /**
  21872. * Creates the VertexData for a Ribbon
  21873. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  21874. * * pathArray array of paths, each of which an array of successive Vector3
  21875. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  21876. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  21877. * * 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
  21878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21879. * * 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)
  21880. * * 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)
  21881. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  21882. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  21883. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  21884. * @returns the VertexData of the ribbon
  21885. */
  21886. static CreateRibbon(options: {
  21887. pathArray: Vector3[][];
  21888. closeArray?: boolean;
  21889. closePath?: boolean;
  21890. offset?: number;
  21891. sideOrientation?: number;
  21892. frontUVs?: Vector4;
  21893. backUVs?: Vector4;
  21894. invertUV?: boolean;
  21895. uvs?: Vector2[];
  21896. colors?: Color4[];
  21897. }): VertexData;
  21898. /**
  21899. * Creates the VertexData for a box
  21900. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21901. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21902. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21903. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21904. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21905. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21906. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21907. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21908. * * 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)
  21909. * * 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)
  21910. * @returns the VertexData of the box
  21911. */
  21912. static CreateBox(options: {
  21913. size?: number;
  21914. width?: number;
  21915. height?: number;
  21916. depth?: number;
  21917. faceUV?: Vector4[];
  21918. faceColors?: Color4[];
  21919. sideOrientation?: number;
  21920. frontUVs?: Vector4;
  21921. backUVs?: Vector4;
  21922. }): VertexData;
  21923. /**
  21924. * Creates the VertexData for a tiled box
  21925. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21926. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21927. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21928. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21929. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21930. * @returns the VertexData of the box
  21931. */
  21932. static CreateTiledBox(options: {
  21933. pattern?: number;
  21934. width?: number;
  21935. height?: number;
  21936. depth?: number;
  21937. tileSize?: number;
  21938. tileWidth?: number;
  21939. tileHeight?: number;
  21940. alignHorizontal?: number;
  21941. alignVertical?: number;
  21942. faceUV?: Vector4[];
  21943. faceColors?: Color4[];
  21944. sideOrientation?: number;
  21945. }): VertexData;
  21946. /**
  21947. * Creates the VertexData for a tiled plane
  21948. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21949. * * pattern a limited pattern arrangement depending on the number
  21950. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21951. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21952. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21953. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21954. * * 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)
  21955. * * 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)
  21956. * @returns the VertexData of the tiled plane
  21957. */
  21958. static CreateTiledPlane(options: {
  21959. pattern?: number;
  21960. tileSize?: number;
  21961. tileWidth?: number;
  21962. tileHeight?: number;
  21963. size?: number;
  21964. width?: number;
  21965. height?: number;
  21966. alignHorizontal?: number;
  21967. alignVertical?: number;
  21968. sideOrientation?: number;
  21969. frontUVs?: Vector4;
  21970. backUVs?: Vector4;
  21971. }): VertexData;
  21972. /**
  21973. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21975. * * segments sets the number of horizontal strips optional, default 32
  21976. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21977. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21978. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21979. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21980. * * 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
  21981. * * 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
  21982. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21983. * * 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)
  21984. * * 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)
  21985. * @returns the VertexData of the ellipsoid
  21986. */
  21987. static CreateSphere(options: {
  21988. segments?: number;
  21989. diameter?: number;
  21990. diameterX?: number;
  21991. diameterY?: number;
  21992. diameterZ?: number;
  21993. arc?: number;
  21994. slice?: number;
  21995. sideOrientation?: number;
  21996. frontUVs?: Vector4;
  21997. backUVs?: Vector4;
  21998. }): VertexData;
  21999. /**
  22000. * Creates the VertexData for a cylinder, cone or prism
  22001. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22002. * * height sets the height (y direction) of the cylinder, optional, default 2
  22003. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22004. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22005. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22006. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22007. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22008. * * 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
  22009. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22010. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22011. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22012. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22013. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22014. * * 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)
  22015. * * 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)
  22016. * @returns the VertexData of the cylinder, cone or prism
  22017. */
  22018. static CreateCylinder(options: {
  22019. height?: number;
  22020. diameterTop?: number;
  22021. diameterBottom?: number;
  22022. diameter?: number;
  22023. tessellation?: number;
  22024. subdivisions?: number;
  22025. arc?: number;
  22026. faceColors?: Color4[];
  22027. faceUV?: Vector4[];
  22028. hasRings?: boolean;
  22029. enclose?: boolean;
  22030. sideOrientation?: number;
  22031. frontUVs?: Vector4;
  22032. backUVs?: Vector4;
  22033. }): VertexData;
  22034. /**
  22035. * Creates the VertexData for a torus
  22036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22037. * * diameter the diameter of the torus, optional default 1
  22038. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22039. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22041. * * 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)
  22042. * * 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)
  22043. * @returns the VertexData of the torus
  22044. */
  22045. static CreateTorus(options: {
  22046. diameter?: number;
  22047. thickness?: number;
  22048. tessellation?: number;
  22049. sideOrientation?: number;
  22050. frontUVs?: Vector4;
  22051. backUVs?: Vector4;
  22052. }): VertexData;
  22053. /**
  22054. * Creates the VertexData of the LineSystem
  22055. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22056. * - lines an array of lines, each line being an array of successive Vector3
  22057. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22058. * @returns the VertexData of the LineSystem
  22059. */
  22060. static CreateLineSystem(options: {
  22061. lines: Vector3[][];
  22062. colors?: Nullable<Color4[][]>;
  22063. }): VertexData;
  22064. /**
  22065. * Create the VertexData for a DashedLines
  22066. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22067. * - points an array successive Vector3
  22068. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22069. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22070. * - dashNb the intended total number of dashes, optional, default 200
  22071. * @returns the VertexData for the DashedLines
  22072. */
  22073. static CreateDashedLines(options: {
  22074. points: Vector3[];
  22075. dashSize?: number;
  22076. gapSize?: number;
  22077. dashNb?: number;
  22078. }): VertexData;
  22079. /**
  22080. * Creates the VertexData for a Ground
  22081. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22082. * - width the width (x direction) of the ground, optional, default 1
  22083. * - height the height (z direction) of the ground, optional, default 1
  22084. * - subdivisions the number of subdivisions per side, optional, default 1
  22085. * @returns the VertexData of the Ground
  22086. */
  22087. static CreateGround(options: {
  22088. width?: number;
  22089. height?: number;
  22090. subdivisions?: number;
  22091. subdivisionsX?: number;
  22092. subdivisionsY?: number;
  22093. }): VertexData;
  22094. /**
  22095. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22096. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22097. * * xmin the ground minimum X coordinate, optional, default -1
  22098. * * zmin the ground minimum Z coordinate, optional, default -1
  22099. * * xmax the ground maximum X coordinate, optional, default 1
  22100. * * zmax the ground maximum Z coordinate, optional, default 1
  22101. * * 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}
  22102. * * 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}
  22103. * @returns the VertexData of the TiledGround
  22104. */
  22105. static CreateTiledGround(options: {
  22106. xmin: number;
  22107. zmin: number;
  22108. xmax: number;
  22109. zmax: number;
  22110. subdivisions?: {
  22111. w: number;
  22112. h: number;
  22113. };
  22114. precision?: {
  22115. w: number;
  22116. h: number;
  22117. };
  22118. }): VertexData;
  22119. /**
  22120. * Creates the VertexData of the Ground designed from a heightmap
  22121. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22122. * * width the width (x direction) of the ground
  22123. * * height the height (z direction) of the ground
  22124. * * subdivisions the number of subdivisions per side
  22125. * * minHeight the minimum altitude on the ground, optional, default 0
  22126. * * maxHeight the maximum altitude on the ground, optional default 1
  22127. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22128. * * buffer the array holding the image color data
  22129. * * bufferWidth the width of image
  22130. * * bufferHeight the height of image
  22131. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22132. * @returns the VertexData of the Ground designed from a heightmap
  22133. */
  22134. static CreateGroundFromHeightMap(options: {
  22135. width: number;
  22136. height: number;
  22137. subdivisions: number;
  22138. minHeight: number;
  22139. maxHeight: number;
  22140. colorFilter: Color3;
  22141. buffer: Uint8Array;
  22142. bufferWidth: number;
  22143. bufferHeight: number;
  22144. alphaFilter: number;
  22145. }): VertexData;
  22146. /**
  22147. * Creates the VertexData for a Plane
  22148. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22149. * * size sets the width and height of the plane to the value of size, optional default 1
  22150. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22151. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22153. * * 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)
  22154. * * 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)
  22155. * @returns the VertexData of the box
  22156. */
  22157. static CreatePlane(options: {
  22158. size?: number;
  22159. width?: number;
  22160. height?: number;
  22161. sideOrientation?: number;
  22162. frontUVs?: Vector4;
  22163. backUVs?: Vector4;
  22164. }): VertexData;
  22165. /**
  22166. * Creates the VertexData of the Disc or regular Polygon
  22167. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22168. * * radius the radius of the disc, optional default 0.5
  22169. * * tessellation the number of polygon sides, optional, default 64
  22170. * * 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
  22171. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22172. * * 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)
  22173. * * 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)
  22174. * @returns the VertexData of the box
  22175. */
  22176. static CreateDisc(options: {
  22177. radius?: number;
  22178. tessellation?: number;
  22179. arc?: number;
  22180. sideOrientation?: number;
  22181. frontUVs?: Vector4;
  22182. backUVs?: Vector4;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22186. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22187. * @param polygon a mesh built from polygonTriangulation.build()
  22188. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22189. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22190. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22191. * @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)
  22192. * @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)
  22193. * @returns the VertexData of the Polygon
  22194. */
  22195. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22196. /**
  22197. * Creates the VertexData of the IcoSphere
  22198. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22199. * * radius the radius of the IcoSphere, optional default 1
  22200. * * radiusX allows stretching in the x direction, optional, default radius
  22201. * * radiusY allows stretching in the y direction, optional, default radius
  22202. * * radiusZ allows stretching in the z direction, optional, default radius
  22203. * * flat when true creates a flat shaded mesh, optional, default true
  22204. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22206. * * 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)
  22207. * * 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)
  22208. * @returns the VertexData of the IcoSphere
  22209. */
  22210. static CreateIcoSphere(options: {
  22211. radius?: number;
  22212. radiusX?: number;
  22213. radiusY?: number;
  22214. radiusZ?: number;
  22215. flat?: boolean;
  22216. subdivisions?: number;
  22217. sideOrientation?: number;
  22218. frontUVs?: Vector4;
  22219. backUVs?: Vector4;
  22220. }): VertexData;
  22221. /**
  22222. * Creates the VertexData for a Polyhedron
  22223. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22224. * * type provided types are:
  22225. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22226. * * 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)
  22227. * * size the size of the IcoSphere, optional default 1
  22228. * * sizeX allows stretching in the x direction, optional, default size
  22229. * * sizeY allows stretching in the y direction, optional, default size
  22230. * * sizeZ allows stretching in the z direction, optional, default size
  22231. * * 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
  22232. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22233. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22234. * * flat when true creates a flat shaded mesh, optional, default true
  22235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22237. * * 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)
  22238. * * 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)
  22239. * @returns the VertexData of the Polyhedron
  22240. */
  22241. static CreatePolyhedron(options: {
  22242. type?: number;
  22243. size?: number;
  22244. sizeX?: number;
  22245. sizeY?: number;
  22246. sizeZ?: number;
  22247. custom?: any;
  22248. faceUV?: Vector4[];
  22249. faceColors?: Color4[];
  22250. flat?: boolean;
  22251. sideOrientation?: number;
  22252. frontUVs?: Vector4;
  22253. backUVs?: Vector4;
  22254. }): VertexData;
  22255. /**
  22256. * Creates the VertexData for a TorusKnot
  22257. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22258. * * radius the radius of the torus knot, optional, default 2
  22259. * * tube the thickness of the tube, optional, default 0.5
  22260. * * radialSegments the number of sides on each tube segments, optional, default 32
  22261. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22262. * * p the number of windings around the z axis, optional, default 2
  22263. * * q the number of windings around the x axis, optional, default 3
  22264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22265. * * 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)
  22266. * * 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)
  22267. * @returns the VertexData of the Torus Knot
  22268. */
  22269. static CreateTorusKnot(options: {
  22270. radius?: number;
  22271. tube?: number;
  22272. radialSegments?: number;
  22273. tubularSegments?: number;
  22274. p?: number;
  22275. q?: number;
  22276. sideOrientation?: number;
  22277. frontUVs?: Vector4;
  22278. backUVs?: Vector4;
  22279. }): VertexData;
  22280. /**
  22281. * Compute normals for given positions and indices
  22282. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22283. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22284. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22285. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22286. * * facetNormals : optional array of facet normals (vector3)
  22287. * * facetPositions : optional array of facet positions (vector3)
  22288. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22289. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22290. * * bInfo : optional bounding info, required for facetPartitioning computation
  22291. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22292. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22293. * * useRightHandedSystem: optional boolean to for right handed system computation
  22294. * * depthSort : optional boolean to enable the facet depth sort computation
  22295. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22296. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22297. */
  22298. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22299. facetNormals?: any;
  22300. facetPositions?: any;
  22301. facetPartitioning?: any;
  22302. ratio?: number;
  22303. bInfo?: any;
  22304. bbSize?: Vector3;
  22305. subDiv?: any;
  22306. useRightHandedSystem?: boolean;
  22307. depthSort?: boolean;
  22308. distanceTo?: Vector3;
  22309. depthSortedFacets?: any;
  22310. }): void;
  22311. /** @hidden */
  22312. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22313. /**
  22314. * Applies VertexData created from the imported parameters to the geometry
  22315. * @param parsedVertexData the parsed data from an imported file
  22316. * @param geometry the geometry to apply the VertexData to
  22317. */
  22318. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22319. }
  22320. }
  22321. declare module "babylonjs/Morph/morphTarget" {
  22322. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22323. import { Observable } from "babylonjs/Misc/observable";
  22324. import { Nullable, FloatArray } from "babylonjs/types";
  22325. import { Scene } from "babylonjs/scene";
  22326. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22327. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22328. /**
  22329. * Defines a target to use with MorphTargetManager
  22330. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22331. */
  22332. export class MorphTarget implements IAnimatable {
  22333. /** defines the name of the target */
  22334. name: string;
  22335. /**
  22336. * Gets or sets the list of animations
  22337. */
  22338. animations: import("babylonjs/Animations/animation").Animation[];
  22339. private _scene;
  22340. private _positions;
  22341. private _normals;
  22342. private _tangents;
  22343. private _uvs;
  22344. private _influence;
  22345. /**
  22346. * Observable raised when the influence changes
  22347. */
  22348. onInfluenceChanged: Observable<boolean>;
  22349. /** @hidden */
  22350. _onDataLayoutChanged: Observable<void>;
  22351. /**
  22352. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22353. */
  22354. influence: number;
  22355. /**
  22356. * Gets or sets the id of the morph Target
  22357. */
  22358. id: string;
  22359. private _animationPropertiesOverride;
  22360. /**
  22361. * Gets or sets the animation properties override
  22362. */
  22363. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22364. /**
  22365. * Creates a new MorphTarget
  22366. * @param name defines the name of the target
  22367. * @param influence defines the influence to use
  22368. * @param scene defines the scene the morphtarget belongs to
  22369. */
  22370. constructor(
  22371. /** defines the name of the target */
  22372. name: string, influence?: number, scene?: Nullable<Scene>);
  22373. /**
  22374. * Gets a boolean defining if the target contains position data
  22375. */
  22376. readonly hasPositions: boolean;
  22377. /**
  22378. * Gets a boolean defining if the target contains normal data
  22379. */
  22380. readonly hasNormals: boolean;
  22381. /**
  22382. * Gets a boolean defining if the target contains tangent data
  22383. */
  22384. readonly hasTangents: boolean;
  22385. /**
  22386. * Gets a boolean defining if the target contains texture coordinates data
  22387. */
  22388. readonly hasUVs: boolean;
  22389. /**
  22390. * Affects position data to this target
  22391. * @param data defines the position data to use
  22392. */
  22393. setPositions(data: Nullable<FloatArray>): void;
  22394. /**
  22395. * Gets the position data stored in this target
  22396. * @returns a FloatArray containing the position data (or null if not present)
  22397. */
  22398. getPositions(): Nullable<FloatArray>;
  22399. /**
  22400. * Affects normal data to this target
  22401. * @param data defines the normal data to use
  22402. */
  22403. setNormals(data: Nullable<FloatArray>): void;
  22404. /**
  22405. * Gets the normal data stored in this target
  22406. * @returns a FloatArray containing the normal data (or null if not present)
  22407. */
  22408. getNormals(): Nullable<FloatArray>;
  22409. /**
  22410. * Affects tangent data to this target
  22411. * @param data defines the tangent data to use
  22412. */
  22413. setTangents(data: Nullable<FloatArray>): void;
  22414. /**
  22415. * Gets the tangent data stored in this target
  22416. * @returns a FloatArray containing the tangent data (or null if not present)
  22417. */
  22418. getTangents(): Nullable<FloatArray>;
  22419. /**
  22420. * Affects texture coordinates data to this target
  22421. * @param data defines the texture coordinates data to use
  22422. */
  22423. setUVs(data: Nullable<FloatArray>): void;
  22424. /**
  22425. * Gets the texture coordinates data stored in this target
  22426. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22427. */
  22428. getUVs(): Nullable<FloatArray>;
  22429. /**
  22430. * Serializes the current target into a Serialization object
  22431. * @returns the serialized object
  22432. */
  22433. serialize(): any;
  22434. /**
  22435. * Returns the string "MorphTarget"
  22436. * @returns "MorphTarget"
  22437. */
  22438. getClassName(): string;
  22439. /**
  22440. * Creates a new target from serialized data
  22441. * @param serializationObject defines the serialized data to use
  22442. * @returns a new MorphTarget
  22443. */
  22444. static Parse(serializationObject: any): MorphTarget;
  22445. /**
  22446. * Creates a MorphTarget from mesh data
  22447. * @param mesh defines the source mesh
  22448. * @param name defines the name to use for the new target
  22449. * @param influence defines the influence to attach to the target
  22450. * @returns a new MorphTarget
  22451. */
  22452. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22453. }
  22454. }
  22455. declare module "babylonjs/Morph/morphTargetManager" {
  22456. import { Nullable } from "babylonjs/types";
  22457. import { Scene } from "babylonjs/scene";
  22458. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22459. /**
  22460. * This class is used to deform meshes using morphing between different targets
  22461. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22462. */
  22463. export class MorphTargetManager {
  22464. private _targets;
  22465. private _targetInfluenceChangedObservers;
  22466. private _targetDataLayoutChangedObservers;
  22467. private _activeTargets;
  22468. private _scene;
  22469. private _influences;
  22470. private _supportsNormals;
  22471. private _supportsTangents;
  22472. private _supportsUVs;
  22473. private _vertexCount;
  22474. private _uniqueId;
  22475. private _tempInfluences;
  22476. /**
  22477. * Gets or sets a boolean indicating if normals must be morphed
  22478. */
  22479. enableNormalMorphing: boolean;
  22480. /**
  22481. * Gets or sets a boolean indicating if tangents must be morphed
  22482. */
  22483. enableTangentMorphing: boolean;
  22484. /**
  22485. * Gets or sets a boolean indicating if UV must be morphed
  22486. */
  22487. enableUVMorphing: boolean;
  22488. /**
  22489. * Creates a new MorphTargetManager
  22490. * @param scene defines the current scene
  22491. */
  22492. constructor(scene?: Nullable<Scene>);
  22493. /**
  22494. * Gets the unique ID of this manager
  22495. */
  22496. readonly uniqueId: number;
  22497. /**
  22498. * Gets the number of vertices handled by this manager
  22499. */
  22500. readonly vertexCount: number;
  22501. /**
  22502. * Gets a boolean indicating if this manager supports morphing of normals
  22503. */
  22504. readonly supportsNormals: boolean;
  22505. /**
  22506. * Gets a boolean indicating if this manager supports morphing of tangents
  22507. */
  22508. readonly supportsTangents: boolean;
  22509. /**
  22510. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22511. */
  22512. readonly supportsUVs: boolean;
  22513. /**
  22514. * Gets the number of targets stored in this manager
  22515. */
  22516. readonly numTargets: number;
  22517. /**
  22518. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22519. */
  22520. readonly numInfluencers: number;
  22521. /**
  22522. * Gets the list of influences (one per target)
  22523. */
  22524. readonly influences: Float32Array;
  22525. /**
  22526. * Gets the active target at specified index. An active target is a target with an influence > 0
  22527. * @param index defines the index to check
  22528. * @returns the requested target
  22529. */
  22530. getActiveTarget(index: number): MorphTarget;
  22531. /**
  22532. * Gets the target at specified index
  22533. * @param index defines the index to check
  22534. * @returns the requested target
  22535. */
  22536. getTarget(index: number): MorphTarget;
  22537. /**
  22538. * Add a new target to this manager
  22539. * @param target defines the target to add
  22540. */
  22541. addTarget(target: MorphTarget): void;
  22542. /**
  22543. * Removes a target from the manager
  22544. * @param target defines the target to remove
  22545. */
  22546. removeTarget(target: MorphTarget): void;
  22547. /**
  22548. * Serializes the current manager into a Serialization object
  22549. * @returns the serialized object
  22550. */
  22551. serialize(): any;
  22552. private _syncActiveTargets;
  22553. /**
  22554. * Syncrhonize the targets with all the meshes using this morph target manager
  22555. */
  22556. synchronize(): void;
  22557. /**
  22558. * Creates a new MorphTargetManager from serialized data
  22559. * @param serializationObject defines the serialized data
  22560. * @param scene defines the hosting scene
  22561. * @returns the new MorphTargetManager
  22562. */
  22563. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22564. }
  22565. }
  22566. declare module "babylonjs/Meshes/meshLODLevel" {
  22567. import { Mesh } from "babylonjs/Meshes/mesh";
  22568. import { Nullable } from "babylonjs/types";
  22569. /**
  22570. * Class used to represent a specific level of detail of a mesh
  22571. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22572. */
  22573. export class MeshLODLevel {
  22574. /** Defines the distance where this level should star being displayed */
  22575. distance: number;
  22576. /** Defines the mesh to use to render this level */
  22577. mesh: Nullable<Mesh>;
  22578. /**
  22579. * Creates a new LOD level
  22580. * @param distance defines the distance where this level should star being displayed
  22581. * @param mesh defines the mesh to use to render this level
  22582. */
  22583. constructor(
  22584. /** Defines the distance where this level should star being displayed */
  22585. distance: number,
  22586. /** Defines the mesh to use to render this level */
  22587. mesh: Nullable<Mesh>);
  22588. }
  22589. }
  22590. declare module "babylonjs/Meshes/groundMesh" {
  22591. import { Scene } from "babylonjs/scene";
  22592. import { Vector3 } from "babylonjs/Maths/math.vector";
  22593. import { Mesh } from "babylonjs/Meshes/mesh";
  22594. /**
  22595. * Mesh representing the gorund
  22596. */
  22597. export class GroundMesh extends Mesh {
  22598. /** If octree should be generated */
  22599. generateOctree: boolean;
  22600. private _heightQuads;
  22601. /** @hidden */
  22602. _subdivisionsX: number;
  22603. /** @hidden */
  22604. _subdivisionsY: number;
  22605. /** @hidden */
  22606. _width: number;
  22607. /** @hidden */
  22608. _height: number;
  22609. /** @hidden */
  22610. _minX: number;
  22611. /** @hidden */
  22612. _maxX: number;
  22613. /** @hidden */
  22614. _minZ: number;
  22615. /** @hidden */
  22616. _maxZ: number;
  22617. constructor(name: string, scene: Scene);
  22618. /**
  22619. * "GroundMesh"
  22620. * @returns "GroundMesh"
  22621. */
  22622. getClassName(): string;
  22623. /**
  22624. * The minimum of x and y subdivisions
  22625. */
  22626. readonly subdivisions: number;
  22627. /**
  22628. * X subdivisions
  22629. */
  22630. readonly subdivisionsX: number;
  22631. /**
  22632. * Y subdivisions
  22633. */
  22634. readonly subdivisionsY: number;
  22635. /**
  22636. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22637. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22638. * @param chunksCount the number of subdivisions for x and y
  22639. * @param octreeBlocksSize (Default: 32)
  22640. */
  22641. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22642. /**
  22643. * Returns a height (y) value in the Worl system :
  22644. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22645. * @param x x coordinate
  22646. * @param z z coordinate
  22647. * @returns the ground y position if (x, z) are outside the ground surface.
  22648. */
  22649. getHeightAtCoordinates(x: number, z: number): number;
  22650. /**
  22651. * Returns a normalized vector (Vector3) orthogonal to the ground
  22652. * at the ground coordinates (x, z) expressed in the World system.
  22653. * @param x x coordinate
  22654. * @param z z coordinate
  22655. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22656. */
  22657. getNormalAtCoordinates(x: number, z: number): Vector3;
  22658. /**
  22659. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22660. * at the ground coordinates (x, z) expressed in the World system.
  22661. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22662. * @param x x coordinate
  22663. * @param z z coordinate
  22664. * @param ref vector to store the result
  22665. * @returns the GroundMesh.
  22666. */
  22667. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22668. /**
  22669. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22670. * if the ground has been updated.
  22671. * This can be used in the render loop.
  22672. * @returns the GroundMesh.
  22673. */
  22674. updateCoordinateHeights(): GroundMesh;
  22675. private _getFacetAt;
  22676. private _initHeightQuads;
  22677. private _computeHeightQuads;
  22678. /**
  22679. * Serializes this ground mesh
  22680. * @param serializationObject object to write serialization to
  22681. */
  22682. serialize(serializationObject: any): void;
  22683. /**
  22684. * Parses a serialized ground mesh
  22685. * @param parsedMesh the serialized mesh
  22686. * @param scene the scene to create the ground mesh in
  22687. * @returns the created ground mesh
  22688. */
  22689. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22690. }
  22691. }
  22692. declare module "babylonjs/Physics/physicsJoint" {
  22693. import { Vector3 } from "babylonjs/Maths/math.vector";
  22694. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22695. /**
  22696. * Interface for Physics-Joint data
  22697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22698. */
  22699. export interface PhysicsJointData {
  22700. /**
  22701. * The main pivot of the joint
  22702. */
  22703. mainPivot?: Vector3;
  22704. /**
  22705. * The connected pivot of the joint
  22706. */
  22707. connectedPivot?: Vector3;
  22708. /**
  22709. * The main axis of the joint
  22710. */
  22711. mainAxis?: Vector3;
  22712. /**
  22713. * The connected axis of the joint
  22714. */
  22715. connectedAxis?: Vector3;
  22716. /**
  22717. * The collision of the joint
  22718. */
  22719. collision?: boolean;
  22720. /**
  22721. * Native Oimo/Cannon/Energy data
  22722. */
  22723. nativeParams?: any;
  22724. }
  22725. /**
  22726. * This is a holder class for the physics joint created by the physics plugin
  22727. * It holds a set of functions to control the underlying joint
  22728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22729. */
  22730. export class PhysicsJoint {
  22731. /**
  22732. * The type of the physics joint
  22733. */
  22734. type: number;
  22735. /**
  22736. * The data for the physics joint
  22737. */
  22738. jointData: PhysicsJointData;
  22739. private _physicsJoint;
  22740. protected _physicsPlugin: IPhysicsEnginePlugin;
  22741. /**
  22742. * Initializes the physics joint
  22743. * @param type The type of the physics joint
  22744. * @param jointData The data for the physics joint
  22745. */
  22746. constructor(
  22747. /**
  22748. * The type of the physics joint
  22749. */
  22750. type: number,
  22751. /**
  22752. * The data for the physics joint
  22753. */
  22754. jointData: PhysicsJointData);
  22755. /**
  22756. * Gets the physics joint
  22757. */
  22758. /**
  22759. * Sets the physics joint
  22760. */
  22761. physicsJoint: any;
  22762. /**
  22763. * Sets the physics plugin
  22764. */
  22765. physicsPlugin: IPhysicsEnginePlugin;
  22766. /**
  22767. * Execute a function that is physics-plugin specific.
  22768. * @param {Function} func the function that will be executed.
  22769. * It accepts two parameters: the physics world and the physics joint
  22770. */
  22771. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22772. /**
  22773. * Distance-Joint type
  22774. */
  22775. static DistanceJoint: number;
  22776. /**
  22777. * Hinge-Joint type
  22778. */
  22779. static HingeJoint: number;
  22780. /**
  22781. * Ball-and-Socket joint type
  22782. */
  22783. static BallAndSocketJoint: number;
  22784. /**
  22785. * Wheel-Joint type
  22786. */
  22787. static WheelJoint: number;
  22788. /**
  22789. * Slider-Joint type
  22790. */
  22791. static SliderJoint: number;
  22792. /**
  22793. * Prismatic-Joint type
  22794. */
  22795. static PrismaticJoint: number;
  22796. /**
  22797. * Universal-Joint type
  22798. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22799. */
  22800. static UniversalJoint: number;
  22801. /**
  22802. * Hinge-Joint 2 type
  22803. */
  22804. static Hinge2Joint: number;
  22805. /**
  22806. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  22807. */
  22808. static PointToPointJoint: number;
  22809. /**
  22810. * Spring-Joint type
  22811. */
  22812. static SpringJoint: number;
  22813. /**
  22814. * Lock-Joint type
  22815. */
  22816. static LockJoint: number;
  22817. }
  22818. /**
  22819. * A class representing a physics distance joint
  22820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22821. */
  22822. export class DistanceJoint extends PhysicsJoint {
  22823. /**
  22824. *
  22825. * @param jointData The data for the Distance-Joint
  22826. */
  22827. constructor(jointData: DistanceJointData);
  22828. /**
  22829. * Update the predefined distance.
  22830. * @param maxDistance The maximum preferred distance
  22831. * @param minDistance The minimum preferred distance
  22832. */
  22833. updateDistance(maxDistance: number, minDistance?: number): void;
  22834. }
  22835. /**
  22836. * Represents a Motor-Enabled Joint
  22837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22838. */
  22839. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  22840. /**
  22841. * Initializes the Motor-Enabled Joint
  22842. * @param type The type of the joint
  22843. * @param jointData The physica joint data for the joint
  22844. */
  22845. constructor(type: number, jointData: PhysicsJointData);
  22846. /**
  22847. * Set the motor values.
  22848. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22849. * @param force the force to apply
  22850. * @param maxForce max force for this motor.
  22851. */
  22852. setMotor(force?: number, maxForce?: number): void;
  22853. /**
  22854. * Set the motor's limits.
  22855. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22856. * @param upperLimit The upper limit of the motor
  22857. * @param lowerLimit The lower limit of the motor
  22858. */
  22859. setLimit(upperLimit: number, lowerLimit?: number): void;
  22860. }
  22861. /**
  22862. * This class represents a single physics Hinge-Joint
  22863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22864. */
  22865. export class HingeJoint extends MotorEnabledJoint {
  22866. /**
  22867. * Initializes the Hinge-Joint
  22868. * @param jointData The joint data for the Hinge-Joint
  22869. */
  22870. constructor(jointData: PhysicsJointData);
  22871. /**
  22872. * Set the motor values.
  22873. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22874. * @param {number} force the force to apply
  22875. * @param {number} maxForce max force for this motor.
  22876. */
  22877. setMotor(force?: number, maxForce?: number): void;
  22878. /**
  22879. * Set the motor's limits.
  22880. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22881. * @param upperLimit The upper limit of the motor
  22882. * @param lowerLimit The lower limit of the motor
  22883. */
  22884. setLimit(upperLimit: number, lowerLimit?: number): void;
  22885. }
  22886. /**
  22887. * This class represents a dual hinge physics joint (same as wheel joint)
  22888. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22889. */
  22890. export class Hinge2Joint extends MotorEnabledJoint {
  22891. /**
  22892. * Initializes the Hinge2-Joint
  22893. * @param jointData The joint data for the Hinge2-Joint
  22894. */
  22895. constructor(jointData: PhysicsJointData);
  22896. /**
  22897. * Set the motor values.
  22898. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22899. * @param {number} targetSpeed the speed the motor is to reach
  22900. * @param {number} maxForce max force for this motor.
  22901. * @param {motorIndex} the motor's index, 0 or 1.
  22902. */
  22903. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  22904. /**
  22905. * Set the motor limits.
  22906. * Attention, this function is plugin specific. Engines won't react 100% the same.
  22907. * @param {number} upperLimit the upper limit
  22908. * @param {number} lowerLimit lower limit
  22909. * @param {motorIndex} the motor's index, 0 or 1.
  22910. */
  22911. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22912. }
  22913. /**
  22914. * Interface for a motor enabled joint
  22915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22916. */
  22917. export interface IMotorEnabledJoint {
  22918. /**
  22919. * Physics joint
  22920. */
  22921. physicsJoint: any;
  22922. /**
  22923. * Sets the motor of the motor-enabled joint
  22924. * @param force The force of the motor
  22925. * @param maxForce The maximum force of the motor
  22926. * @param motorIndex The index of the motor
  22927. */
  22928. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22929. /**
  22930. * Sets the limit of the motor
  22931. * @param upperLimit The upper limit of the motor
  22932. * @param lowerLimit The lower limit of the motor
  22933. * @param motorIndex The index of the motor
  22934. */
  22935. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22936. }
  22937. /**
  22938. * Joint data for a Distance-Joint
  22939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22940. */
  22941. export interface DistanceJointData extends PhysicsJointData {
  22942. /**
  22943. * Max distance the 2 joint objects can be apart
  22944. */
  22945. maxDistance: number;
  22946. }
  22947. /**
  22948. * Joint data from a spring joint
  22949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22950. */
  22951. export interface SpringJointData extends PhysicsJointData {
  22952. /**
  22953. * Length of the spring
  22954. */
  22955. length: number;
  22956. /**
  22957. * Stiffness of the spring
  22958. */
  22959. stiffness: number;
  22960. /**
  22961. * Damping of the spring
  22962. */
  22963. damping: number;
  22964. /** this callback will be called when applying the force to the impostors. */
  22965. forceApplicationCallback: () => void;
  22966. }
  22967. }
  22968. declare module "babylonjs/Physics/physicsRaycastResult" {
  22969. import { Vector3 } from "babylonjs/Maths/math.vector";
  22970. /**
  22971. * Holds the data for the raycast result
  22972. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22973. */
  22974. export class PhysicsRaycastResult {
  22975. private _hasHit;
  22976. private _hitDistance;
  22977. private _hitNormalWorld;
  22978. private _hitPointWorld;
  22979. private _rayFromWorld;
  22980. private _rayToWorld;
  22981. /**
  22982. * Gets if there was a hit
  22983. */
  22984. readonly hasHit: boolean;
  22985. /**
  22986. * Gets the distance from the hit
  22987. */
  22988. readonly hitDistance: number;
  22989. /**
  22990. * Gets the hit normal/direction in the world
  22991. */
  22992. readonly hitNormalWorld: Vector3;
  22993. /**
  22994. * Gets the hit point in the world
  22995. */
  22996. readonly hitPointWorld: Vector3;
  22997. /**
  22998. * Gets the ray "start point" of the ray in the world
  22999. */
  23000. readonly rayFromWorld: Vector3;
  23001. /**
  23002. * Gets the ray "end point" of the ray in the world
  23003. */
  23004. readonly rayToWorld: Vector3;
  23005. /**
  23006. * Sets the hit data (normal & point in world space)
  23007. * @param hitNormalWorld defines the normal in world space
  23008. * @param hitPointWorld defines the point in world space
  23009. */
  23010. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23011. /**
  23012. * Sets the distance from the start point to the hit point
  23013. * @param distance
  23014. */
  23015. setHitDistance(distance: number): void;
  23016. /**
  23017. * Calculates the distance manually
  23018. */
  23019. calculateHitDistance(): void;
  23020. /**
  23021. * Resets all the values to default
  23022. * @param from The from point on world space
  23023. * @param to The to point on world space
  23024. */
  23025. reset(from?: Vector3, to?: Vector3): void;
  23026. }
  23027. /**
  23028. * Interface for the size containing width and height
  23029. */
  23030. interface IXYZ {
  23031. /**
  23032. * X
  23033. */
  23034. x: number;
  23035. /**
  23036. * Y
  23037. */
  23038. y: number;
  23039. /**
  23040. * Z
  23041. */
  23042. z: number;
  23043. }
  23044. }
  23045. declare module "babylonjs/Physics/IPhysicsEngine" {
  23046. import { Nullable } from "babylonjs/types";
  23047. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23049. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23050. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23051. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23052. /**
  23053. * Interface used to describe a physics joint
  23054. */
  23055. export interface PhysicsImpostorJoint {
  23056. /** Defines the main impostor to which the joint is linked */
  23057. mainImpostor: PhysicsImpostor;
  23058. /** Defines the impostor that is connected to the main impostor using this joint */
  23059. connectedImpostor: PhysicsImpostor;
  23060. /** Defines the joint itself */
  23061. joint: PhysicsJoint;
  23062. }
  23063. /** @hidden */
  23064. export interface IPhysicsEnginePlugin {
  23065. world: any;
  23066. name: string;
  23067. setGravity(gravity: Vector3): void;
  23068. setTimeStep(timeStep: number): void;
  23069. getTimeStep(): number;
  23070. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23071. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23072. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23073. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23074. removePhysicsBody(impostor: PhysicsImpostor): void;
  23075. generateJoint(joint: PhysicsImpostorJoint): void;
  23076. removeJoint(joint: PhysicsImpostorJoint): void;
  23077. isSupported(): boolean;
  23078. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23079. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23080. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23081. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23082. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23083. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23084. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23085. getBodyMass(impostor: PhysicsImpostor): number;
  23086. getBodyFriction(impostor: PhysicsImpostor): number;
  23087. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23088. getBodyRestitution(impostor: PhysicsImpostor): number;
  23089. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23090. getBodyPressure?(impostor: PhysicsImpostor): number;
  23091. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23092. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23093. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23094. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23095. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23096. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23097. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23098. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23099. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23100. sleepBody(impostor: PhysicsImpostor): void;
  23101. wakeUpBody(impostor: PhysicsImpostor): void;
  23102. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23103. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23104. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23105. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23106. getRadius(impostor: PhysicsImpostor): number;
  23107. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23108. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23109. dispose(): void;
  23110. }
  23111. /**
  23112. * Interface used to define a physics engine
  23113. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23114. */
  23115. export interface IPhysicsEngine {
  23116. /**
  23117. * Gets the gravity vector used by the simulation
  23118. */
  23119. gravity: Vector3;
  23120. /**
  23121. * Sets the gravity vector used by the simulation
  23122. * @param gravity defines the gravity vector to use
  23123. */
  23124. setGravity(gravity: Vector3): void;
  23125. /**
  23126. * Set the time step of the physics engine.
  23127. * Default is 1/60.
  23128. * To slow it down, enter 1/600 for example.
  23129. * To speed it up, 1/30
  23130. * @param newTimeStep the new timestep to apply to this world.
  23131. */
  23132. setTimeStep(newTimeStep: number): void;
  23133. /**
  23134. * Get the time step of the physics engine.
  23135. * @returns the current time step
  23136. */
  23137. getTimeStep(): number;
  23138. /**
  23139. * Release all resources
  23140. */
  23141. dispose(): void;
  23142. /**
  23143. * Gets the name of the current physics plugin
  23144. * @returns the name of the plugin
  23145. */
  23146. getPhysicsPluginName(): string;
  23147. /**
  23148. * Adding a new impostor for the impostor tracking.
  23149. * This will be done by the impostor itself.
  23150. * @param impostor the impostor to add
  23151. */
  23152. addImpostor(impostor: PhysicsImpostor): void;
  23153. /**
  23154. * Remove an impostor from the engine.
  23155. * This impostor and its mesh will not longer be updated by the physics engine.
  23156. * @param impostor the impostor to remove
  23157. */
  23158. removeImpostor(impostor: PhysicsImpostor): void;
  23159. /**
  23160. * Add a joint to the physics engine
  23161. * @param mainImpostor defines the main impostor to which the joint is added.
  23162. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23163. * @param joint defines the joint that will connect both impostors.
  23164. */
  23165. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23166. /**
  23167. * Removes a joint from the simulation
  23168. * @param mainImpostor defines the impostor used with the joint
  23169. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23170. * @param joint defines the joint to remove
  23171. */
  23172. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23173. /**
  23174. * Gets the current plugin used to run the simulation
  23175. * @returns current plugin
  23176. */
  23177. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23178. /**
  23179. * Gets the list of physic impostors
  23180. * @returns an array of PhysicsImpostor
  23181. */
  23182. getImpostors(): Array<PhysicsImpostor>;
  23183. /**
  23184. * Gets the impostor for a physics enabled object
  23185. * @param object defines the object impersonated by the impostor
  23186. * @returns the PhysicsImpostor or null if not found
  23187. */
  23188. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23189. /**
  23190. * Gets the impostor for a physics body object
  23191. * @param body defines physics body used by the impostor
  23192. * @returns the PhysicsImpostor or null if not found
  23193. */
  23194. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23195. /**
  23196. * Does a raycast in the physics world
  23197. * @param from when should the ray start?
  23198. * @param to when should the ray end?
  23199. * @returns PhysicsRaycastResult
  23200. */
  23201. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23202. /**
  23203. * Called by the scene. No need to call it.
  23204. * @param delta defines the timespam between frames
  23205. */
  23206. _step(delta: number): void;
  23207. }
  23208. }
  23209. declare module "babylonjs/Physics/physicsImpostor" {
  23210. import { Nullable, IndicesArray } from "babylonjs/types";
  23211. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23212. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23214. import { Scene } from "babylonjs/scene";
  23215. import { Bone } from "babylonjs/Bones/bone";
  23216. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23217. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23218. import { Space } from "babylonjs/Maths/math.axis";
  23219. /**
  23220. * The interface for the physics imposter parameters
  23221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23222. */
  23223. export interface PhysicsImpostorParameters {
  23224. /**
  23225. * The mass of the physics imposter
  23226. */
  23227. mass: number;
  23228. /**
  23229. * The friction of the physics imposter
  23230. */
  23231. friction?: number;
  23232. /**
  23233. * The coefficient of restitution of the physics imposter
  23234. */
  23235. restitution?: number;
  23236. /**
  23237. * The native options of the physics imposter
  23238. */
  23239. nativeOptions?: any;
  23240. /**
  23241. * Specifies if the parent should be ignored
  23242. */
  23243. ignoreParent?: boolean;
  23244. /**
  23245. * Specifies if bi-directional transformations should be disabled
  23246. */
  23247. disableBidirectionalTransformation?: boolean;
  23248. /**
  23249. * The pressure inside the physics imposter, soft object only
  23250. */
  23251. pressure?: number;
  23252. /**
  23253. * The stiffness the physics imposter, soft object only
  23254. */
  23255. stiffness?: number;
  23256. /**
  23257. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23258. */
  23259. velocityIterations?: number;
  23260. /**
  23261. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23262. */
  23263. positionIterations?: number;
  23264. /**
  23265. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23266. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23267. * Add to fix multiple points
  23268. */
  23269. fixedPoints?: number;
  23270. /**
  23271. * The collision margin around a soft object
  23272. */
  23273. margin?: number;
  23274. /**
  23275. * The collision margin around a soft object
  23276. */
  23277. damping?: number;
  23278. /**
  23279. * The path for a rope based on an extrusion
  23280. */
  23281. path?: any;
  23282. /**
  23283. * The shape of an extrusion used for a rope based on an extrusion
  23284. */
  23285. shape?: any;
  23286. }
  23287. /**
  23288. * Interface for a physics-enabled object
  23289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23290. */
  23291. export interface IPhysicsEnabledObject {
  23292. /**
  23293. * The position of the physics-enabled object
  23294. */
  23295. position: Vector3;
  23296. /**
  23297. * The rotation of the physics-enabled object
  23298. */
  23299. rotationQuaternion: Nullable<Quaternion>;
  23300. /**
  23301. * The scale of the physics-enabled object
  23302. */
  23303. scaling: Vector3;
  23304. /**
  23305. * The rotation of the physics-enabled object
  23306. */
  23307. rotation?: Vector3;
  23308. /**
  23309. * The parent of the physics-enabled object
  23310. */
  23311. parent?: any;
  23312. /**
  23313. * The bounding info of the physics-enabled object
  23314. * @returns The bounding info of the physics-enabled object
  23315. */
  23316. getBoundingInfo(): BoundingInfo;
  23317. /**
  23318. * Computes the world matrix
  23319. * @param force Specifies if the world matrix should be computed by force
  23320. * @returns A world matrix
  23321. */
  23322. computeWorldMatrix(force: boolean): Matrix;
  23323. /**
  23324. * Gets the world matrix
  23325. * @returns A world matrix
  23326. */
  23327. getWorldMatrix?(): Matrix;
  23328. /**
  23329. * Gets the child meshes
  23330. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23331. * @returns An array of abstract meshes
  23332. */
  23333. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23334. /**
  23335. * Gets the vertex data
  23336. * @param kind The type of vertex data
  23337. * @returns A nullable array of numbers, or a float32 array
  23338. */
  23339. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23340. /**
  23341. * Gets the indices from the mesh
  23342. * @returns A nullable array of index arrays
  23343. */
  23344. getIndices?(): Nullable<IndicesArray>;
  23345. /**
  23346. * Gets the scene from the mesh
  23347. * @returns the indices array or null
  23348. */
  23349. getScene?(): Scene;
  23350. /**
  23351. * Gets the absolute position from the mesh
  23352. * @returns the absolute position
  23353. */
  23354. getAbsolutePosition(): Vector3;
  23355. /**
  23356. * Gets the absolute pivot point from the mesh
  23357. * @returns the absolute pivot point
  23358. */
  23359. getAbsolutePivotPoint(): Vector3;
  23360. /**
  23361. * Rotates the mesh
  23362. * @param axis The axis of rotation
  23363. * @param amount The amount of rotation
  23364. * @param space The space of the rotation
  23365. * @returns The rotation transform node
  23366. */
  23367. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23368. /**
  23369. * Translates the mesh
  23370. * @param axis The axis of translation
  23371. * @param distance The distance of translation
  23372. * @param space The space of the translation
  23373. * @returns The transform node
  23374. */
  23375. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23376. /**
  23377. * Sets the absolute position of the mesh
  23378. * @param absolutePosition The absolute position of the mesh
  23379. * @returns The transform node
  23380. */
  23381. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23382. /**
  23383. * Gets the class name of the mesh
  23384. * @returns The class name
  23385. */
  23386. getClassName(): string;
  23387. }
  23388. /**
  23389. * Represents a physics imposter
  23390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23391. */
  23392. export class PhysicsImpostor {
  23393. /**
  23394. * The physics-enabled object used as the physics imposter
  23395. */
  23396. object: IPhysicsEnabledObject;
  23397. /**
  23398. * The type of the physics imposter
  23399. */
  23400. type: number;
  23401. private _options;
  23402. private _scene?;
  23403. /**
  23404. * The default object size of the imposter
  23405. */
  23406. static DEFAULT_OBJECT_SIZE: Vector3;
  23407. /**
  23408. * The identity quaternion of the imposter
  23409. */
  23410. static IDENTITY_QUATERNION: Quaternion;
  23411. /** @hidden */
  23412. _pluginData: any;
  23413. private _physicsEngine;
  23414. private _physicsBody;
  23415. private _bodyUpdateRequired;
  23416. private _onBeforePhysicsStepCallbacks;
  23417. private _onAfterPhysicsStepCallbacks;
  23418. /** @hidden */
  23419. _onPhysicsCollideCallbacks: Array<{
  23420. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23421. otherImpostors: Array<PhysicsImpostor>;
  23422. }>;
  23423. private _deltaPosition;
  23424. private _deltaRotation;
  23425. private _deltaRotationConjugated;
  23426. /** @hidden */
  23427. _isFromLine: boolean;
  23428. private _parent;
  23429. private _isDisposed;
  23430. private static _tmpVecs;
  23431. private static _tmpQuat;
  23432. /**
  23433. * Specifies if the physics imposter is disposed
  23434. */
  23435. readonly isDisposed: boolean;
  23436. /**
  23437. * Gets the mass of the physics imposter
  23438. */
  23439. mass: number;
  23440. /**
  23441. * Gets the coefficient of friction
  23442. */
  23443. /**
  23444. * Sets the coefficient of friction
  23445. */
  23446. friction: number;
  23447. /**
  23448. * Gets the coefficient of restitution
  23449. */
  23450. /**
  23451. * Sets the coefficient of restitution
  23452. */
  23453. restitution: number;
  23454. /**
  23455. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23456. */
  23457. /**
  23458. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23459. */
  23460. pressure: number;
  23461. /**
  23462. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23463. */
  23464. /**
  23465. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23466. */
  23467. stiffness: number;
  23468. /**
  23469. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23470. */
  23471. /**
  23472. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23473. */
  23474. velocityIterations: number;
  23475. /**
  23476. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23477. */
  23478. /**
  23479. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23480. */
  23481. positionIterations: number;
  23482. /**
  23483. * The unique id of the physics imposter
  23484. * set by the physics engine when adding this impostor to the array
  23485. */
  23486. uniqueId: number;
  23487. /**
  23488. * @hidden
  23489. */
  23490. soft: boolean;
  23491. /**
  23492. * @hidden
  23493. */
  23494. segments: number;
  23495. private _joints;
  23496. /**
  23497. * Initializes the physics imposter
  23498. * @param object The physics-enabled object used as the physics imposter
  23499. * @param type The type of the physics imposter
  23500. * @param _options The options for the physics imposter
  23501. * @param _scene The Babylon scene
  23502. */
  23503. constructor(
  23504. /**
  23505. * The physics-enabled object used as the physics imposter
  23506. */
  23507. object: IPhysicsEnabledObject,
  23508. /**
  23509. * The type of the physics imposter
  23510. */
  23511. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23512. /**
  23513. * This function will completly initialize this impostor.
  23514. * It will create a new body - but only if this mesh has no parent.
  23515. * If it has, this impostor will not be used other than to define the impostor
  23516. * of the child mesh.
  23517. * @hidden
  23518. */
  23519. _init(): void;
  23520. private _getPhysicsParent;
  23521. /**
  23522. * Should a new body be generated.
  23523. * @returns boolean specifying if body initialization is required
  23524. */
  23525. isBodyInitRequired(): boolean;
  23526. /**
  23527. * Sets the updated scaling
  23528. * @param updated Specifies if the scaling is updated
  23529. */
  23530. setScalingUpdated(): void;
  23531. /**
  23532. * Force a regeneration of this or the parent's impostor's body.
  23533. * Use under cautious - This will remove all joints already implemented.
  23534. */
  23535. forceUpdate(): void;
  23536. /**
  23537. * Gets the body that holds this impostor. Either its own, or its parent.
  23538. */
  23539. /**
  23540. * Set the physics body. Used mainly by the physics engine/plugin
  23541. */
  23542. physicsBody: any;
  23543. /**
  23544. * Get the parent of the physics imposter
  23545. * @returns Physics imposter or null
  23546. */
  23547. /**
  23548. * Sets the parent of the physics imposter
  23549. */
  23550. parent: Nullable<PhysicsImpostor>;
  23551. /**
  23552. * Resets the update flags
  23553. */
  23554. resetUpdateFlags(): void;
  23555. /**
  23556. * Gets the object extend size
  23557. * @returns the object extend size
  23558. */
  23559. getObjectExtendSize(): Vector3;
  23560. /**
  23561. * Gets the object center
  23562. * @returns The object center
  23563. */
  23564. getObjectCenter(): Vector3;
  23565. /**
  23566. * Get a specific parametes from the options parameter
  23567. * @param paramName The object parameter name
  23568. * @returns The object parameter
  23569. */
  23570. getParam(paramName: string): any;
  23571. /**
  23572. * Sets a specific parameter in the options given to the physics plugin
  23573. * @param paramName The parameter name
  23574. * @param value The value of the parameter
  23575. */
  23576. setParam(paramName: string, value: number): void;
  23577. /**
  23578. * Specifically change the body's mass option. Won't recreate the physics body object
  23579. * @param mass The mass of the physics imposter
  23580. */
  23581. setMass(mass: number): void;
  23582. /**
  23583. * Gets the linear velocity
  23584. * @returns linear velocity or null
  23585. */
  23586. getLinearVelocity(): Nullable<Vector3>;
  23587. /**
  23588. * Sets the linear velocity
  23589. * @param velocity linear velocity or null
  23590. */
  23591. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23592. /**
  23593. * Gets the angular velocity
  23594. * @returns angular velocity or null
  23595. */
  23596. getAngularVelocity(): Nullable<Vector3>;
  23597. /**
  23598. * Sets the angular velocity
  23599. * @param velocity The velocity or null
  23600. */
  23601. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23602. /**
  23603. * Execute a function with the physics plugin native code
  23604. * Provide a function the will have two variables - the world object and the physics body object
  23605. * @param func The function to execute with the physics plugin native code
  23606. */
  23607. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23608. /**
  23609. * Register 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. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23613. /**
  23614. * Unregister a function that will be executed before the physics world is stepping forward
  23615. * @param func The function to execute before the physics world is stepped forward
  23616. */
  23617. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23618. /**
  23619. * Register a function that will be executed after the physics step
  23620. * @param func The function to execute after physics step
  23621. */
  23622. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23623. /**
  23624. * Unregisters a function that will be executed after the physics step
  23625. * @param func The function to execute after physics step
  23626. */
  23627. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23628. /**
  23629. * register a function that will be executed when this impostor collides against a different body
  23630. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23631. * @param func Callback that is executed on collision
  23632. */
  23633. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23634. /**
  23635. * Unregisters the physics imposter on contact
  23636. * @param collideAgainst The physics object to collide against
  23637. * @param func Callback to execute on collision
  23638. */
  23639. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23640. private _tmpQuat;
  23641. private _tmpQuat2;
  23642. /**
  23643. * Get the parent rotation
  23644. * @returns The parent rotation
  23645. */
  23646. getParentsRotation(): Quaternion;
  23647. /**
  23648. * this function is executed by the physics engine.
  23649. */
  23650. beforeStep: () => void;
  23651. /**
  23652. * this function is executed by the physics engine
  23653. */
  23654. afterStep: () => void;
  23655. /**
  23656. * Legacy collision detection event support
  23657. */
  23658. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23659. /**
  23660. * event and body object due to cannon's event-based architecture.
  23661. */
  23662. onCollide: (e: {
  23663. body: any;
  23664. }) => void;
  23665. /**
  23666. * Apply a force
  23667. * @param force The force to apply
  23668. * @param contactPoint The contact point for the force
  23669. * @returns The physics imposter
  23670. */
  23671. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23672. /**
  23673. * Apply an impulse
  23674. * @param force The impulse force
  23675. * @param contactPoint The contact point for the impulse force
  23676. * @returns The physics imposter
  23677. */
  23678. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23679. /**
  23680. * A help function to create a joint
  23681. * @param otherImpostor A physics imposter used to create a joint
  23682. * @param jointType The type of joint
  23683. * @param jointData The data for the joint
  23684. * @returns The physics imposter
  23685. */
  23686. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23687. /**
  23688. * Add a joint to this impostor with a different impostor
  23689. * @param otherImpostor A physics imposter used to add a joint
  23690. * @param joint The joint to add
  23691. * @returns The physics imposter
  23692. */
  23693. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23694. /**
  23695. * Add an anchor to a cloth impostor
  23696. * @param otherImpostor rigid impostor to anchor to
  23697. * @param width ratio across width from 0 to 1
  23698. * @param height ratio up height from 0 to 1
  23699. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23700. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23701. * @returns impostor the soft imposter
  23702. */
  23703. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23704. /**
  23705. * Add a hook to a rope impostor
  23706. * @param otherImpostor rigid impostor to anchor to
  23707. * @param length ratio across rope from 0 to 1
  23708. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23709. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23710. * @returns impostor the rope imposter
  23711. */
  23712. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23713. /**
  23714. * Will keep this body still, in a sleep mode.
  23715. * @returns the physics imposter
  23716. */
  23717. sleep(): PhysicsImpostor;
  23718. /**
  23719. * Wake the body up.
  23720. * @returns The physics imposter
  23721. */
  23722. wakeUp(): PhysicsImpostor;
  23723. /**
  23724. * Clones the physics imposter
  23725. * @param newObject The physics imposter clones to this physics-enabled object
  23726. * @returns A nullable physics imposter
  23727. */
  23728. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23729. /**
  23730. * Disposes the physics imposter
  23731. */
  23732. dispose(): void;
  23733. /**
  23734. * Sets the delta position
  23735. * @param position The delta position amount
  23736. */
  23737. setDeltaPosition(position: Vector3): void;
  23738. /**
  23739. * Sets the delta rotation
  23740. * @param rotation The delta rotation amount
  23741. */
  23742. setDeltaRotation(rotation: Quaternion): void;
  23743. /**
  23744. * Gets the box size of the physics imposter and stores the result in the input parameter
  23745. * @param result Stores the box size
  23746. * @returns The physics imposter
  23747. */
  23748. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23749. /**
  23750. * Gets the radius of the physics imposter
  23751. * @returns Radius of the physics imposter
  23752. */
  23753. getRadius(): number;
  23754. /**
  23755. * Sync a bone with this impostor
  23756. * @param bone The bone to sync to the impostor.
  23757. * @param boneMesh The mesh that the bone is influencing.
  23758. * @param jointPivot The pivot of the joint / bone in local space.
  23759. * @param distToJoint Optional distance from the impostor to the joint.
  23760. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23761. */
  23762. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23763. /**
  23764. * Sync impostor to a bone
  23765. * @param bone The bone that the impostor will be synced to.
  23766. * @param boneMesh The mesh that the bone is influencing.
  23767. * @param jointPivot The pivot of the joint / bone in local space.
  23768. * @param distToJoint Optional distance from the impostor to the joint.
  23769. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23770. * @param boneAxis Optional vector3 axis the bone is aligned with
  23771. */
  23772. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23773. /**
  23774. * No-Imposter type
  23775. */
  23776. static NoImpostor: number;
  23777. /**
  23778. * Sphere-Imposter type
  23779. */
  23780. static SphereImpostor: number;
  23781. /**
  23782. * Box-Imposter type
  23783. */
  23784. static BoxImpostor: number;
  23785. /**
  23786. * Plane-Imposter type
  23787. */
  23788. static PlaneImpostor: number;
  23789. /**
  23790. * Mesh-imposter type
  23791. */
  23792. static MeshImpostor: number;
  23793. /**
  23794. * Capsule-Impostor type (Ammo.js plugin only)
  23795. */
  23796. static CapsuleImpostor: number;
  23797. /**
  23798. * Cylinder-Imposter type
  23799. */
  23800. static CylinderImpostor: number;
  23801. /**
  23802. * Particle-Imposter type
  23803. */
  23804. static ParticleImpostor: number;
  23805. /**
  23806. * Heightmap-Imposter type
  23807. */
  23808. static HeightmapImpostor: number;
  23809. /**
  23810. * ConvexHull-Impostor type (Ammo.js plugin only)
  23811. */
  23812. static ConvexHullImpostor: number;
  23813. /**
  23814. * Rope-Imposter type
  23815. */
  23816. static RopeImpostor: number;
  23817. /**
  23818. * Cloth-Imposter type
  23819. */
  23820. static ClothImpostor: number;
  23821. /**
  23822. * Softbody-Imposter type
  23823. */
  23824. static SoftbodyImpostor: number;
  23825. }
  23826. }
  23827. declare module "babylonjs/Meshes/mesh" {
  23828. import { Observable } from "babylonjs/Misc/observable";
  23829. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23830. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23831. import { Camera } from "babylonjs/Cameras/camera";
  23832. import { Scene } from "babylonjs/scene";
  23833. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  23834. import { Color4 } from "babylonjs/Maths/math.color";
  23835. import { Engine } from "babylonjs/Engines/engine";
  23836. import { Node } from "babylonjs/node";
  23837. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23838. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23839. import { Buffer } from "babylonjs/Meshes/buffer";
  23840. import { Geometry } from "babylonjs/Meshes/geometry";
  23841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23843. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  23844. import { Effect } from "babylonjs/Materials/effect";
  23845. import { Material } from "babylonjs/Materials/material";
  23846. import { Skeleton } from "babylonjs/Bones/skeleton";
  23847. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  23848. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  23849. import { Path3D } from "babylonjs/Maths/math.path";
  23850. import { Plane } from "babylonjs/Maths/math.plane";
  23851. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  23852. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  23853. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  23854. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23855. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  23856. /**
  23857. * @hidden
  23858. **/
  23859. export class _CreationDataStorage {
  23860. closePath?: boolean;
  23861. closeArray?: boolean;
  23862. idx: number[];
  23863. dashSize: number;
  23864. gapSize: number;
  23865. path3D: Path3D;
  23866. pathArray: Vector3[][];
  23867. arc: number;
  23868. radius: number;
  23869. cap: number;
  23870. tessellation: number;
  23871. }
  23872. /**
  23873. * @hidden
  23874. **/
  23875. class _InstanceDataStorage {
  23876. visibleInstances: any;
  23877. batchCache: _InstancesBatch;
  23878. instancesBufferSize: number;
  23879. instancesBuffer: Nullable<Buffer>;
  23880. instancesData: Float32Array;
  23881. overridenInstanceCount: number;
  23882. isFrozen: boolean;
  23883. previousBatch: Nullable<_InstancesBatch>;
  23884. hardwareInstancedRendering: boolean;
  23885. sideOrientation: number;
  23886. }
  23887. /**
  23888. * @hidden
  23889. **/
  23890. export class _InstancesBatch {
  23891. mustReturn: boolean;
  23892. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  23893. renderSelf: boolean[];
  23894. hardwareInstancedRendering: boolean[];
  23895. }
  23896. /**
  23897. * Class used to represent renderable models
  23898. */
  23899. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  23900. /**
  23901. * Mesh side orientation : usually the external or front surface
  23902. */
  23903. static readonly FRONTSIDE: number;
  23904. /**
  23905. * Mesh side orientation : usually the internal or back surface
  23906. */
  23907. static readonly BACKSIDE: number;
  23908. /**
  23909. * Mesh side orientation : both internal and external or front and back surfaces
  23910. */
  23911. static readonly DOUBLESIDE: number;
  23912. /**
  23913. * Mesh side orientation : by default, `FRONTSIDE`
  23914. */
  23915. static readonly DEFAULTSIDE: number;
  23916. /**
  23917. * Mesh cap setting : no cap
  23918. */
  23919. static readonly NO_CAP: number;
  23920. /**
  23921. * Mesh cap setting : one cap at the beginning of the mesh
  23922. */
  23923. static readonly CAP_START: number;
  23924. /**
  23925. * Mesh cap setting : one cap at the end of the mesh
  23926. */
  23927. static readonly CAP_END: number;
  23928. /**
  23929. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  23930. */
  23931. static readonly CAP_ALL: number;
  23932. /**
  23933. * Mesh pattern setting : no flip or rotate
  23934. */
  23935. static readonly NO_FLIP: number;
  23936. /**
  23937. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  23938. */
  23939. static readonly FLIP_TILE: number;
  23940. /**
  23941. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  23942. */
  23943. static readonly ROTATE_TILE: number;
  23944. /**
  23945. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  23946. */
  23947. static readonly FLIP_ROW: number;
  23948. /**
  23949. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  23950. */
  23951. static readonly ROTATE_ROW: number;
  23952. /**
  23953. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  23954. */
  23955. static readonly FLIP_N_ROTATE_TILE: number;
  23956. /**
  23957. * Mesh pattern setting : rotate pattern and rotate
  23958. */
  23959. static readonly FLIP_N_ROTATE_ROW: number;
  23960. /**
  23961. * Mesh tile positioning : part tiles same on left/right or top/bottom
  23962. */
  23963. static readonly CENTER: number;
  23964. /**
  23965. * Mesh tile positioning : part tiles on left
  23966. */
  23967. static readonly LEFT: number;
  23968. /**
  23969. * Mesh tile positioning : part tiles on right
  23970. */
  23971. static readonly RIGHT: number;
  23972. /**
  23973. * Mesh tile positioning : part tiles on top
  23974. */
  23975. static readonly TOP: number;
  23976. /**
  23977. * Mesh tile positioning : part tiles on bottom
  23978. */
  23979. static readonly BOTTOM: number;
  23980. /**
  23981. * Gets the default side orientation.
  23982. * @param orientation the orientation to value to attempt to get
  23983. * @returns the default orientation
  23984. * @hidden
  23985. */
  23986. static _GetDefaultSideOrientation(orientation?: number): number;
  23987. private _internalMeshDataInfo;
  23988. /**
  23989. * An event triggered before rendering the mesh
  23990. */
  23991. readonly onBeforeRenderObservable: Observable<Mesh>;
  23992. /**
  23993. * An event triggered before binding the mesh
  23994. */
  23995. readonly onBeforeBindObservable: Observable<Mesh>;
  23996. /**
  23997. * An event triggered after rendering the mesh
  23998. */
  23999. readonly onAfterRenderObservable: Observable<Mesh>;
  24000. /**
  24001. * An event triggered before drawing the mesh
  24002. */
  24003. readonly onBeforeDrawObservable: Observable<Mesh>;
  24004. private _onBeforeDrawObserver;
  24005. /**
  24006. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24007. */
  24008. onBeforeDraw: () => void;
  24009. /**
  24010. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24011. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24012. */
  24013. delayLoadState: number;
  24014. /**
  24015. * Gets the list of instances created from this mesh
  24016. * it is not supposed to be modified manually.
  24017. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24018. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24019. */
  24020. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24021. /**
  24022. * Gets the file containing delay loading data for this mesh
  24023. */
  24024. delayLoadingFile: string;
  24025. /** @hidden */
  24026. _binaryInfo: any;
  24027. /**
  24028. * User defined function used to change how LOD level selection is done
  24029. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24030. */
  24031. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24032. /**
  24033. * Gets or sets the morph target manager
  24034. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24035. */
  24036. morphTargetManager: Nullable<MorphTargetManager>;
  24037. /** @hidden */
  24038. _creationDataStorage: Nullable<_CreationDataStorage>;
  24039. /** @hidden */
  24040. _geometry: Nullable<Geometry>;
  24041. /** @hidden */
  24042. _delayInfo: Array<string>;
  24043. /** @hidden */
  24044. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24045. /** @hidden */
  24046. _instanceDataStorage: _InstanceDataStorage;
  24047. private _effectiveMaterial;
  24048. /** @hidden */
  24049. _shouldGenerateFlatShading: boolean;
  24050. /** @hidden */
  24051. _originalBuilderSideOrientation: number;
  24052. /**
  24053. * Use this property to change the original side orientation defined at construction time
  24054. */
  24055. overrideMaterialSideOrientation: Nullable<number>;
  24056. /**
  24057. * Gets the source mesh (the one used to clone this one from)
  24058. */
  24059. readonly source: Nullable<Mesh>;
  24060. /**
  24061. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24062. */
  24063. isUnIndexed: boolean;
  24064. /**
  24065. * @constructor
  24066. * @param name The value used by scene.getMeshByName() to do a lookup.
  24067. * @param scene The scene to add this mesh to.
  24068. * @param parent The parent of this mesh, if it has one
  24069. * @param source An optional Mesh from which geometry is shared, cloned.
  24070. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24071. * When false, achieved by calling a clone(), also passing False.
  24072. * This will make creation of children, recursive.
  24073. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24074. */
  24075. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24076. /**
  24077. * Gets the class name
  24078. * @returns the string "Mesh".
  24079. */
  24080. getClassName(): string;
  24081. /** @hidden */
  24082. readonly _isMesh: boolean;
  24083. /**
  24084. * Returns a description of this mesh
  24085. * @param fullDetails define if full details about this mesh must be used
  24086. * @returns a descriptive string representing this mesh
  24087. */
  24088. toString(fullDetails?: boolean): string;
  24089. /** @hidden */
  24090. _unBindEffect(): void;
  24091. /**
  24092. * Gets a boolean indicating if this mesh has LOD
  24093. */
  24094. readonly hasLODLevels: boolean;
  24095. /**
  24096. * Gets the list of MeshLODLevel associated with the current mesh
  24097. * @returns an array of MeshLODLevel
  24098. */
  24099. getLODLevels(): MeshLODLevel[];
  24100. private _sortLODLevels;
  24101. /**
  24102. * Add a mesh as LOD level triggered at the given distance.
  24103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24104. * @param distance The distance from the center of the object to show this level
  24105. * @param mesh The mesh to be added as LOD level (can be null)
  24106. * @return This mesh (for chaining)
  24107. */
  24108. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24109. /**
  24110. * Returns the LOD level mesh at the passed distance or null if not found.
  24111. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24112. * @param distance The distance from the center of the object to show this level
  24113. * @returns a Mesh or `null`
  24114. */
  24115. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24116. /**
  24117. * Remove a mesh from the LOD array
  24118. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24119. * @param mesh defines the mesh to be removed
  24120. * @return This mesh (for chaining)
  24121. */
  24122. removeLODLevel(mesh: Mesh): Mesh;
  24123. /**
  24124. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24125. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24126. * @param camera defines the camera to use to compute distance
  24127. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24128. * @return This mesh (for chaining)
  24129. */
  24130. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24131. /**
  24132. * Gets the mesh internal Geometry object
  24133. */
  24134. readonly geometry: Nullable<Geometry>;
  24135. /**
  24136. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24137. * @returns the total number of vertices
  24138. */
  24139. getTotalVertices(): number;
  24140. /**
  24141. * Returns the content of an associated vertex buffer
  24142. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24143. * - VertexBuffer.PositionKind
  24144. * - VertexBuffer.UVKind
  24145. * - VertexBuffer.UV2Kind
  24146. * - VertexBuffer.UV3Kind
  24147. * - VertexBuffer.UV4Kind
  24148. * - VertexBuffer.UV5Kind
  24149. * - VertexBuffer.UV6Kind
  24150. * - VertexBuffer.ColorKind
  24151. * - VertexBuffer.MatricesIndicesKind
  24152. * - VertexBuffer.MatricesIndicesExtraKind
  24153. * - VertexBuffer.MatricesWeightsKind
  24154. * - VertexBuffer.MatricesWeightsExtraKind
  24155. * @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
  24156. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24157. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24158. */
  24159. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24160. /**
  24161. * Returns the mesh VertexBuffer object from the requested `kind`
  24162. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24163. * - VertexBuffer.PositionKind
  24164. * - VertexBuffer.NormalKind
  24165. * - VertexBuffer.UVKind
  24166. * - VertexBuffer.UV2Kind
  24167. * - VertexBuffer.UV3Kind
  24168. * - VertexBuffer.UV4Kind
  24169. * - VertexBuffer.UV5Kind
  24170. * - VertexBuffer.UV6Kind
  24171. * - VertexBuffer.ColorKind
  24172. * - VertexBuffer.MatricesIndicesKind
  24173. * - VertexBuffer.MatricesIndicesExtraKind
  24174. * - VertexBuffer.MatricesWeightsKind
  24175. * - VertexBuffer.MatricesWeightsExtraKind
  24176. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24177. */
  24178. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24179. /**
  24180. * Tests if a specific vertex buffer is associated with this mesh
  24181. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24182. * - VertexBuffer.PositionKind
  24183. * - VertexBuffer.NormalKind
  24184. * - VertexBuffer.UVKind
  24185. * - VertexBuffer.UV2Kind
  24186. * - VertexBuffer.UV3Kind
  24187. * - VertexBuffer.UV4Kind
  24188. * - VertexBuffer.UV5Kind
  24189. * - VertexBuffer.UV6Kind
  24190. * - VertexBuffer.ColorKind
  24191. * - VertexBuffer.MatricesIndicesKind
  24192. * - VertexBuffer.MatricesIndicesExtraKind
  24193. * - VertexBuffer.MatricesWeightsKind
  24194. * - VertexBuffer.MatricesWeightsExtraKind
  24195. * @returns a boolean
  24196. */
  24197. isVerticesDataPresent(kind: string): boolean;
  24198. /**
  24199. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24200. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24201. * - VertexBuffer.PositionKind
  24202. * - VertexBuffer.UVKind
  24203. * - VertexBuffer.UV2Kind
  24204. * - VertexBuffer.UV3Kind
  24205. * - VertexBuffer.UV4Kind
  24206. * - VertexBuffer.UV5Kind
  24207. * - VertexBuffer.UV6Kind
  24208. * - VertexBuffer.ColorKind
  24209. * - VertexBuffer.MatricesIndicesKind
  24210. * - VertexBuffer.MatricesIndicesExtraKind
  24211. * - VertexBuffer.MatricesWeightsKind
  24212. * - VertexBuffer.MatricesWeightsExtraKind
  24213. * @returns a boolean
  24214. */
  24215. isVertexBufferUpdatable(kind: string): boolean;
  24216. /**
  24217. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24218. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24219. * - VertexBuffer.PositionKind
  24220. * - VertexBuffer.NormalKind
  24221. * - VertexBuffer.UVKind
  24222. * - VertexBuffer.UV2Kind
  24223. * - VertexBuffer.UV3Kind
  24224. * - VertexBuffer.UV4Kind
  24225. * - VertexBuffer.UV5Kind
  24226. * - VertexBuffer.UV6Kind
  24227. * - VertexBuffer.ColorKind
  24228. * - VertexBuffer.MatricesIndicesKind
  24229. * - VertexBuffer.MatricesIndicesExtraKind
  24230. * - VertexBuffer.MatricesWeightsKind
  24231. * - VertexBuffer.MatricesWeightsExtraKind
  24232. * @returns an array of strings
  24233. */
  24234. getVerticesDataKinds(): string[];
  24235. /**
  24236. * Returns a positive integer : the total number of indices in this mesh geometry.
  24237. * @returns the numner of indices or zero if the mesh has no geometry.
  24238. */
  24239. getTotalIndices(): number;
  24240. /**
  24241. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24242. * @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.
  24243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24244. * @returns the indices array or an empty array if the mesh has no geometry
  24245. */
  24246. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24247. readonly isBlocked: boolean;
  24248. /**
  24249. * Determine if the current mesh is ready to be rendered
  24250. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24251. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24252. * @returns true if all associated assets are ready (material, textures, shaders)
  24253. */
  24254. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24255. /**
  24256. * 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.
  24257. */
  24258. readonly areNormalsFrozen: boolean;
  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 prevents the mesh normals from being recomputed on next `positions` array update.
  24261. * @returns the current mesh
  24262. */
  24263. freezeNormals(): Mesh;
  24264. /**
  24265. * 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
  24266. * @returns the current mesh
  24267. */
  24268. unfreezeNormals(): Mesh;
  24269. /**
  24270. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24271. */
  24272. overridenInstanceCount: number;
  24273. /** @hidden */
  24274. _preActivate(): Mesh;
  24275. /** @hidden */
  24276. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24277. /** @hidden */
  24278. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24279. /**
  24280. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24281. * This means the mesh underlying bounding box and sphere are recomputed.
  24282. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24283. * @returns the current mesh
  24284. */
  24285. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24286. /** @hidden */
  24287. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24288. /**
  24289. * This function will subdivide the mesh into multiple submeshes
  24290. * @param count defines the expected number of submeshes
  24291. */
  24292. subdivide(count: number): void;
  24293. /**
  24294. * Copy a FloatArray into a specific associated vertex buffer
  24295. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24296. * - VertexBuffer.PositionKind
  24297. * - VertexBuffer.UVKind
  24298. * - VertexBuffer.UV2Kind
  24299. * - VertexBuffer.UV3Kind
  24300. * - VertexBuffer.UV4Kind
  24301. * - VertexBuffer.UV5Kind
  24302. * - VertexBuffer.UV6Kind
  24303. * - VertexBuffer.ColorKind
  24304. * - VertexBuffer.MatricesIndicesKind
  24305. * - VertexBuffer.MatricesIndicesExtraKind
  24306. * - VertexBuffer.MatricesWeightsKind
  24307. * - VertexBuffer.MatricesWeightsExtraKind
  24308. * @param data defines the data source
  24309. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24310. * @param stride defines the data stride size (can be null)
  24311. * @returns the current mesh
  24312. */
  24313. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  24314. /**
  24315. * Flags an associated vertex buffer as updatable
  24316. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24317. * - VertexBuffer.PositionKind
  24318. * - VertexBuffer.UVKind
  24319. * - VertexBuffer.UV2Kind
  24320. * - VertexBuffer.UV3Kind
  24321. * - VertexBuffer.UV4Kind
  24322. * - VertexBuffer.UV5Kind
  24323. * - VertexBuffer.UV6Kind
  24324. * - VertexBuffer.ColorKind
  24325. * - VertexBuffer.MatricesIndicesKind
  24326. * - VertexBuffer.MatricesIndicesExtraKind
  24327. * - VertexBuffer.MatricesWeightsKind
  24328. * - VertexBuffer.MatricesWeightsExtraKind
  24329. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24330. */
  24331. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24332. /**
  24333. * Sets the mesh global Vertex Buffer
  24334. * @param buffer defines the buffer to use
  24335. * @returns the current mesh
  24336. */
  24337. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24338. /**
  24339. * Update a specific associated vertex buffer
  24340. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24341. * - VertexBuffer.PositionKind
  24342. * - VertexBuffer.UVKind
  24343. * - VertexBuffer.UV2Kind
  24344. * - VertexBuffer.UV3Kind
  24345. * - VertexBuffer.UV4Kind
  24346. * - VertexBuffer.UV5Kind
  24347. * - VertexBuffer.UV6Kind
  24348. * - VertexBuffer.ColorKind
  24349. * - VertexBuffer.MatricesIndicesKind
  24350. * - VertexBuffer.MatricesIndicesExtraKind
  24351. * - VertexBuffer.MatricesWeightsKind
  24352. * - VertexBuffer.MatricesWeightsExtraKind
  24353. * @param data defines the data source
  24354. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24355. * @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)
  24356. * @returns the current mesh
  24357. */
  24358. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  24359. /**
  24360. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24361. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24362. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24363. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24364. * @returns the current mesh
  24365. */
  24366. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24367. /**
  24368. * Creates a un-shared specific occurence of the geometry for the mesh.
  24369. * @returns the current mesh
  24370. */
  24371. makeGeometryUnique(): Mesh;
  24372. /**
  24373. * Set the index buffer of this mesh
  24374. * @param indices defines the source data
  24375. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24376. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24377. * @returns the current mesh
  24378. */
  24379. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  24380. /**
  24381. * Update the current index buffer
  24382. * @param indices defines the source data
  24383. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24384. * @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)
  24385. * @returns the current mesh
  24386. */
  24387. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  24388. /**
  24389. * Invert the geometry to move from a right handed system to a left handed one.
  24390. * @returns the current mesh
  24391. */
  24392. toLeftHanded(): Mesh;
  24393. /** @hidden */
  24394. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24395. /** @hidden */
  24396. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24397. /**
  24398. * Registers for this mesh a javascript function called just before the rendering process
  24399. * @param func defines the function to call before rendering this mesh
  24400. * @returns the current mesh
  24401. */
  24402. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24403. /**
  24404. * Disposes a previously registered javascript function called before the rendering
  24405. * @param func defines the function to remove
  24406. * @returns the current mesh
  24407. */
  24408. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24409. /**
  24410. * Registers for this mesh a javascript function called just after the rendering is complete
  24411. * @param func defines the function to call after rendering this mesh
  24412. * @returns the current mesh
  24413. */
  24414. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24415. /**
  24416. * Disposes a previously registered javascript function called after the rendering.
  24417. * @param func defines the function to remove
  24418. * @returns the current mesh
  24419. */
  24420. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24421. /** @hidden */
  24422. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24423. /** @hidden */
  24424. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24425. /** @hidden */
  24426. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24427. /** @hidden */
  24428. _rebuild(): void;
  24429. /** @hidden */
  24430. _freeze(): void;
  24431. /** @hidden */
  24432. _unFreeze(): void;
  24433. /**
  24434. * 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
  24435. * @param subMesh defines the subMesh to render
  24436. * @param enableAlphaMode defines if alpha mode can be changed
  24437. * @returns the current mesh
  24438. */
  24439. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24440. private _onBeforeDraw;
  24441. /**
  24442. * Renormalize the mesh and patch it up if there are no weights
  24443. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24444. * However in the case of zero weights then we set just a single influence to 1.
  24445. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24446. */
  24447. cleanMatrixWeights(): void;
  24448. private normalizeSkinFourWeights;
  24449. private normalizeSkinWeightsAndExtra;
  24450. /**
  24451. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24452. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24453. * the user know there was an issue with importing the mesh
  24454. * @returns a validation object with skinned, valid and report string
  24455. */
  24456. validateSkinning(): {
  24457. skinned: boolean;
  24458. valid: boolean;
  24459. report: string;
  24460. };
  24461. /** @hidden */
  24462. _checkDelayState(): Mesh;
  24463. private _queueLoad;
  24464. /**
  24465. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24466. * A mesh is in the frustum if its bounding box intersects the frustum
  24467. * @param frustumPlanes defines the frustum to test
  24468. * @returns true if the mesh is in the frustum planes
  24469. */
  24470. isInFrustum(frustumPlanes: Plane[]): boolean;
  24471. /**
  24472. * Sets the mesh material by the material or multiMaterial `id` property
  24473. * @param id is a string identifying the material or the multiMaterial
  24474. * @returns the current mesh
  24475. */
  24476. setMaterialByID(id: string): Mesh;
  24477. /**
  24478. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24479. * @returns an array of IAnimatable
  24480. */
  24481. getAnimatables(): IAnimatable[];
  24482. /**
  24483. * Modifies the mesh geometry according to the passed transformation matrix.
  24484. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24485. * The mesh normals are modified using the same transformation.
  24486. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24487. * @param transform defines the transform matrix to use
  24488. * @see http://doc.babylonjs.com/resources/baking_transformations
  24489. * @returns the current mesh
  24490. */
  24491. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24492. /**
  24493. * Modifies the mesh geometry according to its own current World Matrix.
  24494. * The mesh World Matrix is then reset.
  24495. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24496. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24497. * @see http://doc.babylonjs.com/resources/baking_transformations
  24498. * @returns the current mesh
  24499. */
  24500. bakeCurrentTransformIntoVertices(): Mesh;
  24501. /** @hidden */
  24502. readonly _positions: Nullable<Vector3[]>;
  24503. /** @hidden */
  24504. _resetPointsArrayCache(): Mesh;
  24505. /** @hidden */
  24506. _generatePointsArray(): boolean;
  24507. /**
  24508. * Returns a new Mesh object generated from the current mesh properties.
  24509. * This method must not get confused with createInstance()
  24510. * @param name is a string, the name given to the new mesh
  24511. * @param newParent can be any Node object (default `null`)
  24512. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24513. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24514. * @returns a new mesh
  24515. */
  24516. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24517. /**
  24518. * Releases resources associated with this mesh.
  24519. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24520. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24521. */
  24522. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24523. /**
  24524. * Modifies the mesh geometry according to a displacement map.
  24525. * 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.
  24526. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24527. * @param url is a string, the URL from the image file is to be downloaded.
  24528. * @param minHeight is the lower limit of the displacement.
  24529. * @param maxHeight is the upper limit of the displacement.
  24530. * @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.
  24531. * @param uvOffset is an optional vector2 used to offset UV.
  24532. * @param uvScale is an optional vector2 used to scale UV.
  24533. * @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.
  24534. * @returns the Mesh.
  24535. */
  24536. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24537. /**
  24538. * Modifies the mesh geometry according to a displacementMap buffer.
  24539. * 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.
  24540. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24541. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24542. * @param heightMapWidth is the width of the buffer image.
  24543. * @param heightMapHeight is the height of the buffer image.
  24544. * @param minHeight is the lower limit of the displacement.
  24545. * @param maxHeight is the upper limit of the displacement.
  24546. * @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.
  24547. * @param uvOffset is an optional vector2 used to offset UV.
  24548. * @param uvScale is an optional vector2 used to scale UV.
  24549. * @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.
  24550. * @returns the Mesh.
  24551. */
  24552. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24553. /**
  24554. * Modify the mesh to get a flat shading rendering.
  24555. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24556. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24557. * @returns current mesh
  24558. */
  24559. convertToFlatShadedMesh(): Mesh;
  24560. /**
  24561. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24562. * In other words, more vertices, no more indices and a single bigger VBO.
  24563. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24564. * @returns current mesh
  24565. */
  24566. convertToUnIndexedMesh(): Mesh;
  24567. /**
  24568. * Inverses facet orientations.
  24569. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24570. * @param flipNormals will also inverts the normals
  24571. * @returns current mesh
  24572. */
  24573. flipFaces(flipNormals?: boolean): Mesh;
  24574. /**
  24575. * Increase the number of facets and hence vertices in a mesh
  24576. * Vertex normals are interpolated from existing vertex normals
  24577. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24578. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24579. */
  24580. increaseVertices(numberPerEdge: number): void;
  24581. /**
  24582. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24583. * This will undo any application of covertToFlatShadedMesh
  24584. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24585. */
  24586. forceSharedVertices(): void;
  24587. /** @hidden */
  24588. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24589. /** @hidden */
  24590. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24591. /**
  24592. * Creates a new InstancedMesh object from the mesh model.
  24593. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24594. * @param name defines the name of the new instance
  24595. * @returns a new InstancedMesh
  24596. */
  24597. createInstance(name: string): InstancedMesh;
  24598. /**
  24599. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24600. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24601. * @returns the current mesh
  24602. */
  24603. synchronizeInstances(): Mesh;
  24604. /**
  24605. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24606. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24607. * This should be used together with the simplification to avoid disappearing triangles.
  24608. * @param successCallback an optional success callback to be called after the optimization finished.
  24609. * @returns the current mesh
  24610. */
  24611. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24612. /**
  24613. * Serialize current mesh
  24614. * @param serializationObject defines the object which will receive the serialization data
  24615. */
  24616. serialize(serializationObject: any): void;
  24617. /** @hidden */
  24618. _syncGeometryWithMorphTargetManager(): void;
  24619. /** @hidden */
  24620. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24621. /**
  24622. * Returns a new Mesh object parsed from the source provided.
  24623. * @param parsedMesh is the source
  24624. * @param scene defines the hosting scene
  24625. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24626. * @returns a new Mesh
  24627. */
  24628. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24629. /**
  24630. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24631. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24632. * @param name defines the name of the mesh to create
  24633. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24634. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24635. * @param closePath creates a seam between the first and the last points of each path of the path array
  24636. * @param offset is taken in account only if the `pathArray` is containing a single path
  24637. * @param scene defines the hosting scene
  24638. * @param updatable defines if the mesh must be flagged as updatable
  24639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24640. * @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)
  24641. * @returns a new Mesh
  24642. */
  24643. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24644. /**
  24645. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24646. * @param name defines the name of the mesh to create
  24647. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24648. * @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
  24649. * @param scene defines the hosting scene
  24650. * @param updatable defines if the mesh must be flagged as updatable
  24651. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24652. * @returns a new Mesh
  24653. */
  24654. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24655. /**
  24656. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24657. * @param name defines the name of the mesh to create
  24658. * @param size sets the size (float) of each box side (default 1)
  24659. * @param scene defines the hosting scene
  24660. * @param updatable defines if the mesh must be flagged as updatable
  24661. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24662. * @returns a new Mesh
  24663. */
  24664. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24665. /**
  24666. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24667. * @param name defines the name of the mesh to create
  24668. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24669. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24670. * @param scene defines the hosting scene
  24671. * @param updatable defines if the mesh must be flagged as updatable
  24672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24673. * @returns a new Mesh
  24674. */
  24675. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24676. /**
  24677. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24678. * @param name defines the name of the mesh to create
  24679. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24680. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24681. * @param scene defines the hosting scene
  24682. * @returns a new Mesh
  24683. */
  24684. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24685. /**
  24686. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24687. * @param name defines the name of the mesh to create
  24688. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24689. * @param diameterTop set the top cap diameter (floats, default 1)
  24690. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24691. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24692. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24693. * @param scene defines the hosting scene
  24694. * @param updatable defines if the mesh must be flagged as updatable
  24695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24696. * @returns a new Mesh
  24697. */
  24698. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24699. /**
  24700. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24701. * @param name defines the name of the mesh to create
  24702. * @param diameter sets the diameter size (float) of the torus (default 1)
  24703. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24704. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24705. * @param scene defines the hosting scene
  24706. * @param updatable defines if the mesh must be flagged as updatable
  24707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24708. * @returns a new Mesh
  24709. */
  24710. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24711. /**
  24712. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24713. * @param name defines the name of the mesh to create
  24714. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24715. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24716. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24717. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24718. * @param p the number of windings on X axis (positive integers, default 2)
  24719. * @param q the number of windings on Y axis (positive integers, default 3)
  24720. * @param scene defines the hosting scene
  24721. * @param updatable defines if the mesh must be flagged as updatable
  24722. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24723. * @returns a new Mesh
  24724. */
  24725. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24726. /**
  24727. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24728. * @param name defines the name of the mesh to create
  24729. * @param points is an array successive Vector3
  24730. * @param scene defines the hosting scene
  24731. * @param updatable defines if the mesh must be flagged as updatable
  24732. * @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).
  24733. * @returns a new Mesh
  24734. */
  24735. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24736. /**
  24737. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  24738. * @param name defines the name of the mesh to create
  24739. * @param points is an array successive Vector3
  24740. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24741. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24742. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24743. * @param scene defines the hosting scene
  24744. * @param updatable defines if the mesh must be flagged as updatable
  24745. * @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)
  24746. * @returns a new Mesh
  24747. */
  24748. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24749. /**
  24750. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24751. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24752. * 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.
  24753. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24754. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24755. * Remember you can only change the shape positions, not their number when updating a polygon.
  24756. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24757. * @param name defines the name of the mesh to create
  24758. * @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
  24759. * @param scene defines the hosting scene
  24760. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24761. * @param updatable defines if the mesh must be flagged as updatable
  24762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24763. * @param earcutInjection can be used to inject your own earcut reference
  24764. * @returns a new Mesh
  24765. */
  24766. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24767. /**
  24768. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24769. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24770. * @param name defines the name of the mesh to create
  24771. * @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
  24772. * @param depth defines the height of extrusion
  24773. * @param scene defines the hosting scene
  24774. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24775. * @param updatable defines if the mesh must be flagged as updatable
  24776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24777. * @param earcutInjection can be used to inject your own earcut reference
  24778. * @returns a new Mesh
  24779. */
  24780. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24781. /**
  24782. * Creates an extruded shape mesh.
  24783. * 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
  24784. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24785. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24786. * @param name defines the name of the mesh to create
  24787. * @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
  24788. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24789. * @param scale is the value to scale the shape
  24790. * @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
  24791. * @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
  24792. * @param scene defines the hosting scene
  24793. * @param updatable defines if the mesh must be flagged as updatable
  24794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24795. * @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)
  24796. * @returns a new Mesh
  24797. */
  24798. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24799. /**
  24800. * Creates an custom extruded shape mesh.
  24801. * The custom extrusion is a parametric shape.
  24802. * It has no predefined shape. Its final shape will depend on the input parameters.
  24803. * Please consider using the same method from the MeshBuilder class instead
  24804. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24805. * @param name defines the name of the mesh to create
  24806. * @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
  24807. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24808. * @param scaleFunction is a custom Javascript function called on each path point
  24809. * @param rotationFunction is a custom Javascript function called on each path point
  24810. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  24811. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  24812. * @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
  24813. * @param scene defines the hosting scene
  24814. * @param updatable defines if the mesh must be flagged as updatable
  24815. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24816. * @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)
  24817. * @returns a new Mesh
  24818. */
  24819. 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;
  24820. /**
  24821. * Creates lathe mesh.
  24822. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  24823. * Please consider using the same method from the MeshBuilder class instead
  24824. * @param name defines the name of the mesh to create
  24825. * @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
  24826. * @param radius is the radius value of the lathe
  24827. * @param tessellation is the side number of the lathe.
  24828. * @param scene defines the hosting scene
  24829. * @param updatable defines if the mesh must be flagged as updatable
  24830. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24831. * @returns a new Mesh
  24832. */
  24833. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24834. /**
  24835. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  24836. * @param name defines the name of the mesh to create
  24837. * @param size sets the size (float) of both sides of the plane at once (default 1)
  24838. * @param scene defines the hosting scene
  24839. * @param updatable defines if the mesh must be flagged as updatable
  24840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24841. * @returns a new Mesh
  24842. */
  24843. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24844. /**
  24845. * Creates a ground mesh.
  24846. * Please consider using the same method from the MeshBuilder class instead
  24847. * @param name defines the name of the mesh to create
  24848. * @param width set the width of the ground
  24849. * @param height set the height of the ground
  24850. * @param subdivisions sets the number of subdivisions per side
  24851. * @param scene defines the hosting scene
  24852. * @param updatable defines if the mesh must be flagged as updatable
  24853. * @returns a new Mesh
  24854. */
  24855. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  24856. /**
  24857. * Creates a tiled ground mesh.
  24858. * Please consider using the same method from the MeshBuilder class instead
  24859. * @param name defines the name of the mesh to create
  24860. * @param xmin set the ground minimum X coordinate
  24861. * @param zmin set the ground minimum Y coordinate
  24862. * @param xmax set the ground maximum X coordinate
  24863. * @param zmax set the ground maximum Z coordinate
  24864. * @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
  24865. * @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
  24866. * @param scene defines the hosting scene
  24867. * @param updatable defines if the mesh must be flagged as updatable
  24868. * @returns a new Mesh
  24869. */
  24870. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  24871. w: number;
  24872. h: number;
  24873. }, precision: {
  24874. w: number;
  24875. h: number;
  24876. }, scene: Scene, updatable?: boolean): Mesh;
  24877. /**
  24878. * Creates a ground mesh from a height map.
  24879. * Please consider using the same method from the MeshBuilder class instead
  24880. * @see http://doc.babylonjs.com/babylon101/height_map
  24881. * @param name defines the name of the mesh to create
  24882. * @param url sets the URL of the height map image resource
  24883. * @param width set the ground width size
  24884. * @param height set the ground height size
  24885. * @param subdivisions sets the number of subdivision per side
  24886. * @param minHeight is the minimum altitude on the ground
  24887. * @param maxHeight is the maximum altitude on the ground
  24888. * @param scene defines the hosting scene
  24889. * @param updatable defines if the mesh must be flagged as updatable
  24890. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  24891. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  24892. * @returns a new Mesh
  24893. */
  24894. 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;
  24895. /**
  24896. * Creates a tube mesh.
  24897. * The tube is a parametric shape.
  24898. * It has no predefined shape. Its final shape will depend on the input parameters.
  24899. * Please consider using the same method from the MeshBuilder class instead
  24900. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24901. * @param name defines the name of the mesh to create
  24902. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  24903. * @param radius sets the tube radius size
  24904. * @param tessellation is the number of sides on the tubular surface
  24905. * @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
  24906. * @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
  24907. * @param scene defines the hosting scene
  24908. * @param updatable defines if the mesh must be flagged as updatable
  24909. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24910. * @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)
  24911. * @returns a new Mesh
  24912. */
  24913. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  24914. (i: number, distance: number): number;
  24915. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24916. /**
  24917. * Creates a polyhedron mesh.
  24918. * Please consider using the same method from the MeshBuilder class instead.
  24919. * * 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
  24920. * * The parameter `size` (positive float, default 1) sets the polygon size
  24921. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  24922. * * 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`
  24923. * * 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
  24924. * * 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)`)
  24925. * * 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
  24926. * * 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
  24927. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24928. * * If you create a double-sided mesh, you can choose what parts of 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
  24929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24930. * @param name defines the name of the mesh to create
  24931. * @param options defines the options used to create the mesh
  24932. * @param scene defines the hosting scene
  24933. * @returns a new Mesh
  24934. */
  24935. static CreatePolyhedron(name: string, options: {
  24936. type?: number;
  24937. size?: number;
  24938. sizeX?: number;
  24939. sizeY?: number;
  24940. sizeZ?: number;
  24941. custom?: any;
  24942. faceUV?: Vector4[];
  24943. faceColors?: Color4[];
  24944. updatable?: boolean;
  24945. sideOrientation?: number;
  24946. }, scene: Scene): Mesh;
  24947. /**
  24948. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  24949. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  24950. * * 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`)
  24951. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  24952. * * 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
  24953. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24954. * * If you create a double-sided mesh, you can choose what parts of 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
  24955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24956. * @param name defines the name of the mesh
  24957. * @param options defines the options used to create the mesh
  24958. * @param scene defines the hosting scene
  24959. * @returns a new Mesh
  24960. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  24961. */
  24962. static CreateIcoSphere(name: string, options: {
  24963. radius?: number;
  24964. flat?: boolean;
  24965. subdivisions?: number;
  24966. sideOrientation?: number;
  24967. updatable?: boolean;
  24968. }, scene: Scene): Mesh;
  24969. /**
  24970. * Creates a decal mesh.
  24971. * Please consider using the same method from the MeshBuilder class instead.
  24972. * A decal is a mesh usually applied as a model onto the surface of another mesh
  24973. * @param name defines the name of the mesh
  24974. * @param sourceMesh defines the mesh receiving the decal
  24975. * @param position sets the position of the decal in world coordinates
  24976. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  24977. * @param size sets the decal scaling
  24978. * @param angle sets the angle to rotate the decal
  24979. * @returns a new Mesh
  24980. */
  24981. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  24982. /**
  24983. * Prepare internal position array for software CPU skinning
  24984. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  24985. */
  24986. setPositionsForCPUSkinning(): Float32Array;
  24987. /**
  24988. * Prepare internal normal array for software CPU skinning
  24989. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  24990. */
  24991. setNormalsForCPUSkinning(): Float32Array;
  24992. /**
  24993. * Updates the vertex buffer by applying transformation from the bones
  24994. * @param skeleton defines the skeleton to apply to current mesh
  24995. * @returns the current mesh
  24996. */
  24997. applySkeleton(skeleton: Skeleton): Mesh;
  24998. /**
  24999. * 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
  25000. * @param meshes defines the list of meshes to scan
  25001. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25002. */
  25003. static MinMax(meshes: AbstractMesh[]): {
  25004. min: Vector3;
  25005. max: Vector3;
  25006. };
  25007. /**
  25008. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25009. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25010. * @returns a vector3
  25011. */
  25012. static Center(meshesOrMinMaxVector: {
  25013. min: Vector3;
  25014. max: Vector3;
  25015. } | AbstractMesh[]): Vector3;
  25016. /**
  25017. * Merge the array of meshes into a single mesh for performance reasons.
  25018. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25019. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25020. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25021. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25022. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25023. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25024. * @returns a new mesh
  25025. */
  25026. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25027. /** @hidden */
  25028. addInstance(instance: InstancedMesh): void;
  25029. /** @hidden */
  25030. removeInstance(instance: InstancedMesh): void;
  25031. }
  25032. }
  25033. declare module "babylonjs/Cameras/camera" {
  25034. import { SmartArray } from "babylonjs/Misc/smartArray";
  25035. import { Observable } from "babylonjs/Misc/observable";
  25036. import { Nullable } from "babylonjs/types";
  25037. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25038. import { Scene } from "babylonjs/scene";
  25039. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25040. import { Node } from "babylonjs/node";
  25041. import { Mesh } from "babylonjs/Meshes/mesh";
  25042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25043. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25044. import { Viewport } from "babylonjs/Maths/math.viewport";
  25045. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25046. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25047. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25048. import { Ray } from "babylonjs/Culling/ray";
  25049. /**
  25050. * This is the base class of all the camera used in the application.
  25051. * @see http://doc.babylonjs.com/features/cameras
  25052. */
  25053. export class Camera extends Node {
  25054. /** @hidden */
  25055. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25056. /**
  25057. * This is the default projection mode used by the cameras.
  25058. * It helps recreating a feeling of perspective and better appreciate depth.
  25059. * This is the best way to simulate real life cameras.
  25060. */
  25061. static readonly PERSPECTIVE_CAMERA: number;
  25062. /**
  25063. * This helps creating camera with an orthographic mode.
  25064. * 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.
  25065. */
  25066. static readonly ORTHOGRAPHIC_CAMERA: number;
  25067. /**
  25068. * This is the default FOV mode for perspective cameras.
  25069. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25070. */
  25071. static readonly FOVMODE_VERTICAL_FIXED: number;
  25072. /**
  25073. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25074. */
  25075. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25076. /**
  25077. * This specifies ther is no need for a camera rig.
  25078. * Basically only one eye is rendered corresponding to the camera.
  25079. */
  25080. static readonly RIG_MODE_NONE: number;
  25081. /**
  25082. * Simulates a camera Rig with one blue eye and one red eye.
  25083. * This can be use with 3d blue and red glasses.
  25084. */
  25085. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25086. /**
  25087. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25088. */
  25089. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25090. /**
  25091. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25092. */
  25093. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25094. /**
  25095. * Defines that both eyes of the camera will be rendered over under each other.
  25096. */
  25097. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25098. /**
  25099. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25100. */
  25101. static readonly RIG_MODE_VR: number;
  25102. /**
  25103. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25104. */
  25105. static readonly RIG_MODE_WEBVR: number;
  25106. /**
  25107. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25108. */
  25109. static readonly RIG_MODE_CUSTOM: number;
  25110. /**
  25111. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25112. */
  25113. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25114. /**
  25115. * Define the input manager associated with the camera.
  25116. */
  25117. inputs: CameraInputsManager<Camera>;
  25118. /** @hidden */
  25119. _position: Vector3;
  25120. /**
  25121. * Define the current local position of the camera in the scene
  25122. */
  25123. position: Vector3;
  25124. /**
  25125. * The vector the camera should consider as up.
  25126. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25127. */
  25128. upVector: Vector3;
  25129. /**
  25130. * Define the current limit on the left side for an orthographic camera
  25131. * In scene unit
  25132. */
  25133. orthoLeft: Nullable<number>;
  25134. /**
  25135. * Define the current limit on the right side for an orthographic camera
  25136. * In scene unit
  25137. */
  25138. orthoRight: Nullable<number>;
  25139. /**
  25140. * Define the current limit on the bottom side for an orthographic camera
  25141. * In scene unit
  25142. */
  25143. orthoBottom: Nullable<number>;
  25144. /**
  25145. * Define the current limit on the top side for an orthographic camera
  25146. * In scene unit
  25147. */
  25148. orthoTop: Nullable<number>;
  25149. /**
  25150. * Field Of View is set in Radians. (default is 0.8)
  25151. */
  25152. fov: number;
  25153. /**
  25154. * Define the minimum distance the camera can see from.
  25155. * This is important to note that the depth buffer are not infinite and the closer it starts
  25156. * the more your scene might encounter depth fighting issue.
  25157. */
  25158. minZ: number;
  25159. /**
  25160. * Define the maximum distance the camera can see to.
  25161. * This is important to note that the depth buffer are not infinite and the further it end
  25162. * the more your scene might encounter depth fighting issue.
  25163. */
  25164. maxZ: number;
  25165. /**
  25166. * Define the default inertia of the camera.
  25167. * This helps giving a smooth feeling to the camera movement.
  25168. */
  25169. inertia: number;
  25170. /**
  25171. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25172. */
  25173. mode: number;
  25174. /**
  25175. * Define wether the camera is intermediate.
  25176. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25177. */
  25178. isIntermediate: boolean;
  25179. /**
  25180. * Define the viewport of the camera.
  25181. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25182. */
  25183. viewport: Viewport;
  25184. /**
  25185. * Restricts the camera to viewing objects with the same layerMask.
  25186. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25187. */
  25188. layerMask: number;
  25189. /**
  25190. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25191. */
  25192. fovMode: number;
  25193. /**
  25194. * Rig mode of the camera.
  25195. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25196. * This is normally controlled byt the camera themselves as internal use.
  25197. */
  25198. cameraRigMode: number;
  25199. /**
  25200. * Defines the distance between both "eyes" in case of a RIG
  25201. */
  25202. interaxialDistance: number;
  25203. /**
  25204. * Defines if stereoscopic rendering is done side by side or over under.
  25205. */
  25206. isStereoscopicSideBySide: boolean;
  25207. /**
  25208. * 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
  25209. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25210. * else in the scene. (Eg. security camera)
  25211. *
  25212. * 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)
  25213. */
  25214. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25215. /**
  25216. * When set, the camera will render to this render target instead of the default canvas
  25217. *
  25218. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25219. */
  25220. outputRenderTarget: Nullable<RenderTargetTexture>;
  25221. /**
  25222. * Observable triggered when the camera view matrix has changed.
  25223. */
  25224. onViewMatrixChangedObservable: Observable<Camera>;
  25225. /**
  25226. * Observable triggered when the camera Projection matrix has changed.
  25227. */
  25228. onProjectionMatrixChangedObservable: Observable<Camera>;
  25229. /**
  25230. * Observable triggered when the inputs have been processed.
  25231. */
  25232. onAfterCheckInputsObservable: Observable<Camera>;
  25233. /**
  25234. * Observable triggered when reset has been called and applied to the camera.
  25235. */
  25236. onRestoreStateObservable: Observable<Camera>;
  25237. /** @hidden */
  25238. _cameraRigParams: any;
  25239. /** @hidden */
  25240. _rigCameras: Camera[];
  25241. /** @hidden */
  25242. _rigPostProcess: Nullable<PostProcess>;
  25243. protected _webvrViewMatrix: Matrix;
  25244. /** @hidden */
  25245. _skipRendering: boolean;
  25246. /** @hidden */
  25247. _projectionMatrix: Matrix;
  25248. /** @hidden */
  25249. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25250. /** @hidden */
  25251. _activeMeshes: SmartArray<AbstractMesh>;
  25252. protected _globalPosition: Vector3;
  25253. /** @hidden */
  25254. _computedViewMatrix: Matrix;
  25255. private _doNotComputeProjectionMatrix;
  25256. private _transformMatrix;
  25257. private _frustumPlanes;
  25258. private _refreshFrustumPlanes;
  25259. private _storedFov;
  25260. private _stateStored;
  25261. /**
  25262. * Instantiates a new camera object.
  25263. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25264. * @see http://doc.babylonjs.com/features/cameras
  25265. * @param name Defines the name of the camera in the scene
  25266. * @param position Defines the position of the camera
  25267. * @param scene Defines the scene the camera belongs too
  25268. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25269. */
  25270. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25271. /**
  25272. * Store current camera state (fov, position, etc..)
  25273. * @returns the camera
  25274. */
  25275. storeState(): Camera;
  25276. /**
  25277. * Restores the camera state values if it has been stored. You must call storeState() first
  25278. */
  25279. protected _restoreStateValues(): boolean;
  25280. /**
  25281. * Restored camera state. You must call storeState() first.
  25282. * @returns true if restored and false otherwise
  25283. */
  25284. restoreState(): boolean;
  25285. /**
  25286. * Gets the class name of the camera.
  25287. * @returns the class name
  25288. */
  25289. getClassName(): string;
  25290. /** @hidden */
  25291. readonly _isCamera: boolean;
  25292. /**
  25293. * Gets a string representation of the camera useful for debug purpose.
  25294. * @param fullDetails Defines that a more verboe level of logging is required
  25295. * @returns the string representation
  25296. */
  25297. toString(fullDetails?: boolean): string;
  25298. /**
  25299. * Gets the current world space position of the camera.
  25300. */
  25301. readonly globalPosition: Vector3;
  25302. /**
  25303. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25304. * @returns the active meshe list
  25305. */
  25306. getActiveMeshes(): SmartArray<AbstractMesh>;
  25307. /**
  25308. * Check wether a mesh is part of the current active mesh list of the camera
  25309. * @param mesh Defines the mesh to check
  25310. * @returns true if active, false otherwise
  25311. */
  25312. isActiveMesh(mesh: Mesh): boolean;
  25313. /**
  25314. * Is this camera ready to be used/rendered
  25315. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25316. * @return true if the camera is ready
  25317. */
  25318. isReady(completeCheck?: boolean): boolean;
  25319. /** @hidden */
  25320. _initCache(): void;
  25321. /** @hidden */
  25322. _updateCache(ignoreParentClass?: boolean): void;
  25323. /** @hidden */
  25324. _isSynchronized(): boolean;
  25325. /** @hidden */
  25326. _isSynchronizedViewMatrix(): boolean;
  25327. /** @hidden */
  25328. _isSynchronizedProjectionMatrix(): boolean;
  25329. /**
  25330. * Attach the input controls to a specific dom element to get the input from.
  25331. * @param element Defines the element the controls should be listened from
  25332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25333. */
  25334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25335. /**
  25336. * Detach the current controls from the specified dom element.
  25337. * @param element Defines the element to stop listening the inputs from
  25338. */
  25339. detachControl(element: HTMLElement): void;
  25340. /**
  25341. * Update the camera state according to the different inputs gathered during the frame.
  25342. */
  25343. update(): void;
  25344. /** @hidden */
  25345. _checkInputs(): void;
  25346. /** @hidden */
  25347. readonly rigCameras: Camera[];
  25348. /**
  25349. * Gets the post process used by the rig cameras
  25350. */
  25351. readonly rigPostProcess: Nullable<PostProcess>;
  25352. /**
  25353. * Internal, gets the first post proces.
  25354. * @returns the first post process to be run on this camera.
  25355. */
  25356. _getFirstPostProcess(): Nullable<PostProcess>;
  25357. private _cascadePostProcessesToRigCams;
  25358. /**
  25359. * Attach a post process to the camera.
  25360. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25361. * @param postProcess The post process to attach to the camera
  25362. * @param insertAt The position of the post process in case several of them are in use in the scene
  25363. * @returns the position the post process has been inserted at
  25364. */
  25365. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25366. /**
  25367. * Detach a post process to the camera.
  25368. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25369. * @param postProcess The post process to detach from the camera
  25370. */
  25371. detachPostProcess(postProcess: PostProcess): void;
  25372. /**
  25373. * Gets the current world matrix of the camera
  25374. */
  25375. getWorldMatrix(): Matrix;
  25376. /** @hidden */
  25377. _getViewMatrix(): Matrix;
  25378. /**
  25379. * Gets the current view matrix of the camera.
  25380. * @param force forces the camera to recompute the matrix without looking at the cached state
  25381. * @returns the view matrix
  25382. */
  25383. getViewMatrix(force?: boolean): Matrix;
  25384. /**
  25385. * Freeze the projection matrix.
  25386. * It will prevent the cache check of the camera projection compute and can speed up perf
  25387. * if no parameter of the camera are meant to change
  25388. * @param projection Defines manually a projection if necessary
  25389. */
  25390. freezeProjectionMatrix(projection?: Matrix): void;
  25391. /**
  25392. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25393. */
  25394. unfreezeProjectionMatrix(): void;
  25395. /**
  25396. * Gets the current projection matrix of the camera.
  25397. * @param force forces the camera to recompute the matrix without looking at the cached state
  25398. * @returns the projection matrix
  25399. */
  25400. getProjectionMatrix(force?: boolean): Matrix;
  25401. /**
  25402. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25403. * @returns a Matrix
  25404. */
  25405. getTransformationMatrix(): Matrix;
  25406. private _updateFrustumPlanes;
  25407. /**
  25408. * Checks if a cullable object (mesh...) is in the camera frustum
  25409. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25410. * @param target The object to check
  25411. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25412. * @returns true if the object is in frustum otherwise false
  25413. */
  25414. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25415. /**
  25416. * Checks if a cullable object (mesh...) is in the camera frustum
  25417. * Unlike isInFrustum this cheks the full bounding box
  25418. * @param target The object to check
  25419. * @returns true if the object is in frustum otherwise false
  25420. */
  25421. isCompletelyInFrustum(target: ICullable): boolean;
  25422. /**
  25423. * Gets a ray in the forward direction from the camera.
  25424. * @param length Defines the length of the ray to create
  25425. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25426. * @param origin Defines the start point of the ray which defaults to the camera position
  25427. * @returns the forward ray
  25428. */
  25429. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25430. /**
  25431. * Releases resources associated with this node.
  25432. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25433. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25434. */
  25435. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25436. /** @hidden */
  25437. _isLeftCamera: boolean;
  25438. /**
  25439. * Gets the left camera of a rig setup in case of Rigged Camera
  25440. */
  25441. readonly isLeftCamera: boolean;
  25442. /** @hidden */
  25443. _isRightCamera: boolean;
  25444. /**
  25445. * Gets the right camera of a rig setup in case of Rigged Camera
  25446. */
  25447. readonly isRightCamera: boolean;
  25448. /**
  25449. * Gets the left camera of a rig setup in case of Rigged Camera
  25450. */
  25451. readonly leftCamera: Nullable<FreeCamera>;
  25452. /**
  25453. * Gets the right camera of a rig setup in case of Rigged Camera
  25454. */
  25455. readonly rightCamera: Nullable<FreeCamera>;
  25456. /**
  25457. * Gets the left camera target of a rig setup in case of Rigged Camera
  25458. * @returns the target position
  25459. */
  25460. getLeftTarget(): Nullable<Vector3>;
  25461. /**
  25462. * Gets the right camera target of a rig setup in case of Rigged Camera
  25463. * @returns the target position
  25464. */
  25465. getRightTarget(): Nullable<Vector3>;
  25466. /**
  25467. * @hidden
  25468. */
  25469. setCameraRigMode(mode: number, rigParams: any): void;
  25470. /** @hidden */
  25471. static _setStereoscopicRigMode(camera: Camera): void;
  25472. /** @hidden */
  25473. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25474. /** @hidden */
  25475. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25476. /** @hidden */
  25477. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25478. /** @hidden */
  25479. _getVRProjectionMatrix(): Matrix;
  25480. protected _updateCameraRotationMatrix(): void;
  25481. protected _updateWebVRCameraRotationMatrix(): void;
  25482. /**
  25483. * This function MUST be overwritten by the different WebVR cameras available.
  25484. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25485. * @hidden
  25486. */
  25487. _getWebVRProjectionMatrix(): Matrix;
  25488. /**
  25489. * This function MUST be overwritten by the different WebVR cameras available.
  25490. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25491. * @hidden
  25492. */
  25493. _getWebVRViewMatrix(): Matrix;
  25494. /** @hidden */
  25495. setCameraRigParameter(name: string, value: any): void;
  25496. /**
  25497. * needs to be overridden by children so sub has required properties to be copied
  25498. * @hidden
  25499. */
  25500. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25501. /**
  25502. * May need to be overridden by children
  25503. * @hidden
  25504. */
  25505. _updateRigCameras(): void;
  25506. /** @hidden */
  25507. _setupInputs(): void;
  25508. /**
  25509. * Serialiaze the camera setup to a json represention
  25510. * @returns the JSON representation
  25511. */
  25512. serialize(): any;
  25513. /**
  25514. * Clones the current camera.
  25515. * @param name The cloned camera name
  25516. * @returns the cloned camera
  25517. */
  25518. clone(name: string): Camera;
  25519. /**
  25520. * Gets the direction of the camera relative to a given local axis.
  25521. * @param localAxis Defines the reference axis to provide a relative direction.
  25522. * @return the direction
  25523. */
  25524. getDirection(localAxis: Vector3): Vector3;
  25525. /**
  25526. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25527. * @param localAxis Defines the reference axis to provide a relative direction.
  25528. * @param result Defines the vector to store the result in
  25529. */
  25530. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25531. /**
  25532. * Gets a camera constructor for a given camera type
  25533. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25534. * @param name The name of the camera the result will be able to instantiate
  25535. * @param scene The scene the result will construct the camera in
  25536. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25537. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25538. * @returns a factory method to construc the camera
  25539. */
  25540. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25541. /**
  25542. * Compute the world matrix of the camera.
  25543. * @returns the camera workd matrix
  25544. */
  25545. computeWorldMatrix(): Matrix;
  25546. /**
  25547. * Parse a JSON and creates the camera from the parsed information
  25548. * @param parsedCamera The JSON to parse
  25549. * @param scene The scene to instantiate the camera in
  25550. * @returns the newly constructed camera
  25551. */
  25552. static Parse(parsedCamera: any, scene: Scene): Camera;
  25553. }
  25554. }
  25555. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25556. import { Nullable } from "babylonjs/types";
  25557. import { Scene } from "babylonjs/scene";
  25558. import { Vector4 } from "babylonjs/Maths/math.vector";
  25559. import { Mesh } from "babylonjs/Meshes/mesh";
  25560. /**
  25561. * Class containing static functions to help procedurally build meshes
  25562. */
  25563. export class DiscBuilder {
  25564. /**
  25565. * Creates a plane polygonal mesh. By default, this is a disc
  25566. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25567. * * 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
  25568. * * 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
  25569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25572. * @param name defines the name of the mesh
  25573. * @param options defines the options used to create the mesh
  25574. * @param scene defines the hosting scene
  25575. * @returns the plane polygonal mesh
  25576. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25577. */
  25578. static CreateDisc(name: string, options: {
  25579. radius?: number;
  25580. tessellation?: number;
  25581. arc?: number;
  25582. updatable?: boolean;
  25583. sideOrientation?: number;
  25584. frontUVs?: Vector4;
  25585. backUVs?: Vector4;
  25586. }, scene?: Nullable<Scene>): Mesh;
  25587. }
  25588. }
  25589. declare module "babylonjs/Particles/solidParticleSystem" {
  25590. import { Vector3 } from "babylonjs/Maths/math.vector";
  25591. import { Mesh } from "babylonjs/Meshes/mesh";
  25592. import { Scene, IDisposable } from "babylonjs/scene";
  25593. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25594. /**
  25595. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25596. *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.
  25597. * The SPS is also a particle system. It provides some methods to manage the particles.
  25598. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25599. *
  25600. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25601. */
  25602. export class SolidParticleSystem implements IDisposable {
  25603. /**
  25604. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25605. * Example : var p = SPS.particles[i];
  25606. */
  25607. particles: SolidParticle[];
  25608. /**
  25609. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25610. */
  25611. nbParticles: number;
  25612. /**
  25613. * If the particles must ever face the camera (default false). Useful for planar particles.
  25614. */
  25615. billboard: boolean;
  25616. /**
  25617. * Recompute normals when adding a shape
  25618. */
  25619. recomputeNormals: boolean;
  25620. /**
  25621. * This a counter ofr your own usage. It's not set by any SPS functions.
  25622. */
  25623. counter: number;
  25624. /**
  25625. * The SPS name. This name is also given to the underlying mesh.
  25626. */
  25627. name: string;
  25628. /**
  25629. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25630. */
  25631. mesh: Mesh;
  25632. /**
  25633. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25634. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25635. */
  25636. vars: any;
  25637. /**
  25638. * This array is populated when the SPS is set as 'pickable'.
  25639. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25640. * Each element of this array is an object `{idx: int, faceId: int}`.
  25641. * `idx` is the picked particle index in the `SPS.particles` array
  25642. * `faceId` is the picked face index counted within this particle.
  25643. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25644. */
  25645. pickedParticles: {
  25646. idx: number;
  25647. faceId: number;
  25648. }[];
  25649. /**
  25650. * This array is populated when `enableDepthSort` is set to true.
  25651. * Each element of this array is an instance of the class DepthSortedParticle.
  25652. */
  25653. depthSortedParticles: DepthSortedParticle[];
  25654. /**
  25655. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25656. * @hidden
  25657. */
  25658. _bSphereOnly: boolean;
  25659. /**
  25660. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25661. * @hidden
  25662. */
  25663. _bSphereRadiusFactor: number;
  25664. private _scene;
  25665. private _positions;
  25666. private _indices;
  25667. private _normals;
  25668. private _colors;
  25669. private _uvs;
  25670. private _indices32;
  25671. private _positions32;
  25672. private _normals32;
  25673. private _fixedNormal32;
  25674. private _colors32;
  25675. private _uvs32;
  25676. private _index;
  25677. private _updatable;
  25678. private _pickable;
  25679. private _isVisibilityBoxLocked;
  25680. private _alwaysVisible;
  25681. private _depthSort;
  25682. private _shapeCounter;
  25683. private _copy;
  25684. private _color;
  25685. private _computeParticleColor;
  25686. private _computeParticleTexture;
  25687. private _computeParticleRotation;
  25688. private _computeParticleVertex;
  25689. private _computeBoundingBox;
  25690. private _depthSortParticles;
  25691. private _camera;
  25692. private _mustUnrotateFixedNormals;
  25693. private _particlesIntersect;
  25694. private _needs32Bits;
  25695. /**
  25696. * Creates a SPS (Solid Particle System) object.
  25697. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25698. * @param scene (Scene) is the scene in which the SPS is added.
  25699. * @param options defines the options of the sps e.g.
  25700. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25701. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25702. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25703. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25704. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25705. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25706. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25707. */
  25708. constructor(name: string, scene: Scene, options?: {
  25709. updatable?: boolean;
  25710. isPickable?: boolean;
  25711. enableDepthSort?: boolean;
  25712. particleIntersection?: boolean;
  25713. boundingSphereOnly?: boolean;
  25714. bSphereRadiusFactor?: number;
  25715. });
  25716. /**
  25717. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25718. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25719. * @returns the created mesh
  25720. */
  25721. buildMesh(): Mesh;
  25722. /**
  25723. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25724. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25725. * Thus the particles generated from `digest()` have their property `position` set yet.
  25726. * @param mesh ( Mesh ) is the mesh to be digested
  25727. * @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
  25728. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25729. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25730. * @returns the current SPS
  25731. */
  25732. digest(mesh: Mesh, options?: {
  25733. facetNb?: number;
  25734. number?: number;
  25735. delta?: number;
  25736. }): SolidParticleSystem;
  25737. private _unrotateFixedNormals;
  25738. private _resetCopy;
  25739. private _meshBuilder;
  25740. private _posToShape;
  25741. private _uvsToShapeUV;
  25742. private _addParticle;
  25743. /**
  25744. * Adds some particles to the SPS from the model shape. Returns the shape id.
  25745. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  25746. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  25747. * @param nb (positive integer) the number of particles to be created from this model
  25748. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  25749. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  25750. * @returns the number of shapes in the system
  25751. */
  25752. addShape(mesh: Mesh, nb: number, options?: {
  25753. positionFunction?: any;
  25754. vertexFunction?: any;
  25755. }): number;
  25756. private _rebuildParticle;
  25757. /**
  25758. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  25759. * @returns the SPS.
  25760. */
  25761. rebuildMesh(): SolidParticleSystem;
  25762. /**
  25763. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  25764. * This method calls `updateParticle()` for each particle of the SPS.
  25765. * For an animated SPS, it is usually called within the render loop.
  25766. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  25767. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  25768. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  25769. * @returns the SPS.
  25770. */
  25771. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  25772. /**
  25773. * Disposes the SPS.
  25774. */
  25775. dispose(): void;
  25776. /**
  25777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  25778. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25779. * @returns the SPS.
  25780. */
  25781. refreshVisibleSize(): SolidParticleSystem;
  25782. /**
  25783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  25784. * @param size the size (float) of the visibility box
  25785. * note : this doesn't lock the SPS mesh bounding box.
  25786. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25787. */
  25788. setVisibilityBox(size: number): void;
  25789. /**
  25790. * Gets whether the SPS as always visible or not
  25791. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25792. */
  25793. /**
  25794. * Sets the SPS as always visible or not
  25795. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25796. */
  25797. isAlwaysVisible: boolean;
  25798. /**
  25799. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25800. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25801. */
  25802. /**
  25803. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  25804. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  25805. */
  25806. isVisibilityBoxLocked: boolean;
  25807. /**
  25808. * Tells to `setParticles()` to compute 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. /**
  25813. * Gets if `setParticles()` computes the particle rotations or not.
  25814. * Default value : true. The SPS is faster when it's set to false.
  25815. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  25816. */
  25817. computeParticleRotation: boolean;
  25818. /**
  25819. * Tells to `setParticles()` to compute 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. /**
  25824. * Gets if `setParticles()` computes the particle colors or not.
  25825. * Default value : true. The SPS is faster when it's set to false.
  25826. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  25827. */
  25828. computeParticleColor: boolean;
  25829. /**
  25830. * Gets if `setParticles()` computes the particle textures or not.
  25831. * Default value : true. The SPS is faster when it's set to false.
  25832. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  25833. */
  25834. computeParticleTexture: boolean;
  25835. /**
  25836. * Tells to `setParticles()` to call 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. /**
  25841. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  25842. * Default value : false. The SPS is faster when it's set to false.
  25843. * Note : the particle custom vertex positions aren't stored values.
  25844. */
  25845. computeParticleVertex: boolean;
  25846. /**
  25847. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  25848. */
  25849. /**
  25850. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  25851. */
  25852. computeBoundingBox: boolean;
  25853. /**
  25854. * Tells to `setParticles()` to sort 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. /**
  25859. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  25860. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  25861. * Default : `true`
  25862. */
  25863. depthSortParticles: boolean;
  25864. /**
  25865. * This function does nothing. It may be overwritten to set all the particle first values.
  25866. * The SPS doesn't call this function, you may have to call it by your own.
  25867. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25868. */
  25869. initParticles(): void;
  25870. /**
  25871. * This function does nothing. It may be overwritten to recycle a particle.
  25872. * The SPS doesn't call this function, you may have to call it by your own.
  25873. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25874. * @param particle The particle to recycle
  25875. * @returns the recycled particle
  25876. */
  25877. recycleParticle(particle: SolidParticle): SolidParticle;
  25878. /**
  25879. * Updates a particle : this function should be overwritten by the user.
  25880. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  25881. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  25882. * @example : just set a particle position or velocity and recycle conditions
  25883. * @param particle The particle to update
  25884. * @returns the updated particle
  25885. */
  25886. updateParticle(particle: SolidParticle): SolidParticle;
  25887. /**
  25888. * Updates a vertex of a particle : it can be overwritten by the user.
  25889. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  25890. * @param particle the current particle
  25891. * @param vertex the current index of the current particle
  25892. * @param pt the index of the current vertex in the particle shape
  25893. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  25894. * @example : just set a vertex particle position
  25895. * @returns the updated vertex
  25896. */
  25897. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  25898. /**
  25899. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  25900. * This does nothing and may be overwritten by the user.
  25901. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25902. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25903. * @param update the boolean update value actually passed to setParticles()
  25904. */
  25905. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25906. /**
  25907. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  25908. * This will be passed three parameters.
  25909. * This does nothing and may be overwritten by the user.
  25910. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25911. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  25912. * @param update the boolean update value actually passed to setParticles()
  25913. */
  25914. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  25915. }
  25916. }
  25917. declare module "babylonjs/Particles/solidParticle" {
  25918. import { Nullable } from "babylonjs/types";
  25919. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  25920. import { Color4 } from "babylonjs/Maths/math.color";
  25921. import { Mesh } from "babylonjs/Meshes/mesh";
  25922. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25923. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  25924. import { Plane } from "babylonjs/Maths/math.plane";
  25925. /**
  25926. * Represents one particle of a solid particle system.
  25927. */
  25928. export class SolidParticle {
  25929. /**
  25930. * particle global index
  25931. */
  25932. idx: number;
  25933. /**
  25934. * The color of the particle
  25935. */
  25936. color: Nullable<Color4>;
  25937. /**
  25938. * The world space position of the particle.
  25939. */
  25940. position: Vector3;
  25941. /**
  25942. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  25943. */
  25944. rotation: Vector3;
  25945. /**
  25946. * The world space rotation quaternion of the particle.
  25947. */
  25948. rotationQuaternion: Nullable<Quaternion>;
  25949. /**
  25950. * The scaling of the particle.
  25951. */
  25952. scaling: Vector3;
  25953. /**
  25954. * The uvs of the particle.
  25955. */
  25956. uvs: Vector4;
  25957. /**
  25958. * The current speed of the particle.
  25959. */
  25960. velocity: Vector3;
  25961. /**
  25962. * The pivot point in the particle local space.
  25963. */
  25964. pivot: Vector3;
  25965. /**
  25966. * Must the particle be translated from its pivot point in its local space ?
  25967. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  25968. * Default : false
  25969. */
  25970. translateFromPivot: boolean;
  25971. /**
  25972. * Is the particle active or not ?
  25973. */
  25974. alive: boolean;
  25975. /**
  25976. * Is the particle visible or not ?
  25977. */
  25978. isVisible: boolean;
  25979. /**
  25980. * Index of this particle in the global "positions" array (Internal use)
  25981. * @hidden
  25982. */
  25983. _pos: number;
  25984. /**
  25985. * @hidden Index of this particle in the global "indices" array (Internal use)
  25986. */
  25987. _ind: number;
  25988. /**
  25989. * @hidden ModelShape of this particle (Internal use)
  25990. */
  25991. _model: ModelShape;
  25992. /**
  25993. * ModelShape id of this particle
  25994. */
  25995. shapeId: number;
  25996. /**
  25997. * Index of the particle in its shape id (Internal use)
  25998. */
  25999. idxInShape: number;
  26000. /**
  26001. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26002. */
  26003. _modelBoundingInfo: BoundingInfo;
  26004. /**
  26005. * @hidden Particle BoundingInfo object (Internal use)
  26006. */
  26007. _boundingInfo: BoundingInfo;
  26008. /**
  26009. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26010. */
  26011. _sps: SolidParticleSystem;
  26012. /**
  26013. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26014. */
  26015. _stillInvisible: boolean;
  26016. /**
  26017. * @hidden Last computed particle rotation matrix
  26018. */
  26019. _rotationMatrix: number[];
  26020. /**
  26021. * Parent particle Id, if any.
  26022. * Default null.
  26023. */
  26024. parentId: Nullable<number>;
  26025. /**
  26026. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26027. * The possible values are :
  26028. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26029. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26030. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26031. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26032. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26033. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26034. * */
  26035. cullingStrategy: number;
  26036. /**
  26037. * @hidden Internal global position in the SPS.
  26038. */
  26039. _globalPosition: Vector3;
  26040. /**
  26041. * Creates a Solid Particle object.
  26042. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26043. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26044. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26045. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26046. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26047. * @param shapeId (integer) is the model shape identifier in the SPS.
  26048. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26049. * @param sps defines the sps it is associated to
  26050. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26051. */
  26052. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26053. /**
  26054. * Legacy support, changed scale to scaling
  26055. */
  26056. /**
  26057. * Legacy support, changed scale to scaling
  26058. */
  26059. scale: Vector3;
  26060. /**
  26061. * Legacy support, changed quaternion to rotationQuaternion
  26062. */
  26063. /**
  26064. * Legacy support, changed quaternion to rotationQuaternion
  26065. */
  26066. quaternion: Nullable<Quaternion>;
  26067. /**
  26068. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26069. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26070. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26071. * @returns true if it intersects
  26072. */
  26073. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26074. /**
  26075. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26076. * A particle is in the frustum if its bounding box intersects the frustum
  26077. * @param frustumPlanes defines the frustum to test
  26078. * @returns true if the particle is in the frustum planes
  26079. */
  26080. isInFrustum(frustumPlanes: Plane[]): boolean;
  26081. /**
  26082. * get the rotation matrix of the particle
  26083. * @hidden
  26084. */
  26085. getRotationMatrix(m: Matrix): void;
  26086. }
  26087. /**
  26088. * Represents the shape of the model used by one particle of a solid particle system.
  26089. * SPS internal tool, don't use it manually.
  26090. */
  26091. export class ModelShape {
  26092. /**
  26093. * The shape id
  26094. * @hidden
  26095. */
  26096. shapeID: number;
  26097. /**
  26098. * flat array of model positions (internal use)
  26099. * @hidden
  26100. */
  26101. _shape: Vector3[];
  26102. /**
  26103. * flat array of model UVs (internal use)
  26104. * @hidden
  26105. */
  26106. _shapeUV: number[];
  26107. /**
  26108. * length of the shape in the model indices array (internal use)
  26109. * @hidden
  26110. */
  26111. _indicesLength: number;
  26112. /**
  26113. * Custom position function (internal use)
  26114. * @hidden
  26115. */
  26116. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26117. /**
  26118. * Custom vertex function (internal use)
  26119. * @hidden
  26120. */
  26121. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26122. /**
  26123. * 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.
  26124. * SPS internal tool, don't use it manually.
  26125. * @hidden
  26126. */
  26127. 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>);
  26128. }
  26129. /**
  26130. * Represents a Depth Sorted Particle in the solid particle system.
  26131. */
  26132. export class DepthSortedParticle {
  26133. /**
  26134. * Index of the particle in the "indices" array
  26135. */
  26136. ind: number;
  26137. /**
  26138. * Length of the particle shape in the "indices" array
  26139. */
  26140. indicesLength: number;
  26141. /**
  26142. * Squared distance from the particle to the camera
  26143. */
  26144. sqDistance: number;
  26145. }
  26146. }
  26147. declare module "babylonjs/Collisions/meshCollisionData" {
  26148. import { Collider } from "babylonjs/Collisions/collider";
  26149. import { Vector3 } from "babylonjs/Maths/math.vector";
  26150. import { Nullable } from "babylonjs/types";
  26151. import { Observer } from "babylonjs/Misc/observable";
  26152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26153. /**
  26154. * @hidden
  26155. */
  26156. export class _MeshCollisionData {
  26157. _checkCollisions: boolean;
  26158. _collisionMask: number;
  26159. _collisionGroup: number;
  26160. _collider: Nullable<Collider>;
  26161. _oldPositionForCollisions: Vector3;
  26162. _diffPositionForCollisions: Vector3;
  26163. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26164. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26165. }
  26166. }
  26167. declare module "babylonjs/Meshes/abstractMesh" {
  26168. import { Observable } from "babylonjs/Misc/observable";
  26169. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26170. import { Camera } from "babylonjs/Cameras/camera";
  26171. import { Scene, IDisposable } from "babylonjs/scene";
  26172. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26173. import { Node } from "babylonjs/node";
  26174. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26175. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26177. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26178. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26179. import { Material } from "babylonjs/Materials/material";
  26180. import { Light } from "babylonjs/Lights/light";
  26181. import { Skeleton } from "babylonjs/Bones/skeleton";
  26182. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26183. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26184. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26185. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26186. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26187. import { Plane } from "babylonjs/Maths/math.plane";
  26188. import { Ray } from "babylonjs/Culling/ray";
  26189. import { Collider } from "babylonjs/Collisions/collider";
  26190. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26191. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26192. /** @hidden */
  26193. class _FacetDataStorage {
  26194. facetPositions: Vector3[];
  26195. facetNormals: Vector3[];
  26196. facetPartitioning: number[][];
  26197. facetNb: number;
  26198. partitioningSubdivisions: number;
  26199. partitioningBBoxRatio: number;
  26200. facetDataEnabled: boolean;
  26201. facetParameters: any;
  26202. bbSize: Vector3;
  26203. subDiv: {
  26204. max: number;
  26205. X: number;
  26206. Y: number;
  26207. Z: number;
  26208. };
  26209. facetDepthSort: boolean;
  26210. facetDepthSortEnabled: boolean;
  26211. depthSortedIndices: IndicesArray;
  26212. depthSortedFacets: {
  26213. ind: number;
  26214. sqDistance: number;
  26215. }[];
  26216. facetDepthSortFunction: (f1: {
  26217. ind: number;
  26218. sqDistance: number;
  26219. }, f2: {
  26220. ind: number;
  26221. sqDistance: number;
  26222. }) => number;
  26223. facetDepthSortFrom: Vector3;
  26224. facetDepthSortOrigin: Vector3;
  26225. invertedMatrix: Matrix;
  26226. }
  26227. /**
  26228. * @hidden
  26229. **/
  26230. class _InternalAbstractMeshDataInfo {
  26231. _hasVertexAlpha: boolean;
  26232. _useVertexColors: boolean;
  26233. _numBoneInfluencers: number;
  26234. _applyFog: boolean;
  26235. _receiveShadows: boolean;
  26236. _facetData: _FacetDataStorage;
  26237. _visibility: number;
  26238. _skeleton: Nullable<Skeleton>;
  26239. _layerMask: number;
  26240. _computeBonesUsingShaders: boolean;
  26241. _isActive: boolean;
  26242. _onlyForInstances: boolean;
  26243. _isActiveIntermediate: boolean;
  26244. _onlyForInstancesIntermediate: boolean;
  26245. }
  26246. /**
  26247. * Class used to store all common mesh properties
  26248. */
  26249. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26250. /** No occlusion */
  26251. static OCCLUSION_TYPE_NONE: number;
  26252. /** Occlusion set to optimisitic */
  26253. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26254. /** Occlusion set to strict */
  26255. static OCCLUSION_TYPE_STRICT: number;
  26256. /** Use an accurante occlusion algorithm */
  26257. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26258. /** Use a conservative occlusion algorithm */
  26259. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26260. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26261. * Test order :
  26262. * Is the bounding sphere outside the frustum ?
  26263. * If not, are the bounding box vertices outside the frustum ?
  26264. * It not, then the cullable object is in the frustum.
  26265. */
  26266. static readonly CULLINGSTRATEGY_STANDARD: number;
  26267. /** Culling strategy : Bounding Sphere Only.
  26268. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26269. * It's also less accurate than the standard because some not visible objects can still be selected.
  26270. * Test : is the bounding sphere outside the frustum ?
  26271. * If not, then the cullable object is in the frustum.
  26272. */
  26273. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26274. /** Culling strategy : Optimistic Inclusion.
  26275. * This in an inclusion test first, then the standard exclusion test.
  26276. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26277. * 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.
  26278. * Anyway, it's as accurate as the standard strategy.
  26279. * Test :
  26280. * Is the cullable object bounding sphere center in the frustum ?
  26281. * If not, apply the default culling strategy.
  26282. */
  26283. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26284. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26285. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26286. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26287. * 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.
  26288. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26289. * Test :
  26290. * Is the cullable object bounding sphere center in the frustum ?
  26291. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26292. */
  26293. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26294. /**
  26295. * No billboard
  26296. */
  26297. static readonly BILLBOARDMODE_NONE: number;
  26298. /** Billboard on X axis */
  26299. static readonly BILLBOARDMODE_X: number;
  26300. /** Billboard on Y axis */
  26301. static readonly BILLBOARDMODE_Y: number;
  26302. /** Billboard on Z axis */
  26303. static readonly BILLBOARDMODE_Z: number;
  26304. /** Billboard on all axes */
  26305. static readonly BILLBOARDMODE_ALL: number;
  26306. /** @hidden */
  26307. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26308. /**
  26309. * The culling strategy to use to check whether the mesh must be rendered or not.
  26310. * This value can be changed at any time and will be used on the next render mesh selection.
  26311. * The possible values are :
  26312. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26313. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26314. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26315. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26316. * Please read each static variable documentation to get details about the culling process.
  26317. * */
  26318. cullingStrategy: number;
  26319. /**
  26320. * Gets the number of facets in the mesh
  26321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26322. */
  26323. readonly facetNb: number;
  26324. /**
  26325. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26327. */
  26328. partitioningSubdivisions: number;
  26329. /**
  26330. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26331. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26333. */
  26334. partitioningBBoxRatio: number;
  26335. /**
  26336. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26337. * Works only for updatable meshes.
  26338. * Doesn't work with multi-materials
  26339. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26340. */
  26341. mustDepthSortFacets: boolean;
  26342. /**
  26343. * The location (Vector3) where the facet depth sort must be computed from.
  26344. * By default, the active camera position.
  26345. * Used only when facet depth sort is enabled
  26346. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26347. */
  26348. facetDepthSortFrom: Vector3;
  26349. /**
  26350. * gets a boolean indicating if facetData is enabled
  26351. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26352. */
  26353. readonly isFacetDataEnabled: boolean;
  26354. /** @hidden */
  26355. _updateNonUniformScalingState(value: boolean): boolean;
  26356. /**
  26357. * An event triggered when this mesh collides with another one
  26358. */
  26359. onCollideObservable: Observable<AbstractMesh>;
  26360. /** Set a function to call when this mesh collides with another one */
  26361. onCollide: () => void;
  26362. /**
  26363. * An event triggered when the collision's position changes
  26364. */
  26365. onCollisionPositionChangeObservable: Observable<Vector3>;
  26366. /** Set a function to call when the collision's position changes */
  26367. onCollisionPositionChange: () => void;
  26368. /**
  26369. * An event triggered when material is changed
  26370. */
  26371. onMaterialChangedObservable: Observable<AbstractMesh>;
  26372. /**
  26373. * Gets or sets the orientation for POV movement & rotation
  26374. */
  26375. definedFacingForward: boolean;
  26376. /** @hidden */
  26377. _occlusionQuery: Nullable<WebGLQuery>;
  26378. /** @hidden */
  26379. _renderingGroup: Nullable<RenderingGroup>;
  26380. /**
  26381. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26382. */
  26383. /**
  26384. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26385. */
  26386. visibility: number;
  26387. /** Gets or sets the alpha index used to sort transparent meshes
  26388. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26389. */
  26390. alphaIndex: number;
  26391. /**
  26392. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26393. */
  26394. isVisible: boolean;
  26395. /**
  26396. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26397. */
  26398. isPickable: boolean;
  26399. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26400. showSubMeshesBoundingBox: boolean;
  26401. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26402. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26403. */
  26404. isBlocker: boolean;
  26405. /**
  26406. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26407. */
  26408. enablePointerMoveEvents: boolean;
  26409. /**
  26410. * Specifies the rendering group id for this mesh (0 by default)
  26411. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26412. */
  26413. renderingGroupId: number;
  26414. private _material;
  26415. /** Gets or sets current material */
  26416. material: Nullable<Material>;
  26417. /**
  26418. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26419. * @see http://doc.babylonjs.com/babylon101/shadows
  26420. */
  26421. receiveShadows: boolean;
  26422. /** Defines color to use when rendering outline */
  26423. outlineColor: Color3;
  26424. /** Define width to use when rendering outline */
  26425. outlineWidth: number;
  26426. /** Defines color to use when rendering overlay */
  26427. overlayColor: Color3;
  26428. /** Defines alpha to use when rendering overlay */
  26429. overlayAlpha: number;
  26430. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26431. hasVertexAlpha: boolean;
  26432. /** 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) */
  26433. useVertexColors: boolean;
  26434. /**
  26435. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26436. */
  26437. computeBonesUsingShaders: boolean;
  26438. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26439. numBoneInfluencers: number;
  26440. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26441. applyFog: boolean;
  26442. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26443. useOctreeForRenderingSelection: boolean;
  26444. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26445. useOctreeForPicking: boolean;
  26446. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26447. useOctreeForCollisions: boolean;
  26448. /**
  26449. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26450. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26451. */
  26452. layerMask: number;
  26453. /**
  26454. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26455. */
  26456. alwaysSelectAsActiveMesh: boolean;
  26457. /**
  26458. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26459. */
  26460. doNotSyncBoundingInfo: boolean;
  26461. /**
  26462. * Gets or sets the current action manager
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26464. */
  26465. actionManager: Nullable<AbstractActionManager>;
  26466. private _meshCollisionData;
  26467. /**
  26468. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26469. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26470. */
  26471. ellipsoid: Vector3;
  26472. /**
  26473. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26474. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26475. */
  26476. ellipsoidOffset: Vector3;
  26477. /**
  26478. * Gets or sets a collision mask used to mask collisions (default is -1).
  26479. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26480. */
  26481. collisionMask: number;
  26482. /**
  26483. * Gets or sets the current collision group mask (-1 by default).
  26484. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26485. */
  26486. collisionGroup: number;
  26487. /**
  26488. * Defines edge width used when edgesRenderer is enabled
  26489. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26490. */
  26491. edgesWidth: number;
  26492. /**
  26493. * Defines edge color used when edgesRenderer is enabled
  26494. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26495. */
  26496. edgesColor: Color4;
  26497. /** @hidden */
  26498. _edgesRenderer: Nullable<IEdgesRenderer>;
  26499. /** @hidden */
  26500. _masterMesh: Nullable<AbstractMesh>;
  26501. /** @hidden */
  26502. _boundingInfo: Nullable<BoundingInfo>;
  26503. /** @hidden */
  26504. _renderId: number;
  26505. /**
  26506. * Gets or sets the list of subMeshes
  26507. * @see http://doc.babylonjs.com/how_to/multi_materials
  26508. */
  26509. subMeshes: SubMesh[];
  26510. /** @hidden */
  26511. _intersectionsInProgress: AbstractMesh[];
  26512. /** @hidden */
  26513. _unIndexed: boolean;
  26514. /** @hidden */
  26515. _lightSources: Light[];
  26516. /** Gets the list of lights affecting that mesh */
  26517. readonly lightSources: Light[];
  26518. /** @hidden */
  26519. readonly _positions: Nullable<Vector3[]>;
  26520. /** @hidden */
  26521. _waitingData: {
  26522. lods: Nullable<any>;
  26523. actions: Nullable<any>;
  26524. freezeWorldMatrix: Nullable<boolean>;
  26525. };
  26526. /** @hidden */
  26527. _bonesTransformMatrices: Nullable<Float32Array>;
  26528. /** @hidden */
  26529. _transformMatrixTexture: Nullable<RawTexture>;
  26530. /**
  26531. * Gets or sets a skeleton to apply skining transformations
  26532. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26533. */
  26534. skeleton: Nullable<Skeleton>;
  26535. /**
  26536. * An event triggered when the mesh is rebuilt.
  26537. */
  26538. onRebuildObservable: Observable<AbstractMesh>;
  26539. /**
  26540. * Creates a new AbstractMesh
  26541. * @param name defines the name of the mesh
  26542. * @param scene defines the hosting scene
  26543. */
  26544. constructor(name: string, scene?: Nullable<Scene>);
  26545. /**
  26546. * Returns the string "AbstractMesh"
  26547. * @returns "AbstractMesh"
  26548. */
  26549. getClassName(): string;
  26550. /**
  26551. * Gets a string representation of the current mesh
  26552. * @param fullDetails defines a boolean indicating if full details must be included
  26553. * @returns a string representation of the current mesh
  26554. */
  26555. toString(fullDetails?: boolean): string;
  26556. /**
  26557. * @hidden
  26558. */
  26559. protected _getEffectiveParent(): Nullable<Node>;
  26560. /** @hidden */
  26561. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26562. /** @hidden */
  26563. _rebuild(): void;
  26564. /** @hidden */
  26565. _resyncLightSources(): void;
  26566. /** @hidden */
  26567. _resyncLighSource(light: Light): void;
  26568. /** @hidden */
  26569. _unBindEffect(): void;
  26570. /** @hidden */
  26571. _removeLightSource(light: Light): void;
  26572. private _markSubMeshesAsDirty;
  26573. /** @hidden */
  26574. _markSubMeshesAsLightDirty(): void;
  26575. /** @hidden */
  26576. _markSubMeshesAsAttributesDirty(): void;
  26577. /** @hidden */
  26578. _markSubMeshesAsMiscDirty(): void;
  26579. /**
  26580. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26581. */
  26582. scaling: Vector3;
  26583. /**
  26584. * Returns true if the mesh is blocked. Implemented by child classes
  26585. */
  26586. readonly isBlocked: boolean;
  26587. /**
  26588. * Returns the mesh itself by default. Implemented by child classes
  26589. * @param camera defines the camera to use to pick the right LOD level
  26590. * @returns the currentAbstractMesh
  26591. */
  26592. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26593. /**
  26594. * Returns 0 by default. Implemented by child classes
  26595. * @returns an integer
  26596. */
  26597. getTotalVertices(): number;
  26598. /**
  26599. * Returns a positive integer : the total number of indices in this mesh geometry.
  26600. * @returns the numner of indices or zero if the mesh has no geometry.
  26601. */
  26602. getTotalIndices(): number;
  26603. /**
  26604. * Returns null by default. Implemented by child classes
  26605. * @returns null
  26606. */
  26607. getIndices(): Nullable<IndicesArray>;
  26608. /**
  26609. * Returns the array of the requested vertex data kind. Implemented by child classes
  26610. * @param kind defines the vertex data kind to use
  26611. * @returns null
  26612. */
  26613. getVerticesData(kind: string): Nullable<FloatArray>;
  26614. /**
  26615. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26616. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26617. * Note that a new underlying VertexBuffer object is created each call.
  26618. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26619. * @param kind defines vertex data kind:
  26620. * * VertexBuffer.PositionKind
  26621. * * VertexBuffer.UVKind
  26622. * * VertexBuffer.UV2Kind
  26623. * * VertexBuffer.UV3Kind
  26624. * * VertexBuffer.UV4Kind
  26625. * * VertexBuffer.UV5Kind
  26626. * * VertexBuffer.UV6Kind
  26627. * * VertexBuffer.ColorKind
  26628. * * VertexBuffer.MatricesIndicesKind
  26629. * * VertexBuffer.MatricesIndicesExtraKind
  26630. * * VertexBuffer.MatricesWeightsKind
  26631. * * VertexBuffer.MatricesWeightsExtraKind
  26632. * @param data defines the data source
  26633. * @param updatable defines if the data must be flagged as updatable (or static)
  26634. * @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
  26635. * @returns the current mesh
  26636. */
  26637. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26638. /**
  26639. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26640. * If the mesh has no geometry, it is simply returned as it is.
  26641. * @param kind defines vertex data kind:
  26642. * * VertexBuffer.PositionKind
  26643. * * VertexBuffer.UVKind
  26644. * * VertexBuffer.UV2Kind
  26645. * * VertexBuffer.UV3Kind
  26646. * * VertexBuffer.UV4Kind
  26647. * * VertexBuffer.UV5Kind
  26648. * * VertexBuffer.UV6Kind
  26649. * * VertexBuffer.ColorKind
  26650. * * VertexBuffer.MatricesIndicesKind
  26651. * * VertexBuffer.MatricesIndicesExtraKind
  26652. * * VertexBuffer.MatricesWeightsKind
  26653. * * VertexBuffer.MatricesWeightsExtraKind
  26654. * @param data defines the data source
  26655. * @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
  26656. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26657. * @returns the current mesh
  26658. */
  26659. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26660. /**
  26661. * Sets the mesh indices,
  26662. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26663. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26664. * @param totalVertices Defines the total number of vertices
  26665. * @returns the current mesh
  26666. */
  26667. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26668. /**
  26669. * Gets a boolean indicating if specific vertex data is present
  26670. * @param kind defines the vertex data kind to use
  26671. * @returns true is data kind is present
  26672. */
  26673. isVerticesDataPresent(kind: string): boolean;
  26674. /**
  26675. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26676. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26677. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26678. * @returns a BoundingInfo
  26679. */
  26680. getBoundingInfo(): BoundingInfo;
  26681. /**
  26682. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26683. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26684. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26685. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26686. * @returns the current mesh
  26687. */
  26688. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26689. /**
  26690. * Overwrite the current bounding info
  26691. * @param boundingInfo defines the new bounding info
  26692. * @returns the current mesh
  26693. */
  26694. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26695. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26696. readonly useBones: boolean;
  26697. /** @hidden */
  26698. _preActivate(): void;
  26699. /** @hidden */
  26700. _preActivateForIntermediateRendering(renderId: number): void;
  26701. /** @hidden */
  26702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26703. /** @hidden */
  26704. _postActivate(): void;
  26705. /** @hidden */
  26706. _freeze(): void;
  26707. /** @hidden */
  26708. _unFreeze(): void;
  26709. /**
  26710. * Gets the current world matrix
  26711. * @returns a Matrix
  26712. */
  26713. getWorldMatrix(): Matrix;
  26714. /** @hidden */
  26715. _getWorldMatrixDeterminant(): number;
  26716. /**
  26717. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26718. */
  26719. readonly isAnInstance: boolean;
  26720. /**
  26721. * Perform relative position change from the point of view of behind the front of the mesh.
  26722. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26723. * Supports definition of mesh facing forward or backward
  26724. * @param amountRight defines the distance on the right axis
  26725. * @param amountUp defines the distance on the up axis
  26726. * @param amountForward defines the distance on the forward axis
  26727. * @returns the current mesh
  26728. */
  26729. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  26730. /**
  26731. * Calculate relative position change from the point of view of behind the front of the mesh.
  26732. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26733. * Supports definition of mesh facing forward or backward
  26734. * @param amountRight defines the distance on the right axis
  26735. * @param amountUp defines the distance on the up axis
  26736. * @param amountForward defines the distance on the forward axis
  26737. * @returns the new displacement vector
  26738. */
  26739. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  26740. /**
  26741. * Perform relative rotation change from the point of view of behind the front of the mesh.
  26742. * Supports definition of mesh facing forward or backward
  26743. * @param flipBack defines the flip
  26744. * @param twirlClockwise defines the twirl
  26745. * @param tiltRight defines the tilt
  26746. * @returns the current mesh
  26747. */
  26748. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  26749. /**
  26750. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  26751. * Supports definition of mesh facing forward or backward.
  26752. * @param flipBack defines the flip
  26753. * @param twirlClockwise defines the twirl
  26754. * @param tiltRight defines the tilt
  26755. * @returns the new rotation vector
  26756. */
  26757. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  26758. /**
  26759. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  26760. * This means the mesh underlying bounding box and sphere are recomputed.
  26761. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  26762. * @returns the current mesh
  26763. */
  26764. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  26765. /** @hidden */
  26766. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  26767. /** @hidden */
  26768. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  26769. /** @hidden */
  26770. _updateBoundingInfo(): AbstractMesh;
  26771. /** @hidden */
  26772. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  26773. /** @hidden */
  26774. protected _afterComputeWorldMatrix(): void;
  26775. /** @hidden */
  26776. readonly _effectiveMesh: AbstractMesh;
  26777. /**
  26778. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  26779. * A mesh is in the frustum if its bounding box intersects the frustum
  26780. * @param frustumPlanes defines the frustum to test
  26781. * @returns true if the mesh is in the frustum planes
  26782. */
  26783. isInFrustum(frustumPlanes: Plane[]): boolean;
  26784. /**
  26785. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  26786. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  26787. * @param frustumPlanes defines the frustum to test
  26788. * @returns true if the mesh is completely in the frustum planes
  26789. */
  26790. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26791. /**
  26792. * True if the mesh intersects another mesh or a SolidParticle object
  26793. * @param mesh defines a target mesh or SolidParticle to test
  26794. * @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)
  26795. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  26796. * @returns true if there is an intersection
  26797. */
  26798. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  26799. /**
  26800. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  26801. * @param point defines the point to test
  26802. * @returns true if there is an intersection
  26803. */
  26804. intersectsPoint(point: Vector3): boolean;
  26805. /**
  26806. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  26807. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26808. */
  26809. checkCollisions: boolean;
  26810. /**
  26811. * Gets Collider object used to compute collisions (not physics)
  26812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26813. */
  26814. readonly collider: Nullable<Collider>;
  26815. /**
  26816. * Move the mesh using collision engine
  26817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26818. * @param displacement defines the requested displacement vector
  26819. * @returns the current mesh
  26820. */
  26821. moveWithCollisions(displacement: Vector3): AbstractMesh;
  26822. private _onCollisionPositionChange;
  26823. /** @hidden */
  26824. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  26825. /** @hidden */
  26826. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  26827. /** @hidden */
  26828. _checkCollision(collider: Collider): AbstractMesh;
  26829. /** @hidden */
  26830. _generatePointsArray(): boolean;
  26831. /**
  26832. * Checks if the passed Ray intersects with the mesh
  26833. * @param ray defines the ray to use
  26834. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  26835. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26836. * @returns the picking info
  26837. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  26838. */
  26839. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  26840. /**
  26841. * Clones the current mesh
  26842. * @param name defines the mesh name
  26843. * @param newParent defines the new mesh parent
  26844. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  26845. * @returns the new mesh
  26846. */
  26847. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  26848. /**
  26849. * Disposes all the submeshes of the current meshnp
  26850. * @returns the current mesh
  26851. */
  26852. releaseSubMeshes(): AbstractMesh;
  26853. /**
  26854. * Releases resources associated with this abstract mesh.
  26855. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26856. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26857. */
  26858. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26859. /**
  26860. * Adds the passed mesh as a child to the current mesh
  26861. * @param mesh defines the child mesh
  26862. * @returns the current mesh
  26863. */
  26864. addChild(mesh: AbstractMesh): AbstractMesh;
  26865. /**
  26866. * Removes the passed mesh from the current mesh children list
  26867. * @param mesh defines the child mesh
  26868. * @returns the current mesh
  26869. */
  26870. removeChild(mesh: AbstractMesh): AbstractMesh;
  26871. /** @hidden */
  26872. private _initFacetData;
  26873. /**
  26874. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  26875. * This method can be called within the render loop.
  26876. * 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
  26877. * @returns the current mesh
  26878. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26879. */
  26880. updateFacetData(): AbstractMesh;
  26881. /**
  26882. * Returns the facetLocalNormals array.
  26883. * The normals are expressed in the mesh local spac
  26884. * @returns an array of Vector3
  26885. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26886. */
  26887. getFacetLocalNormals(): Vector3[];
  26888. /**
  26889. * Returns the facetLocalPositions array.
  26890. * The facet positions are expressed in the mesh local space
  26891. * @returns an array of Vector3
  26892. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26893. */
  26894. getFacetLocalPositions(): Vector3[];
  26895. /**
  26896. * Returns the facetLocalPartioning array
  26897. * @returns an array of array of numbers
  26898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26899. */
  26900. getFacetLocalPartitioning(): number[][];
  26901. /**
  26902. * Returns the i-th facet position in the world system.
  26903. * This method allocates a new Vector3 per call
  26904. * @param i defines the facet index
  26905. * @returns a new Vector3
  26906. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26907. */
  26908. getFacetPosition(i: number): Vector3;
  26909. /**
  26910. * Sets the reference Vector3 with the i-th facet position in the world system
  26911. * @param i defines the facet index
  26912. * @param ref defines the target vector
  26913. * @returns the current mesh
  26914. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26915. */
  26916. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  26917. /**
  26918. * Returns the i-th facet normal in the world system.
  26919. * This method allocates a new Vector3 per call
  26920. * @param i defines the facet index
  26921. * @returns a new Vector3
  26922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26923. */
  26924. getFacetNormal(i: number): Vector3;
  26925. /**
  26926. * Sets the reference Vector3 with the i-th facet normal in the world system
  26927. * @param i defines the facet index
  26928. * @param ref defines the target vector
  26929. * @returns the current mesh
  26930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26931. */
  26932. getFacetNormalToRef(i: number, ref: Vector3): this;
  26933. /**
  26934. * 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)
  26935. * @param x defines x coordinate
  26936. * @param y defines y coordinate
  26937. * @param z defines z coordinate
  26938. * @returns the array of facet indexes
  26939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26940. */
  26941. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  26942. /**
  26943. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  26944. * @param projected sets as the (x,y,z) world projection on the facet
  26945. * @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
  26946. * @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
  26947. * @param x defines x coordinate
  26948. * @param y defines y coordinate
  26949. * @param z defines z coordinate
  26950. * @returns the face index if found (or null instead)
  26951. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26952. */
  26953. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26954. /**
  26955. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  26956. * @param projected sets as the (x,y,z) local projection on the facet
  26957. * @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
  26958. * @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
  26959. * @param x defines x coordinate
  26960. * @param y defines y coordinate
  26961. * @param z defines z coordinate
  26962. * @returns the face index if found (or null instead)
  26963. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26964. */
  26965. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  26966. /**
  26967. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  26968. * @returns the parameters
  26969. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26970. */
  26971. getFacetDataParameters(): any;
  26972. /**
  26973. * Disables the feature FacetData and frees the related memory
  26974. * @returns the current mesh
  26975. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  26976. */
  26977. disableFacetData(): AbstractMesh;
  26978. /**
  26979. * Updates the AbstractMesh indices array
  26980. * @param indices defines the data source
  26981. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  26982. * @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)
  26983. * @returns the current mesh
  26984. */
  26985. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  26986. /**
  26987. * Creates new normals data for the mesh
  26988. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  26989. * @returns the current mesh
  26990. */
  26991. createNormals(updatable: boolean): AbstractMesh;
  26992. /**
  26993. * Align the mesh with a normal
  26994. * @param normal defines the normal to use
  26995. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  26996. * @returns the current mesh
  26997. */
  26998. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  26999. /** @hidden */
  27000. _checkOcclusionQuery(): boolean;
  27001. /**
  27002. * Disables the mesh edge rendering mode
  27003. * @returns the currentAbstractMesh
  27004. */
  27005. disableEdgesRendering(): AbstractMesh;
  27006. /**
  27007. * Enables the edge rendering mode on the mesh.
  27008. * This mode makes the mesh edges visible
  27009. * @param epsilon defines the maximal distance between two angles to detect a face
  27010. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27011. * @returns the currentAbstractMesh
  27012. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27013. */
  27014. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27015. }
  27016. }
  27017. declare module "babylonjs/Actions/actionEvent" {
  27018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27019. import { Nullable } from "babylonjs/types";
  27020. import { Sprite } from "babylonjs/Sprites/sprite";
  27021. import { Scene } from "babylonjs/scene";
  27022. import { Vector2 } from "babylonjs/Maths/math.vector";
  27023. /**
  27024. * Interface used to define ActionEvent
  27025. */
  27026. export interface IActionEvent {
  27027. /** The mesh or sprite that triggered the action */
  27028. source: any;
  27029. /** The X mouse cursor position at the time of the event */
  27030. pointerX: number;
  27031. /** The Y mouse cursor position at the time of the event */
  27032. pointerY: number;
  27033. /** The mesh that is currently pointed at (can be null) */
  27034. meshUnderPointer: Nullable<AbstractMesh>;
  27035. /** the original (browser) event that triggered the ActionEvent */
  27036. sourceEvent?: any;
  27037. /** additional data for the event */
  27038. additionalData?: any;
  27039. }
  27040. /**
  27041. * ActionEvent is the event being sent when an action is triggered.
  27042. */
  27043. export class ActionEvent implements IActionEvent {
  27044. /** The mesh or sprite that triggered the action */
  27045. source: any;
  27046. /** The X mouse cursor position at the time of the event */
  27047. pointerX: number;
  27048. /** The Y mouse cursor position at the time of the event */
  27049. pointerY: number;
  27050. /** The mesh that is currently pointed at (can be null) */
  27051. meshUnderPointer: Nullable<AbstractMesh>;
  27052. /** the original (browser) event that triggered the ActionEvent */
  27053. sourceEvent?: any;
  27054. /** additional data for the event */
  27055. additionalData?: any;
  27056. /**
  27057. * Creates a new ActionEvent
  27058. * @param source The mesh or sprite that triggered the action
  27059. * @param pointerX The X mouse cursor position at the time of the event
  27060. * @param pointerY The Y mouse cursor position at the time of the event
  27061. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27062. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27063. * @param additionalData additional data for the event
  27064. */
  27065. constructor(
  27066. /** The mesh or sprite that triggered the action */
  27067. source: any,
  27068. /** The X mouse cursor position at the time of the event */
  27069. pointerX: number,
  27070. /** The Y mouse cursor position at the time of the event */
  27071. pointerY: number,
  27072. /** The mesh that is currently pointed at (can be null) */
  27073. meshUnderPointer: Nullable<AbstractMesh>,
  27074. /** the original (browser) event that triggered the ActionEvent */
  27075. sourceEvent?: any,
  27076. /** additional data for the event */
  27077. additionalData?: any);
  27078. /**
  27079. * Helper function to auto-create an ActionEvent from a source mesh.
  27080. * @param source The source mesh that triggered the event
  27081. * @param evt The original (browser) event
  27082. * @param additionalData additional data for the event
  27083. * @returns the new ActionEvent
  27084. */
  27085. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27086. /**
  27087. * Helper function to auto-create an ActionEvent from a source sprite
  27088. * @param source The source sprite that triggered the event
  27089. * @param scene Scene associated with the sprite
  27090. * @param evt The original (browser) event
  27091. * @param additionalData additional data for the event
  27092. * @returns the new ActionEvent
  27093. */
  27094. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27095. /**
  27096. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27097. * @param scene the scene where the event occurred
  27098. * @param evt The original (browser) event
  27099. * @returns the new ActionEvent
  27100. */
  27101. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27102. /**
  27103. * Helper function to auto-create an ActionEvent from a primitive
  27104. * @param prim defines the target primitive
  27105. * @param pointerPos defines the pointer position
  27106. * @param evt The original (browser) event
  27107. * @param additionalData additional data for the event
  27108. * @returns the new ActionEvent
  27109. */
  27110. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27111. }
  27112. }
  27113. declare module "babylonjs/Actions/abstractActionManager" {
  27114. import { IDisposable } from "babylonjs/scene";
  27115. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27116. import { IAction } from "babylonjs/Actions/action";
  27117. import { Nullable } from "babylonjs/types";
  27118. /**
  27119. * Abstract class used to decouple action Manager from scene and meshes.
  27120. * Do not instantiate.
  27121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27122. */
  27123. export abstract class AbstractActionManager implements IDisposable {
  27124. /** Gets the list of active triggers */
  27125. static Triggers: {
  27126. [key: string]: number;
  27127. };
  27128. /** Gets the cursor to use when hovering items */
  27129. hoverCursor: string;
  27130. /** Gets the list of actions */
  27131. actions: IAction[];
  27132. /**
  27133. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27134. */
  27135. isRecursive: boolean;
  27136. /**
  27137. * Releases all associated resources
  27138. */
  27139. abstract dispose(): void;
  27140. /**
  27141. * Does this action manager has pointer triggers
  27142. */
  27143. abstract readonly hasPointerTriggers: boolean;
  27144. /**
  27145. * Does this action manager has pick triggers
  27146. */
  27147. abstract readonly hasPickTriggers: boolean;
  27148. /**
  27149. * Process a specific trigger
  27150. * @param trigger defines the trigger to process
  27151. * @param evt defines the event details to be processed
  27152. */
  27153. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27154. /**
  27155. * Does this action manager handles actions of any of the given triggers
  27156. * @param triggers defines the triggers to be tested
  27157. * @return a boolean indicating whether one (or more) of the triggers is handled
  27158. */
  27159. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27160. /**
  27161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27162. * speed.
  27163. * @param triggerA defines the trigger to be tested
  27164. * @param triggerB defines the trigger to be tested
  27165. * @return a boolean indicating whether one (or more) of the triggers is handled
  27166. */
  27167. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27168. /**
  27169. * Does this action manager handles actions of a given trigger
  27170. * @param trigger defines the trigger to be tested
  27171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27172. * @return whether the trigger is handled
  27173. */
  27174. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27175. /**
  27176. * Serialize this manager to a JSON object
  27177. * @param name defines the property name to store this manager
  27178. * @returns a JSON representation of this manager
  27179. */
  27180. abstract serialize(name: string): any;
  27181. /**
  27182. * Registers an action to this action manager
  27183. * @param action defines the action to be registered
  27184. * @return the action amended (prepared) after registration
  27185. */
  27186. abstract registerAction(action: IAction): Nullable<IAction>;
  27187. /**
  27188. * Unregisters an action to this action manager
  27189. * @param action defines the action to be unregistered
  27190. * @return a boolean indicating whether the action has been unregistered
  27191. */
  27192. abstract unregisterAction(action: IAction): Boolean;
  27193. /**
  27194. * Does exist one action manager with at least one trigger
  27195. **/
  27196. static readonly HasTriggers: boolean;
  27197. /**
  27198. * Does exist one action manager with at least one pick trigger
  27199. **/
  27200. static readonly HasPickTriggers: boolean;
  27201. /**
  27202. * Does exist one action manager that handles actions of a given trigger
  27203. * @param trigger defines the trigger to be tested
  27204. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27205. **/
  27206. static HasSpecificTrigger(trigger: number): boolean;
  27207. }
  27208. }
  27209. declare module "babylonjs/node" {
  27210. import { Scene } from "babylonjs/scene";
  27211. import { Nullable } from "babylonjs/types";
  27212. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27213. import { Engine } from "babylonjs/Engines/engine";
  27214. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27215. import { Observable } from "babylonjs/Misc/observable";
  27216. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27217. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27218. import { Animatable } from "babylonjs/Animations/animatable";
  27219. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27220. import { Animation } from "babylonjs/Animations/animation";
  27221. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27223. /**
  27224. * Defines how a node can be built from a string name.
  27225. */
  27226. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27227. /**
  27228. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27229. */
  27230. export class Node implements IBehaviorAware<Node> {
  27231. /** @hidden */
  27232. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27233. private static _NodeConstructors;
  27234. /**
  27235. * Add a new node constructor
  27236. * @param type defines the type name of the node to construct
  27237. * @param constructorFunc defines the constructor function
  27238. */
  27239. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27240. /**
  27241. * Returns a node constructor based on type name
  27242. * @param type defines the type name
  27243. * @param name defines the new node name
  27244. * @param scene defines the hosting scene
  27245. * @param options defines optional options to transmit to constructors
  27246. * @returns the new constructor or null
  27247. */
  27248. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27249. /**
  27250. * Gets or sets the name of the node
  27251. */
  27252. name: string;
  27253. /**
  27254. * Gets or sets the id of the node
  27255. */
  27256. id: string;
  27257. /**
  27258. * Gets or sets the unique id of the node
  27259. */
  27260. uniqueId: number;
  27261. /**
  27262. * Gets or sets a string used to store user defined state for the node
  27263. */
  27264. state: string;
  27265. /**
  27266. * Gets or sets an object used to store user defined information for the node
  27267. */
  27268. metadata: any;
  27269. /**
  27270. * For internal use only. Please do not use.
  27271. */
  27272. reservedDataStore: any;
  27273. /**
  27274. * List of inspectable custom properties (used by the Inspector)
  27275. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27276. */
  27277. inspectableCustomProperties: IInspectable[];
  27278. /**
  27279. * Gets or sets a boolean used to define if the node must be serialized
  27280. */
  27281. doNotSerialize: boolean;
  27282. /** @hidden */
  27283. _isDisposed: boolean;
  27284. /**
  27285. * Gets a list of Animations associated with the node
  27286. */
  27287. animations: import("babylonjs/Animations/animation").Animation[];
  27288. protected _ranges: {
  27289. [name: string]: Nullable<AnimationRange>;
  27290. };
  27291. /**
  27292. * Callback raised when the node is ready to be used
  27293. */
  27294. onReady: Nullable<(node: Node) => void>;
  27295. private _isEnabled;
  27296. private _isParentEnabled;
  27297. private _isReady;
  27298. /** @hidden */
  27299. _currentRenderId: number;
  27300. private _parentUpdateId;
  27301. /** @hidden */
  27302. _childUpdateId: number;
  27303. /** @hidden */
  27304. _waitingParentId: Nullable<string>;
  27305. /** @hidden */
  27306. _scene: Scene;
  27307. /** @hidden */
  27308. _cache: any;
  27309. private _parentNode;
  27310. private _children;
  27311. /** @hidden */
  27312. _worldMatrix: Matrix;
  27313. /** @hidden */
  27314. _worldMatrixDeterminant: number;
  27315. /** @hidden */
  27316. _worldMatrixDeterminantIsDirty: boolean;
  27317. /** @hidden */
  27318. private _sceneRootNodesIndex;
  27319. /**
  27320. * Gets a boolean indicating if the node has been disposed
  27321. * @returns true if the node was disposed
  27322. */
  27323. isDisposed(): boolean;
  27324. /**
  27325. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27326. * @see https://doc.babylonjs.com/how_to/parenting
  27327. */
  27328. parent: Nullable<Node>;
  27329. private addToSceneRootNodes;
  27330. private removeFromSceneRootNodes;
  27331. private _animationPropertiesOverride;
  27332. /**
  27333. * Gets or sets the animation properties override
  27334. */
  27335. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27336. /**
  27337. * Gets a string idenfifying the name of the class
  27338. * @returns "Node" string
  27339. */
  27340. getClassName(): string;
  27341. /** @hidden */
  27342. readonly _isNode: boolean;
  27343. /**
  27344. * An event triggered when the mesh is disposed
  27345. */
  27346. onDisposeObservable: Observable<Node>;
  27347. private _onDisposeObserver;
  27348. /**
  27349. * Sets a callback that will be raised when the node will be disposed
  27350. */
  27351. onDispose: () => void;
  27352. /**
  27353. * Creates a new Node
  27354. * @param name the name and id to be given to this node
  27355. * @param scene the scene this node will be added to
  27356. * @param addToRootNodes the node will be added to scene.rootNodes
  27357. */
  27358. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27359. /**
  27360. * Gets the scene of the node
  27361. * @returns a scene
  27362. */
  27363. getScene(): Scene;
  27364. /**
  27365. * Gets the engine of the node
  27366. * @returns a Engine
  27367. */
  27368. getEngine(): Engine;
  27369. private _behaviors;
  27370. /**
  27371. * Attach a behavior to the node
  27372. * @see http://doc.babylonjs.com/features/behaviour
  27373. * @param behavior defines the behavior to attach
  27374. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27375. * @returns the current Node
  27376. */
  27377. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27378. /**
  27379. * Remove an attached behavior
  27380. * @see http://doc.babylonjs.com/features/behaviour
  27381. * @param behavior defines the behavior to attach
  27382. * @returns the current Node
  27383. */
  27384. removeBehavior(behavior: Behavior<Node>): Node;
  27385. /**
  27386. * Gets the list of attached behaviors
  27387. * @see http://doc.babylonjs.com/features/behaviour
  27388. */
  27389. readonly behaviors: Behavior<Node>[];
  27390. /**
  27391. * Gets an attached behavior by name
  27392. * @param name defines the name of the behavior to look for
  27393. * @see http://doc.babylonjs.com/features/behaviour
  27394. * @returns null if behavior was not found else the requested behavior
  27395. */
  27396. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27397. /**
  27398. * Returns the latest update of the World matrix
  27399. * @returns a Matrix
  27400. */
  27401. getWorldMatrix(): Matrix;
  27402. /** @hidden */
  27403. _getWorldMatrixDeterminant(): number;
  27404. /**
  27405. * Returns directly the latest state of the mesh World matrix.
  27406. * A Matrix is returned.
  27407. */
  27408. readonly worldMatrixFromCache: Matrix;
  27409. /** @hidden */
  27410. _initCache(): void;
  27411. /** @hidden */
  27412. updateCache(force?: boolean): void;
  27413. /** @hidden */
  27414. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27415. /** @hidden */
  27416. _updateCache(ignoreParentClass?: boolean): void;
  27417. /** @hidden */
  27418. _isSynchronized(): boolean;
  27419. /** @hidden */
  27420. _markSyncedWithParent(): void;
  27421. /** @hidden */
  27422. isSynchronizedWithParent(): boolean;
  27423. /** @hidden */
  27424. isSynchronized(): boolean;
  27425. /**
  27426. * Is this node ready to be used/rendered
  27427. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27428. * @return true if the node is ready
  27429. */
  27430. isReady(completeCheck?: boolean): boolean;
  27431. /**
  27432. * Is this node enabled?
  27433. * 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
  27434. * @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
  27435. * @return whether this node (and its parent) is enabled
  27436. */
  27437. isEnabled(checkAncestors?: boolean): boolean;
  27438. /** @hidden */
  27439. protected _syncParentEnabledState(): void;
  27440. /**
  27441. * Set the enabled state of this node
  27442. * @param value defines the new enabled state
  27443. */
  27444. setEnabled(value: boolean): void;
  27445. /**
  27446. * Is this node a descendant of the given node?
  27447. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27448. * @param ancestor defines the parent node to inspect
  27449. * @returns a boolean indicating if this node is a descendant of the given node
  27450. */
  27451. isDescendantOf(ancestor: Node): boolean;
  27452. /** @hidden */
  27453. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27454. /**
  27455. * Will return all nodes that have this node as ascendant
  27456. * @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
  27457. * @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
  27458. * @return all children nodes of all types
  27459. */
  27460. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27461. /**
  27462. * Get all child-meshes of this node
  27463. * @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)
  27464. * @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
  27465. * @returns an array of AbstractMesh
  27466. */
  27467. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27468. /**
  27469. * Get all direct children of this node
  27470. * @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
  27471. * @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)
  27472. * @returns an array of Node
  27473. */
  27474. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27475. /** @hidden */
  27476. _setReady(state: boolean): void;
  27477. /**
  27478. * Get an animation by name
  27479. * @param name defines the name of the animation to look for
  27480. * @returns null if not found else the requested animation
  27481. */
  27482. getAnimationByName(name: string): Nullable<Animation>;
  27483. /**
  27484. * Creates an animation range for this node
  27485. * @param name defines the name of the range
  27486. * @param from defines the starting key
  27487. * @param to defines the end key
  27488. */
  27489. createAnimationRange(name: string, from: number, to: number): void;
  27490. /**
  27491. * Delete a specific animation range
  27492. * @param name defines the name of the range to delete
  27493. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27494. */
  27495. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27496. /**
  27497. * Get an animation range by name
  27498. * @param name defines the name of the animation range to look for
  27499. * @returns null if not found else the requested animation range
  27500. */
  27501. getAnimationRange(name: string): Nullable<AnimationRange>;
  27502. /**
  27503. * Gets the list of all animation ranges defined on this node
  27504. * @returns an array
  27505. */
  27506. getAnimationRanges(): Nullable<AnimationRange>[];
  27507. /**
  27508. * Will start the animation sequence
  27509. * @param name defines the range frames for animation sequence
  27510. * @param loop defines if the animation should loop (false by default)
  27511. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27512. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27513. * @returns the object created for this animation. If range does not exist, it will return null
  27514. */
  27515. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27516. /**
  27517. * Serialize animation ranges into a JSON compatible object
  27518. * @returns serialization object
  27519. */
  27520. serializeAnimationRanges(): any;
  27521. /**
  27522. * Computes the world matrix of the node
  27523. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27524. * @returns the world matrix
  27525. */
  27526. computeWorldMatrix(force?: boolean): Matrix;
  27527. /**
  27528. * Releases resources associated with this node.
  27529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27531. */
  27532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27533. /**
  27534. * Parse animation range data from a serialization object and store them into a given node
  27535. * @param node defines where to store the animation ranges
  27536. * @param parsedNode defines the serialization object to read data from
  27537. * @param scene defines the hosting scene
  27538. */
  27539. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27540. /**
  27541. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27542. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27543. * @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
  27544. * @returns the new bounding vectors
  27545. */
  27546. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27547. min: Vector3;
  27548. max: Vector3;
  27549. };
  27550. }
  27551. }
  27552. declare module "babylonjs/Animations/animation" {
  27553. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27554. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27555. import { Color3 } from "babylonjs/Maths/math.color";
  27556. import { Nullable } from "babylonjs/types";
  27557. import { Scene } from "babylonjs/scene";
  27558. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27559. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27560. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27561. import { Node } from "babylonjs/node";
  27562. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27563. import { Size } from "babylonjs/Maths/math.size";
  27564. import { Animatable } from "babylonjs/Animations/animatable";
  27565. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27566. /**
  27567. * @hidden
  27568. */
  27569. export class _IAnimationState {
  27570. key: number;
  27571. repeatCount: number;
  27572. workValue?: any;
  27573. loopMode?: number;
  27574. offsetValue?: any;
  27575. highLimitValue?: any;
  27576. }
  27577. /**
  27578. * Class used to store any kind of animation
  27579. */
  27580. export class Animation {
  27581. /**Name of the animation */
  27582. name: string;
  27583. /**Property to animate */
  27584. targetProperty: string;
  27585. /**The frames per second of the animation */
  27586. framePerSecond: number;
  27587. /**The data type of the animation */
  27588. dataType: number;
  27589. /**The loop mode of the animation */
  27590. loopMode?: number | undefined;
  27591. /**Specifies if blending should be enabled */
  27592. enableBlending?: boolean | undefined;
  27593. /**
  27594. * Use matrix interpolation instead of using direct key value when animating matrices
  27595. */
  27596. static AllowMatricesInterpolation: boolean;
  27597. /**
  27598. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27599. */
  27600. static AllowMatrixDecomposeForInterpolation: boolean;
  27601. /**
  27602. * Stores the key frames of the animation
  27603. */
  27604. private _keys;
  27605. /**
  27606. * Stores the easing function of the animation
  27607. */
  27608. private _easingFunction;
  27609. /**
  27610. * @hidden Internal use only
  27611. */
  27612. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27613. /**
  27614. * The set of event that will be linked to this animation
  27615. */
  27616. private _events;
  27617. /**
  27618. * Stores an array of target property paths
  27619. */
  27620. targetPropertyPath: string[];
  27621. /**
  27622. * Stores the blending speed of the animation
  27623. */
  27624. blendingSpeed: number;
  27625. /**
  27626. * Stores the animation ranges for the animation
  27627. */
  27628. private _ranges;
  27629. /**
  27630. * @hidden Internal use
  27631. */
  27632. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27633. /**
  27634. * Sets up an animation
  27635. * @param property The property to animate
  27636. * @param animationType The animation type to apply
  27637. * @param framePerSecond The frames per second of the animation
  27638. * @param easingFunction The easing function used in the animation
  27639. * @returns The created animation
  27640. */
  27641. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27642. /**
  27643. * Create and start an animation on a node
  27644. * @param name defines the name of the global animation that will be run on all nodes
  27645. * @param node defines the root node where the animation will take place
  27646. * @param targetProperty defines property to animate
  27647. * @param framePerSecond defines the number of frame per second yo use
  27648. * @param totalFrame defines the number of frames in total
  27649. * @param from defines the initial value
  27650. * @param to defines the final value
  27651. * @param loopMode defines which loop mode you want to use (off by default)
  27652. * @param easingFunction defines the easing function to use (linear by default)
  27653. * @param onAnimationEnd defines the callback to call when animation end
  27654. * @returns the animatable created for this animation
  27655. */
  27656. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27657. /**
  27658. * Create and start an animation on a node and its descendants
  27659. * @param name defines the name of the global animation that will be run on all nodes
  27660. * @param node defines the root node where the animation will take place
  27661. * @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
  27662. * @param targetProperty defines property to animate
  27663. * @param framePerSecond defines the number of frame per second to use
  27664. * @param totalFrame defines the number of frames in total
  27665. * @param from defines the initial value
  27666. * @param to defines the final value
  27667. * @param loopMode defines which loop mode you want to use (off by default)
  27668. * @param easingFunction defines the easing function to use (linear by default)
  27669. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27670. * @returns the list of animatables created for all nodes
  27671. * @example https://www.babylonjs-playground.com/#MH0VLI
  27672. */
  27673. 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[]>;
  27674. /**
  27675. * Creates a new animation, merges it with the existing animations and starts it
  27676. * @param name Name of the animation
  27677. * @param node Node which contains the scene that begins the animations
  27678. * @param targetProperty Specifies which property to animate
  27679. * @param framePerSecond The frames per second of the animation
  27680. * @param totalFrame The total number of frames
  27681. * @param from The frame at the beginning of the animation
  27682. * @param to The frame at the end of the animation
  27683. * @param loopMode Specifies the loop mode of the animation
  27684. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27685. * @param onAnimationEnd Callback to run once the animation is complete
  27686. * @returns Nullable animation
  27687. */
  27688. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27689. /**
  27690. * Transition property of an host to the target Value
  27691. * @param property The property to transition
  27692. * @param targetValue The target Value of the property
  27693. * @param host The object where the property to animate belongs
  27694. * @param scene Scene used to run the animation
  27695. * @param frameRate Framerate (in frame/s) to use
  27696. * @param transition The transition type we want to use
  27697. * @param duration The duration of the animation, in milliseconds
  27698. * @param onAnimationEnd Callback trigger at the end of the animation
  27699. * @returns Nullable animation
  27700. */
  27701. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27702. /**
  27703. * Return the array of runtime animations currently using this animation
  27704. */
  27705. readonly runtimeAnimations: RuntimeAnimation[];
  27706. /**
  27707. * Specifies if any of the runtime animations are currently running
  27708. */
  27709. readonly hasRunningRuntimeAnimations: boolean;
  27710. /**
  27711. * Initializes the animation
  27712. * @param name Name of the animation
  27713. * @param targetProperty Property to animate
  27714. * @param framePerSecond The frames per second of the animation
  27715. * @param dataType The data type of the animation
  27716. * @param loopMode The loop mode of the animation
  27717. * @param enableBlending Specifies if blending should be enabled
  27718. */
  27719. constructor(
  27720. /**Name of the animation */
  27721. name: string,
  27722. /**Property to animate */
  27723. targetProperty: string,
  27724. /**The frames per second of the animation */
  27725. framePerSecond: number,
  27726. /**The data type of the animation */
  27727. dataType: number,
  27728. /**The loop mode of the animation */
  27729. loopMode?: number | undefined,
  27730. /**Specifies if blending should be enabled */
  27731. enableBlending?: boolean | undefined);
  27732. /**
  27733. * Converts the animation to a string
  27734. * @param fullDetails support for multiple levels of logging within scene loading
  27735. * @returns String form of the animation
  27736. */
  27737. toString(fullDetails?: boolean): string;
  27738. /**
  27739. * Add an event to this animation
  27740. * @param event Event to add
  27741. */
  27742. addEvent(event: AnimationEvent): void;
  27743. /**
  27744. * Remove all events found at the given frame
  27745. * @param frame The frame to remove events from
  27746. */
  27747. removeEvents(frame: number): void;
  27748. /**
  27749. * Retrieves all the events from the animation
  27750. * @returns Events from the animation
  27751. */
  27752. getEvents(): AnimationEvent[];
  27753. /**
  27754. * Creates an animation range
  27755. * @param name Name of the animation range
  27756. * @param from Starting frame of the animation range
  27757. * @param to Ending frame of the animation
  27758. */
  27759. createRange(name: string, from: number, to: number): void;
  27760. /**
  27761. * Deletes an animation range by name
  27762. * @param name Name of the animation range to delete
  27763. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  27764. */
  27765. deleteRange(name: string, deleteFrames?: boolean): void;
  27766. /**
  27767. * Gets the animation range by name, or null if not defined
  27768. * @param name Name of the animation range
  27769. * @returns Nullable animation range
  27770. */
  27771. getRange(name: string): Nullable<AnimationRange>;
  27772. /**
  27773. * Gets the key frames from the animation
  27774. * @returns The key frames of the animation
  27775. */
  27776. getKeys(): Array<IAnimationKey>;
  27777. /**
  27778. * Gets the highest frame rate of the animation
  27779. * @returns Highest frame rate of the animation
  27780. */
  27781. getHighestFrame(): number;
  27782. /**
  27783. * Gets the easing function of the animation
  27784. * @returns Easing function of the animation
  27785. */
  27786. getEasingFunction(): IEasingFunction;
  27787. /**
  27788. * Sets the easing function of the animation
  27789. * @param easingFunction A custom mathematical formula for animation
  27790. */
  27791. setEasingFunction(easingFunction: EasingFunction): void;
  27792. /**
  27793. * Interpolates a scalar linearly
  27794. * @param startValue Start value of the animation curve
  27795. * @param endValue End value of the animation curve
  27796. * @param gradient Scalar amount to interpolate
  27797. * @returns Interpolated scalar value
  27798. */
  27799. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  27800. /**
  27801. * Interpolates a scalar cubically
  27802. * @param startValue Start value of the animation curve
  27803. * @param outTangent End tangent of the animation
  27804. * @param endValue End value of the animation curve
  27805. * @param inTangent Start tangent of the animation curve
  27806. * @param gradient Scalar amount to interpolate
  27807. * @returns Interpolated scalar value
  27808. */
  27809. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  27810. /**
  27811. * Interpolates a quaternion using a spherical linear interpolation
  27812. * @param startValue Start value of the animation curve
  27813. * @param endValue End value of the animation curve
  27814. * @param gradient Scalar amount to interpolate
  27815. * @returns Interpolated quaternion value
  27816. */
  27817. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  27818. /**
  27819. * Interpolates a quaternion cubically
  27820. * @param startValue Start value of the animation curve
  27821. * @param outTangent End tangent of the animation curve
  27822. * @param endValue End value of the animation curve
  27823. * @param inTangent Start tangent of the animation curve
  27824. * @param gradient Scalar amount to interpolate
  27825. * @returns Interpolated quaternion value
  27826. */
  27827. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  27828. /**
  27829. * Interpolates a Vector3 linearl
  27830. * @param startValue Start value of the animation curve
  27831. * @param endValue End value of the animation curve
  27832. * @param gradient Scalar amount to interpolate
  27833. * @returns Interpolated scalar value
  27834. */
  27835. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  27836. /**
  27837. * Interpolates a Vector3 cubically
  27838. * @param startValue Start value of the animation curve
  27839. * @param outTangent End tangent of the animation
  27840. * @param endValue End value of the animation curve
  27841. * @param inTangent Start tangent of the animation curve
  27842. * @param gradient Scalar amount to interpolate
  27843. * @returns InterpolatedVector3 value
  27844. */
  27845. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  27846. /**
  27847. * Interpolates a Vector2 linearly
  27848. * @param startValue Start value of the animation curve
  27849. * @param endValue End value of the animation curve
  27850. * @param gradient Scalar amount to interpolate
  27851. * @returns Interpolated Vector2 value
  27852. */
  27853. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  27854. /**
  27855. * Interpolates a Vector2 cubically
  27856. * @param startValue Start value of the animation curve
  27857. * @param outTangent End tangent of the animation
  27858. * @param endValue End value of the animation curve
  27859. * @param inTangent Start tangent of the animation curve
  27860. * @param gradient Scalar amount to interpolate
  27861. * @returns Interpolated Vector2 value
  27862. */
  27863. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  27864. /**
  27865. * Interpolates a size linearly
  27866. * @param startValue Start value of the animation curve
  27867. * @param endValue End value of the animation curve
  27868. * @param gradient Scalar amount to interpolate
  27869. * @returns Interpolated Size value
  27870. */
  27871. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  27872. /**
  27873. * Interpolates a Color3 linearly
  27874. * @param startValue Start value of the animation curve
  27875. * @param endValue End value of the animation curve
  27876. * @param gradient Scalar amount to interpolate
  27877. * @returns Interpolated Color3 value
  27878. */
  27879. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  27880. /**
  27881. * @hidden Internal use only
  27882. */
  27883. _getKeyValue(value: any): any;
  27884. /**
  27885. * @hidden Internal use only
  27886. */
  27887. _interpolate(currentFrame: number, state: _IAnimationState): any;
  27888. /**
  27889. * Defines the function to use to interpolate matrices
  27890. * @param startValue defines the start matrix
  27891. * @param endValue defines the end matrix
  27892. * @param gradient defines the gradient between both matrices
  27893. * @param result defines an optional target matrix where to store the interpolation
  27894. * @returns the interpolated matrix
  27895. */
  27896. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  27897. /**
  27898. * Makes a copy of the animation
  27899. * @returns Cloned animation
  27900. */
  27901. clone(): Animation;
  27902. /**
  27903. * Sets the key frames of the animation
  27904. * @param values The animation key frames to set
  27905. */
  27906. setKeys(values: Array<IAnimationKey>): void;
  27907. /**
  27908. * Serializes the animation to an object
  27909. * @returns Serialized object
  27910. */
  27911. serialize(): any;
  27912. /**
  27913. * Float animation type
  27914. */
  27915. private static _ANIMATIONTYPE_FLOAT;
  27916. /**
  27917. * Vector3 animation type
  27918. */
  27919. private static _ANIMATIONTYPE_VECTOR3;
  27920. /**
  27921. * Quaternion animation type
  27922. */
  27923. private static _ANIMATIONTYPE_QUATERNION;
  27924. /**
  27925. * Matrix animation type
  27926. */
  27927. private static _ANIMATIONTYPE_MATRIX;
  27928. /**
  27929. * Color3 animation type
  27930. */
  27931. private static _ANIMATIONTYPE_COLOR3;
  27932. /**
  27933. * Vector2 animation type
  27934. */
  27935. private static _ANIMATIONTYPE_VECTOR2;
  27936. /**
  27937. * Size animation type
  27938. */
  27939. private static _ANIMATIONTYPE_SIZE;
  27940. /**
  27941. * Relative Loop Mode
  27942. */
  27943. private static _ANIMATIONLOOPMODE_RELATIVE;
  27944. /**
  27945. * Cycle Loop Mode
  27946. */
  27947. private static _ANIMATIONLOOPMODE_CYCLE;
  27948. /**
  27949. * Constant Loop Mode
  27950. */
  27951. private static _ANIMATIONLOOPMODE_CONSTANT;
  27952. /**
  27953. * Get the float animation type
  27954. */
  27955. static readonly ANIMATIONTYPE_FLOAT: number;
  27956. /**
  27957. * Get the Vector3 animation type
  27958. */
  27959. static readonly ANIMATIONTYPE_VECTOR3: number;
  27960. /**
  27961. * Get the Vector2 animation type
  27962. */
  27963. static readonly ANIMATIONTYPE_VECTOR2: number;
  27964. /**
  27965. * Get the Size animation type
  27966. */
  27967. static readonly ANIMATIONTYPE_SIZE: number;
  27968. /**
  27969. * Get the Quaternion animation type
  27970. */
  27971. static readonly ANIMATIONTYPE_QUATERNION: number;
  27972. /**
  27973. * Get the Matrix animation type
  27974. */
  27975. static readonly ANIMATIONTYPE_MATRIX: number;
  27976. /**
  27977. * Get the Color3 animation type
  27978. */
  27979. static readonly ANIMATIONTYPE_COLOR3: number;
  27980. /**
  27981. * Get the Relative Loop Mode
  27982. */
  27983. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  27984. /**
  27985. * Get the Cycle Loop Mode
  27986. */
  27987. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  27988. /**
  27989. * Get the Constant Loop Mode
  27990. */
  27991. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  27992. /** @hidden */
  27993. static _UniversalLerp(left: any, right: any, amount: number): any;
  27994. /**
  27995. * Parses an animation object and creates an animation
  27996. * @param parsedAnimation Parsed animation object
  27997. * @returns Animation object
  27998. */
  27999. static Parse(parsedAnimation: any): Animation;
  28000. /**
  28001. * Appends the serialized animations from the source animations
  28002. * @param source Source containing the animations
  28003. * @param destination Target to store the animations
  28004. */
  28005. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28006. }
  28007. }
  28008. declare module "babylonjs/Animations/animatable.interface" {
  28009. import { Nullable } from "babylonjs/types";
  28010. import { Animation } from "babylonjs/Animations/animation";
  28011. /**
  28012. * Interface containing an array of animations
  28013. */
  28014. export interface IAnimatable {
  28015. /**
  28016. * Array of animations
  28017. */
  28018. animations: Nullable<Array<Animation>>;
  28019. }
  28020. }
  28021. declare module "babylonjs/Materials/fresnelParameters" {
  28022. import { Color3 } from "babylonjs/Maths/math.color";
  28023. /**
  28024. * This represents all the required information to add a fresnel effect on a material:
  28025. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28026. */
  28027. export class FresnelParameters {
  28028. private _isEnabled;
  28029. /**
  28030. * Define if the fresnel effect is enable or not.
  28031. */
  28032. isEnabled: boolean;
  28033. /**
  28034. * Define the color used on edges (grazing angle)
  28035. */
  28036. leftColor: Color3;
  28037. /**
  28038. * Define the color used on center
  28039. */
  28040. rightColor: Color3;
  28041. /**
  28042. * Define bias applied to computed fresnel term
  28043. */
  28044. bias: number;
  28045. /**
  28046. * Defined the power exponent applied to fresnel term
  28047. */
  28048. power: number;
  28049. /**
  28050. * Clones the current fresnel and its valuues
  28051. * @returns a clone fresnel configuration
  28052. */
  28053. clone(): FresnelParameters;
  28054. /**
  28055. * Serializes the current fresnel parameters to a JSON representation.
  28056. * @return the JSON serialization
  28057. */
  28058. serialize(): any;
  28059. /**
  28060. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28061. * @param parsedFresnelParameters Define the JSON representation
  28062. * @returns the parsed parameters
  28063. */
  28064. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28065. }
  28066. }
  28067. declare module "babylonjs/Misc/decorators" {
  28068. import { Nullable } from "babylonjs/types";
  28069. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28070. import { Scene } from "babylonjs/scene";
  28071. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28072. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28073. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28074. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28075. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28076. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28077. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28078. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28079. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28080. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28081. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28082. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28083. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28084. /**
  28085. * Decorator used to define property that can be serialized as reference to a camera
  28086. * @param sourceName defines the name of the property to decorate
  28087. */
  28088. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28089. /**
  28090. * Class used to help serialization objects
  28091. */
  28092. export class SerializationHelper {
  28093. /** @hidden */
  28094. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28095. /** @hidden */
  28096. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28097. /** @hidden */
  28098. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28099. /** @hidden */
  28100. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28101. /**
  28102. * Appends the serialized animations from the source animations
  28103. * @param source Source containing the animations
  28104. * @param destination Target to store the animations
  28105. */
  28106. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28107. /**
  28108. * Static function used to serialized a specific entity
  28109. * @param entity defines the entity to serialize
  28110. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28111. * @returns a JSON compatible object representing the serialization of the entity
  28112. */
  28113. static Serialize<T>(entity: T, serializationObject?: any): any;
  28114. /**
  28115. * Creates a new entity from a serialization data object
  28116. * @param creationFunction defines a function used to instanciated the new entity
  28117. * @param source defines the source serialization data
  28118. * @param scene defines the hosting scene
  28119. * @param rootUrl defines the root url for resources
  28120. * @returns a new entity
  28121. */
  28122. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28123. /**
  28124. * Clones an object
  28125. * @param creationFunction defines the function used to instanciate the new object
  28126. * @param source defines the source object
  28127. * @returns the cloned object
  28128. */
  28129. static Clone<T>(creationFunction: () => T, source: T): T;
  28130. /**
  28131. * Instanciates a new object based on a source one (some data will be shared between both object)
  28132. * @param creationFunction defines the function used to instanciate the new object
  28133. * @param source defines the source object
  28134. * @returns the new object
  28135. */
  28136. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28137. }
  28138. }
  28139. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28140. import { Nullable } from "babylonjs/types";
  28141. /**
  28142. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28143. */
  28144. export interface CubeMapInfo {
  28145. /**
  28146. * The pixel array for the front face.
  28147. * This is stored in format, left to right, up to down format.
  28148. */
  28149. front: Nullable<ArrayBufferView>;
  28150. /**
  28151. * The pixel array for the back face.
  28152. * This is stored in format, left to right, up to down format.
  28153. */
  28154. back: Nullable<ArrayBufferView>;
  28155. /**
  28156. * The pixel array for the left face.
  28157. * This is stored in format, left to right, up to down format.
  28158. */
  28159. left: Nullable<ArrayBufferView>;
  28160. /**
  28161. * The pixel array for the right face.
  28162. * This is stored in format, left to right, up to down format.
  28163. */
  28164. right: Nullable<ArrayBufferView>;
  28165. /**
  28166. * The pixel array for the up face.
  28167. * This is stored in format, left to right, up to down format.
  28168. */
  28169. up: Nullable<ArrayBufferView>;
  28170. /**
  28171. * The pixel array for the down face.
  28172. * This is stored in format, left to right, up to down format.
  28173. */
  28174. down: Nullable<ArrayBufferView>;
  28175. /**
  28176. * The size of the cubemap stored.
  28177. *
  28178. * Each faces will be size * size pixels.
  28179. */
  28180. size: number;
  28181. /**
  28182. * The format of the texture.
  28183. *
  28184. * RGBA, RGB.
  28185. */
  28186. format: number;
  28187. /**
  28188. * The type of the texture data.
  28189. *
  28190. * UNSIGNED_INT, FLOAT.
  28191. */
  28192. type: number;
  28193. /**
  28194. * Specifies whether the texture is in gamma space.
  28195. */
  28196. gammaSpace: boolean;
  28197. }
  28198. /**
  28199. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28200. */
  28201. export class PanoramaToCubeMapTools {
  28202. private static FACE_FRONT;
  28203. private static FACE_BACK;
  28204. private static FACE_RIGHT;
  28205. private static FACE_LEFT;
  28206. private static FACE_DOWN;
  28207. private static FACE_UP;
  28208. /**
  28209. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28210. *
  28211. * @param float32Array The source data.
  28212. * @param inputWidth The width of the input panorama.
  28213. * @param inputHeight The height of the input panorama.
  28214. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28215. * @return The cubemap data
  28216. */
  28217. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28218. private static CreateCubemapTexture;
  28219. private static CalcProjectionSpherical;
  28220. }
  28221. }
  28222. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28223. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28224. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28225. import { Nullable } from "babylonjs/types";
  28226. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28227. /**
  28228. * Helper class dealing with the extraction of spherical polynomial dataArray
  28229. * from a cube map.
  28230. */
  28231. export class CubeMapToSphericalPolynomialTools {
  28232. private static FileFaces;
  28233. /**
  28234. * Converts a texture to the according Spherical Polynomial data.
  28235. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28236. *
  28237. * @param texture The texture to extract the information from.
  28238. * @return The Spherical Polynomial data.
  28239. */
  28240. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28241. /**
  28242. * Converts a cubemap to the according Spherical Polynomial data.
  28243. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28244. *
  28245. * @param cubeInfo The Cube map to extract the information from.
  28246. * @return The Spherical Polynomial data.
  28247. */
  28248. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28249. }
  28250. }
  28251. declare module "babylonjs/Misc/guid" {
  28252. /**
  28253. * Class used to manipulate GUIDs
  28254. */
  28255. export class GUID {
  28256. /**
  28257. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28258. * Be aware Math.random() could cause collisions, but:
  28259. * "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"
  28260. * @returns a pseudo random id
  28261. */
  28262. static RandomId(): string;
  28263. }
  28264. }
  28265. declare module "babylonjs/Materials/Textures/baseTexture" {
  28266. import { Observable } from "babylonjs/Misc/observable";
  28267. import { Nullable } from "babylonjs/types";
  28268. import { Scene } from "babylonjs/scene";
  28269. import { Matrix } from "babylonjs/Maths/math.vector";
  28270. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28272. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28273. import { ISize } from "babylonjs/Maths/math.size";
  28274. /**
  28275. * Base class of all the textures in babylon.
  28276. * It groups all the common properties the materials, post process, lights... might need
  28277. * in order to make a correct use of the texture.
  28278. */
  28279. export class BaseTexture implements IAnimatable {
  28280. /**
  28281. * Default anisotropic filtering level for the application.
  28282. * It is set to 4 as a good tradeoff between perf and quality.
  28283. */
  28284. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28285. /**
  28286. * Gets or sets the unique id of the texture
  28287. */
  28288. uniqueId: number;
  28289. /**
  28290. * Define the name of the texture.
  28291. */
  28292. name: string;
  28293. /**
  28294. * Gets or sets an object used to store user defined information.
  28295. */
  28296. metadata: any;
  28297. /**
  28298. * For internal use only. Please do not use.
  28299. */
  28300. reservedDataStore: any;
  28301. private _hasAlpha;
  28302. /**
  28303. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28304. */
  28305. hasAlpha: boolean;
  28306. /**
  28307. * Defines if the alpha value should be determined via the rgb values.
  28308. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28309. */
  28310. getAlphaFromRGB: boolean;
  28311. /**
  28312. * Intensity or strength of the texture.
  28313. * It is commonly used by materials to fine tune the intensity of the texture
  28314. */
  28315. level: number;
  28316. /**
  28317. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28318. * This is part of the texture as textures usually maps to one uv set.
  28319. */
  28320. coordinatesIndex: number;
  28321. private _coordinatesMode;
  28322. /**
  28323. * How a texture is mapped.
  28324. *
  28325. * | Value | Type | Description |
  28326. * | ----- | ----------------------------------- | ----------- |
  28327. * | 0 | EXPLICIT_MODE | |
  28328. * | 1 | SPHERICAL_MODE | |
  28329. * | 2 | PLANAR_MODE | |
  28330. * | 3 | CUBIC_MODE | |
  28331. * | 4 | PROJECTION_MODE | |
  28332. * | 5 | SKYBOX_MODE | |
  28333. * | 6 | INVCUBIC_MODE | |
  28334. * | 7 | EQUIRECTANGULAR_MODE | |
  28335. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28336. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28337. */
  28338. coordinatesMode: number;
  28339. /**
  28340. * | Value | Type | Description |
  28341. * | ----- | ------------------ | ----------- |
  28342. * | 0 | CLAMP_ADDRESSMODE | |
  28343. * | 1 | WRAP_ADDRESSMODE | |
  28344. * | 2 | MIRROR_ADDRESSMODE | |
  28345. */
  28346. wrapU: number;
  28347. /**
  28348. * | Value | Type | Description |
  28349. * | ----- | ------------------ | ----------- |
  28350. * | 0 | CLAMP_ADDRESSMODE | |
  28351. * | 1 | WRAP_ADDRESSMODE | |
  28352. * | 2 | MIRROR_ADDRESSMODE | |
  28353. */
  28354. wrapV: number;
  28355. /**
  28356. * | Value | Type | Description |
  28357. * | ----- | ------------------ | ----------- |
  28358. * | 0 | CLAMP_ADDRESSMODE | |
  28359. * | 1 | WRAP_ADDRESSMODE | |
  28360. * | 2 | MIRROR_ADDRESSMODE | |
  28361. */
  28362. wrapR: number;
  28363. /**
  28364. * With compliant hardware and browser (supporting anisotropic filtering)
  28365. * this defines the level of anisotropic filtering in the texture.
  28366. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28367. */
  28368. anisotropicFilteringLevel: number;
  28369. /**
  28370. * Define if the texture is a cube texture or if false a 2d texture.
  28371. */
  28372. isCube: boolean;
  28373. /**
  28374. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28375. */
  28376. is3D: boolean;
  28377. /**
  28378. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28379. * HDR texture are usually stored in linear space.
  28380. * This only impacts the PBR and Background materials
  28381. */
  28382. gammaSpace: boolean;
  28383. /**
  28384. * Gets whether or not the texture contains RGBD data.
  28385. */
  28386. readonly isRGBD: boolean;
  28387. /**
  28388. * Is Z inverted in the texture (useful in a cube texture).
  28389. */
  28390. invertZ: boolean;
  28391. /**
  28392. * Are mip maps generated for this texture or not.
  28393. */
  28394. readonly noMipmap: boolean;
  28395. /**
  28396. * @hidden
  28397. */
  28398. lodLevelInAlpha: boolean;
  28399. /**
  28400. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28401. */
  28402. lodGenerationOffset: number;
  28403. /**
  28404. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28405. */
  28406. lodGenerationScale: number;
  28407. /**
  28408. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28409. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28410. * average roughness values.
  28411. */
  28412. linearSpecularLOD: boolean;
  28413. /**
  28414. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28415. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28416. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28417. */
  28418. irradianceTexture: Nullable<BaseTexture>;
  28419. /**
  28420. * Define if the texture is a render target.
  28421. */
  28422. isRenderTarget: boolean;
  28423. /**
  28424. * Define the unique id of the texture in the scene.
  28425. */
  28426. readonly uid: string;
  28427. /**
  28428. * Return a string representation of the texture.
  28429. * @returns the texture as a string
  28430. */
  28431. toString(): string;
  28432. /**
  28433. * Get the class name of the texture.
  28434. * @returns "BaseTexture"
  28435. */
  28436. getClassName(): string;
  28437. /**
  28438. * Define the list of animation attached to the texture.
  28439. */
  28440. animations: import("babylonjs/Animations/animation").Animation[];
  28441. /**
  28442. * An event triggered when the texture is disposed.
  28443. */
  28444. onDisposeObservable: Observable<BaseTexture>;
  28445. private _onDisposeObserver;
  28446. /**
  28447. * Callback triggered when the texture has been disposed.
  28448. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28449. */
  28450. onDispose: () => void;
  28451. /**
  28452. * Define the current state of the loading sequence when in delayed load mode.
  28453. */
  28454. delayLoadState: number;
  28455. private _scene;
  28456. /** @hidden */
  28457. _texture: Nullable<InternalTexture>;
  28458. private _uid;
  28459. /**
  28460. * Define if the texture is preventinga material to render or not.
  28461. * If not and the texture is not ready, the engine will use a default black texture instead.
  28462. */
  28463. readonly isBlocking: boolean;
  28464. /**
  28465. * Instantiates a new BaseTexture.
  28466. * Base class of all the textures in babylon.
  28467. * It groups all the common properties the materials, post process, lights... might need
  28468. * in order to make a correct use of the texture.
  28469. * @param scene Define the scene the texture blongs to
  28470. */
  28471. constructor(scene: Nullable<Scene>);
  28472. /**
  28473. * Get the scene the texture belongs to.
  28474. * @returns the scene or null if undefined
  28475. */
  28476. getScene(): Nullable<Scene>;
  28477. /**
  28478. * Get the texture transform matrix used to offset tile the texture for istance.
  28479. * @returns the transformation matrix
  28480. */
  28481. getTextureMatrix(): Matrix;
  28482. /**
  28483. * Get the texture reflection matrix used to rotate/transform the reflection.
  28484. * @returns the reflection matrix
  28485. */
  28486. getReflectionTextureMatrix(): Matrix;
  28487. /**
  28488. * Get the underlying lower level texture from Babylon.
  28489. * @returns the insternal texture
  28490. */
  28491. getInternalTexture(): Nullable<InternalTexture>;
  28492. /**
  28493. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28494. * @returns true if ready or not blocking
  28495. */
  28496. isReadyOrNotBlocking(): boolean;
  28497. /**
  28498. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28499. * @returns true if fully ready
  28500. */
  28501. isReady(): boolean;
  28502. private _cachedSize;
  28503. /**
  28504. * Get the size of the texture.
  28505. * @returns the texture size.
  28506. */
  28507. getSize(): ISize;
  28508. /**
  28509. * Get the base size of the texture.
  28510. * It can be different from the size if the texture has been resized for POT for instance
  28511. * @returns the base size
  28512. */
  28513. getBaseSize(): ISize;
  28514. /**
  28515. * Update the sampling mode of the texture.
  28516. * Default is Trilinear mode.
  28517. *
  28518. * | Value | Type | Description |
  28519. * | ----- | ------------------ | ----------- |
  28520. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28521. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28522. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28523. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28524. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28525. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28526. * | 7 | NEAREST_LINEAR | |
  28527. * | 8 | NEAREST_NEAREST | |
  28528. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28529. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28530. * | 11 | LINEAR_LINEAR | |
  28531. * | 12 | LINEAR_NEAREST | |
  28532. *
  28533. * > _mag_: magnification filter (close to the viewer)
  28534. * > _min_: minification filter (far from the viewer)
  28535. * > _mip_: filter used between mip map levels
  28536. *@param samplingMode Define the new sampling mode of the texture
  28537. */
  28538. updateSamplingMode(samplingMode: number): void;
  28539. /**
  28540. * Scales the texture if is `canRescale()`
  28541. * @param ratio the resize factor we want to use to rescale
  28542. */
  28543. scale(ratio: number): void;
  28544. /**
  28545. * Get if the texture can rescale.
  28546. */
  28547. readonly canRescale: boolean;
  28548. /** @hidden */
  28549. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28550. /** @hidden */
  28551. _rebuild(): void;
  28552. /**
  28553. * Triggers the load sequence in delayed load mode.
  28554. */
  28555. delayLoad(): void;
  28556. /**
  28557. * Clones the texture.
  28558. * @returns the cloned texture
  28559. */
  28560. clone(): Nullable<BaseTexture>;
  28561. /**
  28562. * Get the texture underlying type (INT, FLOAT...)
  28563. */
  28564. readonly textureType: number;
  28565. /**
  28566. * Get the texture underlying format (RGB, RGBA...)
  28567. */
  28568. readonly textureFormat: number;
  28569. /**
  28570. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28571. * This will returns an RGBA array buffer containing either in values (0-255) or
  28572. * float values (0-1) depending of the underlying buffer type.
  28573. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28574. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28575. * @param buffer defines a user defined buffer to fill with data (can be null)
  28576. * @returns The Array buffer containing the pixels data.
  28577. */
  28578. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28579. /**
  28580. * Release and destroy the underlying lower level texture aka internalTexture.
  28581. */
  28582. releaseInternalTexture(): void;
  28583. /**
  28584. * Get the polynomial representation of the texture data.
  28585. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  28586. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  28587. */
  28588. sphericalPolynomial: Nullable<SphericalPolynomial>;
  28589. /** @hidden */
  28590. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28591. /** @hidden */
  28592. readonly _lodTextureMid: Nullable<BaseTexture>;
  28593. /** @hidden */
  28594. readonly _lodTextureLow: Nullable<BaseTexture>;
  28595. /**
  28596. * Dispose the texture and release its associated resources.
  28597. */
  28598. dispose(): void;
  28599. /**
  28600. * Serialize the texture into a JSON representation that can be parsed later on.
  28601. * @returns the JSON representation of the texture
  28602. */
  28603. serialize(): any;
  28604. /**
  28605. * Helper function to be called back once a list of texture contains only ready textures.
  28606. * @param textures Define the list of textures to wait for
  28607. * @param callback Define the callback triggered once the entire list will be ready
  28608. */
  28609. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28610. }
  28611. }
  28612. declare module "babylonjs/Materials/Textures/internalTexture" {
  28613. import { Observable } from "babylonjs/Misc/observable";
  28614. import { Nullable, int } from "babylonjs/types";
  28615. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28616. import { Engine } from "babylonjs/Engines/engine";
  28617. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28618. /**
  28619. * Class used to store data associated with WebGL texture data for the engine
  28620. * This class should not be used directly
  28621. */
  28622. export class InternalTexture {
  28623. /** @hidden */
  28624. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  28625. /**
  28626. * The source of the texture data is unknown
  28627. */
  28628. static DATASOURCE_UNKNOWN: number;
  28629. /**
  28630. * Texture data comes from an URL
  28631. */
  28632. static DATASOURCE_URL: number;
  28633. /**
  28634. * Texture data is only used for temporary storage
  28635. */
  28636. static DATASOURCE_TEMP: number;
  28637. /**
  28638. * Texture data comes from raw data (ArrayBuffer)
  28639. */
  28640. static DATASOURCE_RAW: number;
  28641. /**
  28642. * Texture content is dynamic (video or dynamic texture)
  28643. */
  28644. static DATASOURCE_DYNAMIC: number;
  28645. /**
  28646. * Texture content is generated by rendering to it
  28647. */
  28648. static DATASOURCE_RENDERTARGET: number;
  28649. /**
  28650. * Texture content is part of a multi render target process
  28651. */
  28652. static DATASOURCE_MULTIRENDERTARGET: number;
  28653. /**
  28654. * Texture data comes from a cube data file
  28655. */
  28656. static DATASOURCE_CUBE: number;
  28657. /**
  28658. * Texture data comes from a raw cube data
  28659. */
  28660. static DATASOURCE_CUBERAW: number;
  28661. /**
  28662. * Texture data come from a prefiltered cube data file
  28663. */
  28664. static DATASOURCE_CUBEPREFILTERED: number;
  28665. /**
  28666. * Texture content is raw 3D data
  28667. */
  28668. static DATASOURCE_RAW3D: number;
  28669. /**
  28670. * Texture content is a depth texture
  28671. */
  28672. static DATASOURCE_DEPTHTEXTURE: number;
  28673. /**
  28674. * Texture data comes from a raw cube data encoded with RGBD
  28675. */
  28676. static DATASOURCE_CUBERAW_RGBD: number;
  28677. /**
  28678. * Defines if the texture is ready
  28679. */
  28680. isReady: boolean;
  28681. /**
  28682. * Defines if the texture is a cube texture
  28683. */
  28684. isCube: boolean;
  28685. /**
  28686. * Defines if the texture contains 3D data
  28687. */
  28688. is3D: boolean;
  28689. /**
  28690. * Defines if the texture contains multiview data
  28691. */
  28692. isMultiview: boolean;
  28693. /**
  28694. * Gets the URL used to load this texture
  28695. */
  28696. url: string;
  28697. /**
  28698. * Gets the sampling mode of the texture
  28699. */
  28700. samplingMode: number;
  28701. /**
  28702. * Gets a boolean indicating if the texture needs mipmaps generation
  28703. */
  28704. generateMipMaps: boolean;
  28705. /**
  28706. * Gets the number of samples used by the texture (WebGL2+ only)
  28707. */
  28708. samples: number;
  28709. /**
  28710. * Gets the type of the texture (int, float...)
  28711. */
  28712. type: number;
  28713. /**
  28714. * Gets the format of the texture (RGB, RGBA...)
  28715. */
  28716. format: number;
  28717. /**
  28718. * Observable called when the texture is loaded
  28719. */
  28720. onLoadedObservable: Observable<InternalTexture>;
  28721. /**
  28722. * Gets the width of the texture
  28723. */
  28724. width: number;
  28725. /**
  28726. * Gets the height of the texture
  28727. */
  28728. height: number;
  28729. /**
  28730. * Gets the depth of the texture
  28731. */
  28732. depth: number;
  28733. /**
  28734. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  28735. */
  28736. baseWidth: number;
  28737. /**
  28738. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  28739. */
  28740. baseHeight: number;
  28741. /**
  28742. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  28743. */
  28744. baseDepth: number;
  28745. /**
  28746. * Gets a boolean indicating if the texture is inverted on Y axis
  28747. */
  28748. invertY: boolean;
  28749. /** @hidden */
  28750. _invertVScale: boolean;
  28751. /** @hidden */
  28752. _associatedChannel: number;
  28753. /** @hidden */
  28754. _dataSource: number;
  28755. /** @hidden */
  28756. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  28757. /** @hidden */
  28758. _bufferView: Nullable<ArrayBufferView>;
  28759. /** @hidden */
  28760. _bufferViewArray: Nullable<ArrayBufferView[]>;
  28761. /** @hidden */
  28762. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  28763. /** @hidden */
  28764. _size: number;
  28765. /** @hidden */
  28766. _extension: string;
  28767. /** @hidden */
  28768. _files: Nullable<string[]>;
  28769. /** @hidden */
  28770. _workingCanvas: Nullable<HTMLCanvasElement>;
  28771. /** @hidden */
  28772. _workingContext: Nullable<CanvasRenderingContext2D>;
  28773. /** @hidden */
  28774. _framebuffer: Nullable<WebGLFramebuffer>;
  28775. /** @hidden */
  28776. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  28777. /** @hidden */
  28778. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  28779. /** @hidden */
  28780. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  28781. /** @hidden */
  28782. _attachments: Nullable<number[]>;
  28783. /** @hidden */
  28784. _cachedCoordinatesMode: Nullable<number>;
  28785. /** @hidden */
  28786. _cachedWrapU: Nullable<number>;
  28787. /** @hidden */
  28788. _cachedWrapV: Nullable<number>;
  28789. /** @hidden */
  28790. _cachedWrapR: Nullable<number>;
  28791. /** @hidden */
  28792. _cachedAnisotropicFilteringLevel: Nullable<number>;
  28793. /** @hidden */
  28794. _isDisabled: boolean;
  28795. /** @hidden */
  28796. _compression: Nullable<string>;
  28797. /** @hidden */
  28798. _generateStencilBuffer: boolean;
  28799. /** @hidden */
  28800. _generateDepthBuffer: boolean;
  28801. /** @hidden */
  28802. _comparisonFunction: number;
  28803. /** @hidden */
  28804. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  28805. /** @hidden */
  28806. _lodGenerationScale: number;
  28807. /** @hidden */
  28808. _lodGenerationOffset: number;
  28809. /** @hidden */
  28810. _colorTextureArray: Nullable<WebGLTexture>;
  28811. /** @hidden */
  28812. _depthStencilTextureArray: Nullable<WebGLTexture>;
  28813. /** @hidden */
  28814. _lodTextureHigh: Nullable<BaseTexture>;
  28815. /** @hidden */
  28816. _lodTextureMid: Nullable<BaseTexture>;
  28817. /** @hidden */
  28818. _lodTextureLow: Nullable<BaseTexture>;
  28819. /** @hidden */
  28820. _isRGBD: boolean;
  28821. /** @hidden */
  28822. _linearSpecularLOD: boolean;
  28823. /** @hidden */
  28824. _irradianceTexture: Nullable<BaseTexture>;
  28825. /** @hidden */
  28826. _webGLTexture: Nullable<WebGLTexture>;
  28827. /** @hidden */
  28828. _references: number;
  28829. private _engine;
  28830. /**
  28831. * Gets the Engine the texture belongs to.
  28832. * @returns The babylon engine
  28833. */
  28834. getEngine(): Engine;
  28835. /**
  28836. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  28837. */
  28838. readonly dataSource: number;
  28839. /**
  28840. * Creates a new InternalTexture
  28841. * @param engine defines the engine to use
  28842. * @param dataSource defines the type of data that will be used
  28843. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28844. */
  28845. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  28846. /**
  28847. * Increments the number of references (ie. the number of Texture that point to it)
  28848. */
  28849. incrementReferences(): void;
  28850. /**
  28851. * Change the size of the texture (not the size of the content)
  28852. * @param width defines the new width
  28853. * @param height defines the new height
  28854. * @param depth defines the new depth (1 by default)
  28855. */
  28856. updateSize(width: int, height: int, depth?: int): void;
  28857. /** @hidden */
  28858. _rebuild(): void;
  28859. /** @hidden */
  28860. _swapAndDie(target: InternalTexture): void;
  28861. /**
  28862. * Dispose the current allocated resources
  28863. */
  28864. dispose(): void;
  28865. }
  28866. }
  28867. declare module "babylonjs/Materials/effect" {
  28868. import { Observable } from "babylonjs/Misc/observable";
  28869. import { Nullable } from "babylonjs/types";
  28870. import { IDisposable } from "babylonjs/scene";
  28871. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28872. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28873. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28874. import { Engine } from "babylonjs/Engines/engine";
  28875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28876. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28878. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28880. /**
  28881. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28882. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28883. */
  28884. export class EffectFallbacks {
  28885. private _defines;
  28886. private _currentRank;
  28887. private _maxRank;
  28888. private _mesh;
  28889. /**
  28890. * Removes the fallback from the bound mesh.
  28891. */
  28892. unBindMesh(): void;
  28893. /**
  28894. * Adds a fallback on the specified property.
  28895. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28896. * @param define The name of the define in the shader
  28897. */
  28898. addFallback(rank: number, define: string): void;
  28899. /**
  28900. * Sets the mesh to use CPU skinning when needing to fallback.
  28901. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28902. * @param mesh The mesh to use the fallbacks.
  28903. */
  28904. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28905. /**
  28906. * Checks to see if more fallbacks are still availible.
  28907. */
  28908. readonly isMoreFallbacks: boolean;
  28909. /**
  28910. * Removes the defines that should be removed when falling back.
  28911. * @param currentDefines defines the current define statements for the shader.
  28912. * @param effect defines the current effect we try to compile
  28913. * @returns The resulting defines with defines of the current rank removed.
  28914. */
  28915. reduce(currentDefines: string, effect: Effect): string;
  28916. }
  28917. /**
  28918. * Options to be used when creating an effect.
  28919. */
  28920. export class EffectCreationOptions {
  28921. /**
  28922. * Atrributes that will be used in the shader.
  28923. */
  28924. attributes: string[];
  28925. /**
  28926. * Uniform varible names that will be set in the shader.
  28927. */
  28928. uniformsNames: string[];
  28929. /**
  28930. * Uniform buffer varible names that will be set in the shader.
  28931. */
  28932. uniformBuffersNames: string[];
  28933. /**
  28934. * Sampler texture variable names that will be set in the shader.
  28935. */
  28936. samplers: string[];
  28937. /**
  28938. * Define statements that will be set in the shader.
  28939. */
  28940. defines: any;
  28941. /**
  28942. * Possible fallbacks for this effect to improve performance when needed.
  28943. */
  28944. fallbacks: Nullable<EffectFallbacks>;
  28945. /**
  28946. * Callback that will be called when the shader is compiled.
  28947. */
  28948. onCompiled: Nullable<(effect: Effect) => void>;
  28949. /**
  28950. * Callback that will be called if an error occurs during shader compilation.
  28951. */
  28952. onError: Nullable<(effect: Effect, errors: string) => void>;
  28953. /**
  28954. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28955. */
  28956. indexParameters: any;
  28957. /**
  28958. * Max number of lights that can be used in the shader.
  28959. */
  28960. maxSimultaneousLights: number;
  28961. /**
  28962. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28963. */
  28964. transformFeedbackVaryings: Nullable<string[]>;
  28965. }
  28966. /**
  28967. * Effect containing vertex and fragment shader that can be executed on an object.
  28968. */
  28969. export class Effect implements IDisposable {
  28970. /**
  28971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28972. */
  28973. static ShadersRepository: string;
  28974. /**
  28975. * Name of the effect.
  28976. */
  28977. name: any;
  28978. /**
  28979. * String container all the define statements that should be set on the shader.
  28980. */
  28981. defines: string;
  28982. /**
  28983. * Callback that will be called when the shader is compiled.
  28984. */
  28985. onCompiled: Nullable<(effect: Effect) => void>;
  28986. /**
  28987. * Callback that will be called if an error occurs during shader compilation.
  28988. */
  28989. onError: Nullable<(effect: Effect, errors: string) => void>;
  28990. /**
  28991. * Callback that will be called when effect is bound.
  28992. */
  28993. onBind: Nullable<(effect: Effect) => void>;
  28994. /**
  28995. * Unique ID of the effect.
  28996. */
  28997. uniqueId: number;
  28998. /**
  28999. * Observable that will be called when the shader is compiled.
  29000. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29001. */
  29002. onCompileObservable: Observable<Effect>;
  29003. /**
  29004. * Observable that will be called if an error occurs during shader compilation.
  29005. */
  29006. onErrorObservable: Observable<Effect>;
  29007. /** @hidden */
  29008. _onBindObservable: Nullable<Observable<Effect>>;
  29009. /**
  29010. * Observable that will be called when effect is bound.
  29011. */
  29012. readonly onBindObservable: Observable<Effect>;
  29013. /** @hidden */
  29014. _bonesComputationForcedToCPU: boolean;
  29015. private static _uniqueIdSeed;
  29016. private _engine;
  29017. private _uniformBuffersNames;
  29018. private _uniformsNames;
  29019. private _samplerList;
  29020. private _samplers;
  29021. private _isReady;
  29022. private _compilationError;
  29023. private _attributesNames;
  29024. private _attributes;
  29025. private _uniforms;
  29026. /**
  29027. * Key for the effect.
  29028. * @hidden
  29029. */
  29030. _key: string;
  29031. private _indexParameters;
  29032. private _fallbacks;
  29033. private _vertexSourceCode;
  29034. private _fragmentSourceCode;
  29035. private _vertexSourceCodeOverride;
  29036. private _fragmentSourceCodeOverride;
  29037. private _transformFeedbackVaryings;
  29038. /**
  29039. * Compiled shader to webGL program.
  29040. * @hidden
  29041. */
  29042. _pipelineContext: Nullable<IPipelineContext>;
  29043. private _valueCache;
  29044. private static _baseCache;
  29045. /**
  29046. * Instantiates an effect.
  29047. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29048. * @param baseName Name of the effect.
  29049. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29050. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29051. * @param samplers List of sampler variables that will be passed to the shader.
  29052. * @param engine Engine to be used to render the effect
  29053. * @param defines Define statements to be added to the shader.
  29054. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29055. * @param onCompiled Callback that will be called when the shader is compiled.
  29056. * @param onError Callback that will be called if an error occurs during shader compilation.
  29057. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29058. */
  29059. 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);
  29060. private _useFinalCode;
  29061. /**
  29062. * Unique key for this effect
  29063. */
  29064. readonly key: string;
  29065. /**
  29066. * If the effect has been compiled and prepared.
  29067. * @returns if the effect is compiled and prepared.
  29068. */
  29069. isReady(): boolean;
  29070. /**
  29071. * The engine the effect was initialized with.
  29072. * @returns the engine.
  29073. */
  29074. getEngine(): Engine;
  29075. /**
  29076. * The pipeline context for this effect
  29077. * @returns the associated pipeline context
  29078. */
  29079. getPipelineContext(): Nullable<IPipelineContext>;
  29080. /**
  29081. * The set of names of attribute variables for the shader.
  29082. * @returns An array of attribute names.
  29083. */
  29084. getAttributesNames(): string[];
  29085. /**
  29086. * Returns the attribute at the given index.
  29087. * @param index The index of the attribute.
  29088. * @returns The location of the attribute.
  29089. */
  29090. getAttributeLocation(index: number): number;
  29091. /**
  29092. * Returns the attribute based on the name of the variable.
  29093. * @param name of the attribute to look up.
  29094. * @returns the attribute location.
  29095. */
  29096. getAttributeLocationByName(name: string): number;
  29097. /**
  29098. * The number of attributes.
  29099. * @returns the numnber of attributes.
  29100. */
  29101. getAttributesCount(): number;
  29102. /**
  29103. * Gets the index of a uniform variable.
  29104. * @param uniformName of the uniform to look up.
  29105. * @returns the index.
  29106. */
  29107. getUniformIndex(uniformName: string): number;
  29108. /**
  29109. * Returns the attribute based on the name of the variable.
  29110. * @param uniformName of the uniform to look up.
  29111. * @returns the location of the uniform.
  29112. */
  29113. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29114. /**
  29115. * Returns an array of sampler variable names
  29116. * @returns The array of sampler variable neames.
  29117. */
  29118. getSamplers(): string[];
  29119. /**
  29120. * The error from the last compilation.
  29121. * @returns the error string.
  29122. */
  29123. getCompilationError(): string;
  29124. /**
  29125. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29126. * @param func The callback to be used.
  29127. */
  29128. executeWhenCompiled(func: (effect: Effect) => void): void;
  29129. private _checkIsReady;
  29130. /** @hidden */
  29131. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29132. /** @hidden */
  29133. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29134. /** @hidden */
  29135. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29136. /**
  29137. * Recompiles the webGL program
  29138. * @param vertexSourceCode The source code for the vertex shader.
  29139. * @param fragmentSourceCode The source code for the fragment shader.
  29140. * @param onCompiled Callback called when completed.
  29141. * @param onError Callback called on error.
  29142. * @hidden
  29143. */
  29144. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29145. /**
  29146. * Prepares the effect
  29147. * @hidden
  29148. */
  29149. _prepareEffect(): void;
  29150. /**
  29151. * Checks if the effect is supported. (Must be called after compilation)
  29152. */
  29153. readonly isSupported: boolean;
  29154. /**
  29155. * Binds a texture to the engine to be used as output of the shader.
  29156. * @param channel Name of the output variable.
  29157. * @param texture Texture to bind.
  29158. * @hidden
  29159. */
  29160. _bindTexture(channel: string, texture: InternalTexture): void;
  29161. /**
  29162. * Sets a texture on the engine to be used in the shader.
  29163. * @param channel Name of the sampler variable.
  29164. * @param texture Texture to set.
  29165. */
  29166. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29167. /**
  29168. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29169. * @param channel Name of the sampler variable.
  29170. * @param texture Texture to set.
  29171. */
  29172. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29173. /**
  29174. * Sets an array of textures on the engine to be used in the shader.
  29175. * @param channel Name of the variable.
  29176. * @param textures Textures to set.
  29177. */
  29178. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29179. /**
  29180. * 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)
  29181. * @param channel Name of the sampler variable.
  29182. * @param postProcess Post process to get the input texture from.
  29183. */
  29184. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29185. /**
  29186. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29187. * 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)
  29188. * @param channel Name of the sampler variable.
  29189. * @param postProcess Post process to get the output texture from.
  29190. */
  29191. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29192. /** @hidden */
  29193. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29194. /** @hidden */
  29195. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29196. /** @hidden */
  29197. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29198. /** @hidden */
  29199. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29200. /**
  29201. * Binds a buffer to a uniform.
  29202. * @param buffer Buffer to bind.
  29203. * @param name Name of the uniform variable to bind to.
  29204. */
  29205. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29206. /**
  29207. * Binds block to a uniform.
  29208. * @param blockName Name of the block to bind.
  29209. * @param index Index to bind.
  29210. */
  29211. bindUniformBlock(blockName: string, index: number): void;
  29212. /**
  29213. * Sets an interger value on a uniform variable.
  29214. * @param uniformName Name of the variable.
  29215. * @param value Value to be set.
  29216. * @returns this effect.
  29217. */
  29218. setInt(uniformName: string, value: number): Effect;
  29219. /**
  29220. * Sets an int array on a uniform variable.
  29221. * @param uniformName Name of the variable.
  29222. * @param array array to be set.
  29223. * @returns this effect.
  29224. */
  29225. setIntArray(uniformName: string, array: Int32Array): Effect;
  29226. /**
  29227. * 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)
  29228. * @param uniformName Name of the variable.
  29229. * @param array array to be set.
  29230. * @returns this effect.
  29231. */
  29232. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29233. /**
  29234. * 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)
  29235. * @param uniformName Name of the variable.
  29236. * @param array array to be set.
  29237. * @returns this effect.
  29238. */
  29239. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29240. /**
  29241. * 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)
  29242. * @param uniformName Name of the variable.
  29243. * @param array array to be set.
  29244. * @returns this effect.
  29245. */
  29246. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29247. /**
  29248. * Sets an float array on a uniform variable.
  29249. * @param uniformName Name of the variable.
  29250. * @param array array to be set.
  29251. * @returns this effect.
  29252. */
  29253. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29254. /**
  29255. * 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)
  29256. * @param uniformName Name of the variable.
  29257. * @param array array to be set.
  29258. * @returns this effect.
  29259. */
  29260. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29261. /**
  29262. * 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)
  29263. * @param uniformName Name of the variable.
  29264. * @param array array to be set.
  29265. * @returns this effect.
  29266. */
  29267. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29268. /**
  29269. * 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)
  29270. * @param uniformName Name of the variable.
  29271. * @param array array to be set.
  29272. * @returns this effect.
  29273. */
  29274. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29275. /**
  29276. * Sets an array on a uniform variable.
  29277. * @param uniformName Name of the variable.
  29278. * @param array array to be set.
  29279. * @returns this effect.
  29280. */
  29281. setArray(uniformName: string, array: number[]): Effect;
  29282. /**
  29283. * 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)
  29284. * @param uniformName Name of the variable.
  29285. * @param array array to be set.
  29286. * @returns this effect.
  29287. */
  29288. setArray2(uniformName: string, array: number[]): Effect;
  29289. /**
  29290. * 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)
  29291. * @param uniformName Name of the variable.
  29292. * @param array array to be set.
  29293. * @returns this effect.
  29294. */
  29295. setArray3(uniformName: string, array: number[]): Effect;
  29296. /**
  29297. * 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)
  29298. * @param uniformName Name of the variable.
  29299. * @param array array to be set.
  29300. * @returns this effect.
  29301. */
  29302. setArray4(uniformName: string, array: number[]): Effect;
  29303. /**
  29304. * Sets matrices on a uniform variable.
  29305. * @param uniformName Name of the variable.
  29306. * @param matrices matrices to be set.
  29307. * @returns this effect.
  29308. */
  29309. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29310. /**
  29311. * Sets matrix on a uniform variable.
  29312. * @param uniformName Name of the variable.
  29313. * @param matrix matrix to be set.
  29314. * @returns this effect.
  29315. */
  29316. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29317. /**
  29318. * 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)
  29319. * @param uniformName Name of the variable.
  29320. * @param matrix matrix to be set.
  29321. * @returns this effect.
  29322. */
  29323. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29324. /**
  29325. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29326. * @param uniformName Name of the variable.
  29327. * @param matrix matrix to be set.
  29328. * @returns this effect.
  29329. */
  29330. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29331. /**
  29332. * Sets a float on a uniform variable.
  29333. * @param uniformName Name of the variable.
  29334. * @param value value to be set.
  29335. * @returns this effect.
  29336. */
  29337. setFloat(uniformName: string, value: number): Effect;
  29338. /**
  29339. * Sets a boolean on a uniform variable.
  29340. * @param uniformName Name of the variable.
  29341. * @param bool value to be set.
  29342. * @returns this effect.
  29343. */
  29344. setBool(uniformName: string, bool: boolean): Effect;
  29345. /**
  29346. * Sets a Vector2 on a uniform variable.
  29347. * @param uniformName Name of the variable.
  29348. * @param vector2 vector2 to be set.
  29349. * @returns this effect.
  29350. */
  29351. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29352. /**
  29353. * Sets a float2 on a uniform variable.
  29354. * @param uniformName Name of the variable.
  29355. * @param x First float in float2.
  29356. * @param y Second float in float2.
  29357. * @returns this effect.
  29358. */
  29359. setFloat2(uniformName: string, x: number, y: number): Effect;
  29360. /**
  29361. * Sets a Vector3 on a uniform variable.
  29362. * @param uniformName Name of the variable.
  29363. * @param vector3 Value to be set.
  29364. * @returns this effect.
  29365. */
  29366. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29367. /**
  29368. * Sets a float3 on a uniform variable.
  29369. * @param uniformName Name of the variable.
  29370. * @param x First float in float3.
  29371. * @param y Second float in float3.
  29372. * @param z Third float in float3.
  29373. * @returns this effect.
  29374. */
  29375. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29376. /**
  29377. * Sets a Vector4 on a uniform variable.
  29378. * @param uniformName Name of the variable.
  29379. * @param vector4 Value to be set.
  29380. * @returns this effect.
  29381. */
  29382. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29383. /**
  29384. * Sets a float4 on a uniform variable.
  29385. * @param uniformName Name of the variable.
  29386. * @param x First float in float4.
  29387. * @param y Second float in float4.
  29388. * @param z Third float in float4.
  29389. * @param w Fourth float in float4.
  29390. * @returns this effect.
  29391. */
  29392. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29393. /**
  29394. * Sets a Color3 on a uniform variable.
  29395. * @param uniformName Name of the variable.
  29396. * @param color3 Value to be set.
  29397. * @returns this effect.
  29398. */
  29399. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29400. /**
  29401. * Sets a Color4 on a uniform variable.
  29402. * @param uniformName Name of the variable.
  29403. * @param color3 Value to be set.
  29404. * @param alpha Alpha value to be set.
  29405. * @returns this effect.
  29406. */
  29407. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29408. /**
  29409. * Sets a Color4 on a uniform variable
  29410. * @param uniformName defines the name of the variable
  29411. * @param color4 defines the value to be set
  29412. * @returns this effect.
  29413. */
  29414. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29415. /** Release all associated resources */
  29416. dispose(): void;
  29417. /**
  29418. * This function will add a new shader to the shader store
  29419. * @param name the name of the shader
  29420. * @param pixelShader optional pixel shader content
  29421. * @param vertexShader optional vertex shader content
  29422. */
  29423. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29424. /**
  29425. * Store of each shader (The can be looked up using effect.key)
  29426. */
  29427. static ShadersStore: {
  29428. [key: string]: string;
  29429. };
  29430. /**
  29431. * Store of each included file for a shader (The can be looked up using effect.key)
  29432. */
  29433. static IncludesShadersStore: {
  29434. [key: string]: string;
  29435. };
  29436. /**
  29437. * Resets the cache of effects.
  29438. */
  29439. static ResetCache(): void;
  29440. }
  29441. }
  29442. declare module "babylonjs/Materials/uniformBuffer" {
  29443. import { Nullable, FloatArray } from "babylonjs/types";
  29444. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  29445. import { Engine } from "babylonjs/Engines/engine";
  29446. import { Effect } from "babylonjs/Materials/effect";
  29447. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29448. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29449. import { Color3 } from "babylonjs/Maths/math.color";
  29450. /**
  29451. * Uniform buffer objects.
  29452. *
  29453. * Handles blocks of uniform on the GPU.
  29454. *
  29455. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29456. *
  29457. * For more information, please refer to :
  29458. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29459. */
  29460. export class UniformBuffer {
  29461. private _engine;
  29462. private _buffer;
  29463. private _data;
  29464. private _bufferData;
  29465. private _dynamic?;
  29466. private _uniformLocations;
  29467. private _uniformSizes;
  29468. private _uniformLocationPointer;
  29469. private _needSync;
  29470. private _noUBO;
  29471. private _currentEffect;
  29472. private static _MAX_UNIFORM_SIZE;
  29473. private static _tempBuffer;
  29474. /**
  29475. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  29476. * This is dynamic to allow compat with webgl 1 and 2.
  29477. * You will need to pass the name of the uniform as well as the value.
  29478. */
  29479. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  29480. /**
  29481. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  29482. * This is dynamic to allow compat with webgl 1 and 2.
  29483. * You will need to pass the name of the uniform as well as the value.
  29484. */
  29485. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  29486. /**
  29487. * Lambda to Update a single float in a uniform buffer.
  29488. * This is dynamic to allow compat with webgl 1 and 2.
  29489. * You will need to pass the name of the uniform as well as the value.
  29490. */
  29491. updateFloat: (name: string, x: number) => void;
  29492. /**
  29493. * Lambda to Update a vec2 of float in a uniform buffer.
  29494. * This is dynamic to allow compat with webgl 1 and 2.
  29495. * You will need to pass the name of the uniform as well as the value.
  29496. */
  29497. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  29498. /**
  29499. * Lambda to Update a vec3 of float in a uniform buffer.
  29500. * This is dynamic to allow compat with webgl 1 and 2.
  29501. * You will need to pass the name of the uniform as well as the value.
  29502. */
  29503. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  29504. /**
  29505. * Lambda to Update a vec4 of float in a uniform buffer.
  29506. * This is dynamic to allow compat with webgl 1 and 2.
  29507. * You will need to pass the name of the uniform as well as the value.
  29508. */
  29509. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  29510. /**
  29511. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  29512. * This is dynamic to allow compat with webgl 1 and 2.
  29513. * You will need to pass the name of the uniform as well as the value.
  29514. */
  29515. updateMatrix: (name: string, mat: Matrix) => void;
  29516. /**
  29517. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  29518. * This is dynamic to allow compat with webgl 1 and 2.
  29519. * You will need to pass the name of the uniform as well as the value.
  29520. */
  29521. updateVector3: (name: string, vector: Vector3) => void;
  29522. /**
  29523. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  29524. * This is dynamic to allow compat with webgl 1 and 2.
  29525. * You will need to pass the name of the uniform as well as the value.
  29526. */
  29527. updateVector4: (name: string, vector: Vector4) => void;
  29528. /**
  29529. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  29530. * This is dynamic to allow compat with webgl 1 and 2.
  29531. * You will need to pass the name of the uniform as well as the value.
  29532. */
  29533. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  29534. /**
  29535. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  29536. * This is dynamic to allow compat with webgl 1 and 2.
  29537. * You will need to pass the name of the uniform as well as the value.
  29538. */
  29539. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  29540. /**
  29541. * Instantiates a new Uniform buffer objects.
  29542. *
  29543. * Handles blocks of uniform on the GPU.
  29544. *
  29545. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  29546. *
  29547. * For more information, please refer to :
  29548. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  29549. * @param engine Define the engine the buffer is associated with
  29550. * @param data Define the data contained in the buffer
  29551. * @param dynamic Define if the buffer is updatable
  29552. */
  29553. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  29554. /**
  29555. * Indicates if the buffer is using the WebGL2 UBO implementation,
  29556. * or just falling back on setUniformXXX calls.
  29557. */
  29558. readonly useUbo: boolean;
  29559. /**
  29560. * Indicates if the WebGL underlying uniform buffer is in sync
  29561. * with the javascript cache data.
  29562. */
  29563. readonly isSync: boolean;
  29564. /**
  29565. * Indicates if the WebGL underlying uniform buffer is dynamic.
  29566. * Also, a dynamic UniformBuffer will disable cache verification and always
  29567. * update the underlying WebGL uniform buffer to the GPU.
  29568. * @returns if Dynamic, otherwise false
  29569. */
  29570. isDynamic(): boolean;
  29571. /**
  29572. * The data cache on JS side.
  29573. * @returns the underlying data as a float array
  29574. */
  29575. getData(): Float32Array;
  29576. /**
  29577. * The underlying WebGL Uniform buffer.
  29578. * @returns the webgl buffer
  29579. */
  29580. getBuffer(): Nullable<DataBuffer>;
  29581. /**
  29582. * std140 layout specifies how to align data within an UBO structure.
  29583. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  29584. * for specs.
  29585. */
  29586. private _fillAlignment;
  29587. /**
  29588. * Adds an uniform in the buffer.
  29589. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  29590. * for the layout to be correct !
  29591. * @param name Name of the uniform, as used in the uniform block in the shader.
  29592. * @param size Data size, or data directly.
  29593. */
  29594. addUniform(name: string, size: number | number[]): void;
  29595. /**
  29596. * Adds a Matrix 4x4 to the uniform buffer.
  29597. * @param name Name of the uniform, as used in the uniform block in the shader.
  29598. * @param mat A 4x4 matrix.
  29599. */
  29600. addMatrix(name: string, mat: Matrix): void;
  29601. /**
  29602. * Adds a vec2 to the uniform buffer.
  29603. * @param name Name of the uniform, as used in the uniform block in the shader.
  29604. * @param x Define the x component value of the vec2
  29605. * @param y Define the y component value of the vec2
  29606. */
  29607. addFloat2(name: string, x: number, y: number): void;
  29608. /**
  29609. * Adds a vec3 to the uniform buffer.
  29610. * @param name Name of the uniform, as used in the uniform block in the shader.
  29611. * @param x Define the x component value of the vec3
  29612. * @param y Define the y component value of the vec3
  29613. * @param z Define the z component value of the vec3
  29614. */
  29615. addFloat3(name: string, x: number, y: number, z: number): void;
  29616. /**
  29617. * Adds a vec3 to the uniform buffer.
  29618. * @param name Name of the uniform, as used in the uniform block in the shader.
  29619. * @param color Define the vec3 from a Color
  29620. */
  29621. addColor3(name: string, color: Color3): void;
  29622. /**
  29623. * Adds a vec4 to the uniform buffer.
  29624. * @param name Name of the uniform, as used in the uniform block in the shader.
  29625. * @param color Define the rgb components from a Color
  29626. * @param alpha Define the a component of the vec4
  29627. */
  29628. addColor4(name: string, color: Color3, alpha: number): void;
  29629. /**
  29630. * Adds a vec3 to the uniform buffer.
  29631. * @param name Name of the uniform, as used in the uniform block in the shader.
  29632. * @param vector Define the vec3 components from a Vector
  29633. */
  29634. addVector3(name: string, vector: Vector3): void;
  29635. /**
  29636. * Adds a Matrix 3x3 to the uniform buffer.
  29637. * @param name Name of the uniform, as used in the uniform block in the shader.
  29638. */
  29639. addMatrix3x3(name: string): void;
  29640. /**
  29641. * Adds a Matrix 2x2 to the uniform buffer.
  29642. * @param name Name of the uniform, as used in the uniform block in the shader.
  29643. */
  29644. addMatrix2x2(name: string): void;
  29645. /**
  29646. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  29647. */
  29648. create(): void;
  29649. /** @hidden */
  29650. _rebuild(): void;
  29651. /**
  29652. * Updates the WebGL Uniform Buffer on the GPU.
  29653. * If the `dynamic` flag is set to true, no cache comparison is done.
  29654. * Otherwise, the buffer will be updated only if the cache differs.
  29655. */
  29656. update(): void;
  29657. /**
  29658. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  29659. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29660. * @param data Define the flattened data
  29661. * @param size Define the size of the data.
  29662. */
  29663. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  29664. private _updateMatrix3x3ForUniform;
  29665. private _updateMatrix3x3ForEffect;
  29666. private _updateMatrix2x2ForEffect;
  29667. private _updateMatrix2x2ForUniform;
  29668. private _updateFloatForEffect;
  29669. private _updateFloatForUniform;
  29670. private _updateFloat2ForEffect;
  29671. private _updateFloat2ForUniform;
  29672. private _updateFloat3ForEffect;
  29673. private _updateFloat3ForUniform;
  29674. private _updateFloat4ForEffect;
  29675. private _updateFloat4ForUniform;
  29676. private _updateMatrixForEffect;
  29677. private _updateMatrixForUniform;
  29678. private _updateVector3ForEffect;
  29679. private _updateVector3ForUniform;
  29680. private _updateVector4ForEffect;
  29681. private _updateVector4ForUniform;
  29682. private _updateColor3ForEffect;
  29683. private _updateColor3ForUniform;
  29684. private _updateColor4ForEffect;
  29685. private _updateColor4ForUniform;
  29686. /**
  29687. * Sets a sampler uniform on the effect.
  29688. * @param name Define the name of the sampler.
  29689. * @param texture Define the texture to set in the sampler
  29690. */
  29691. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  29692. /**
  29693. * Directly updates the value of the uniform in the cache AND on the GPU.
  29694. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  29695. * @param data Define the flattened data
  29696. */
  29697. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  29698. /**
  29699. * Binds this uniform buffer to an effect.
  29700. * @param effect Define the effect to bind the buffer to
  29701. * @param name Name of the uniform block in the shader.
  29702. */
  29703. bindToEffect(effect: Effect, name: string): void;
  29704. /**
  29705. * Disposes the uniform buffer.
  29706. */
  29707. dispose(): void;
  29708. }
  29709. }
  29710. declare module "babylonjs/Audio/analyser" {
  29711. import { Scene } from "babylonjs/scene";
  29712. /**
  29713. * Class used to work with sound analyzer using fast fourier transform (FFT)
  29714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29715. */
  29716. export class Analyser {
  29717. /**
  29718. * Gets or sets the smoothing
  29719. * @ignorenaming
  29720. */
  29721. SMOOTHING: number;
  29722. /**
  29723. * Gets or sets the FFT table size
  29724. * @ignorenaming
  29725. */
  29726. FFT_SIZE: number;
  29727. /**
  29728. * Gets or sets the bar graph amplitude
  29729. * @ignorenaming
  29730. */
  29731. BARGRAPHAMPLITUDE: number;
  29732. /**
  29733. * Gets or sets the position of the debug canvas
  29734. * @ignorenaming
  29735. */
  29736. DEBUGCANVASPOS: {
  29737. x: number;
  29738. y: number;
  29739. };
  29740. /**
  29741. * Gets or sets the debug canvas size
  29742. * @ignorenaming
  29743. */
  29744. DEBUGCANVASSIZE: {
  29745. width: number;
  29746. height: number;
  29747. };
  29748. private _byteFreqs;
  29749. private _byteTime;
  29750. private _floatFreqs;
  29751. private _webAudioAnalyser;
  29752. private _debugCanvas;
  29753. private _debugCanvasContext;
  29754. private _scene;
  29755. private _registerFunc;
  29756. private _audioEngine;
  29757. /**
  29758. * Creates a new analyser
  29759. * @param scene defines hosting scene
  29760. */
  29761. constructor(scene: Scene);
  29762. /**
  29763. * Get the number of data values you will have to play with for the visualization
  29764. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  29765. * @returns a number
  29766. */
  29767. getFrequencyBinCount(): number;
  29768. /**
  29769. * Gets the current frequency data as a byte array
  29770. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29771. * @returns a Uint8Array
  29772. */
  29773. getByteFrequencyData(): Uint8Array;
  29774. /**
  29775. * Gets the current waveform as a byte array
  29776. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  29777. * @returns a Uint8Array
  29778. */
  29779. getByteTimeDomainData(): Uint8Array;
  29780. /**
  29781. * Gets the current frequency data as a float array
  29782. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  29783. * @returns a Float32Array
  29784. */
  29785. getFloatFrequencyData(): Float32Array;
  29786. /**
  29787. * Renders the debug canvas
  29788. */
  29789. drawDebugCanvas(): void;
  29790. /**
  29791. * Stops rendering the debug canvas and removes it
  29792. */
  29793. stopDebugCanvas(): void;
  29794. /**
  29795. * Connects two audio nodes
  29796. * @param inputAudioNode defines first node to connect
  29797. * @param outputAudioNode defines second node to connect
  29798. */
  29799. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  29800. /**
  29801. * Releases all associated resources
  29802. */
  29803. dispose(): void;
  29804. }
  29805. }
  29806. declare module "babylonjs/Audio/audioEngine" {
  29807. import { IDisposable } from "babylonjs/scene";
  29808. import { Analyser } from "babylonjs/Audio/analyser";
  29809. import { Nullable } from "babylonjs/types";
  29810. import { Observable } from "babylonjs/Misc/observable";
  29811. /**
  29812. * This represents an audio engine and it is responsible
  29813. * to play, synchronize and analyse sounds throughout the application.
  29814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29815. */
  29816. export interface IAudioEngine extends IDisposable {
  29817. /**
  29818. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29819. */
  29820. readonly canUseWebAudio: boolean;
  29821. /**
  29822. * Gets the current AudioContext if available.
  29823. */
  29824. readonly audioContext: Nullable<AudioContext>;
  29825. /**
  29826. * The master gain node defines the global audio volume of your audio engine.
  29827. */
  29828. readonly masterGain: GainNode;
  29829. /**
  29830. * Gets whether or not mp3 are supported by your browser.
  29831. */
  29832. readonly isMP3supported: boolean;
  29833. /**
  29834. * Gets whether or not ogg are supported by your browser.
  29835. */
  29836. readonly isOGGsupported: boolean;
  29837. /**
  29838. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29839. * @ignoreNaming
  29840. */
  29841. WarnedWebAudioUnsupported: boolean;
  29842. /**
  29843. * Defines if the audio engine relies on a custom unlocked button.
  29844. * In this case, the embedded button will not be displayed.
  29845. */
  29846. useCustomUnlockedButton: boolean;
  29847. /**
  29848. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  29849. */
  29850. readonly unlocked: boolean;
  29851. /**
  29852. * Event raised when audio has been unlocked on the browser.
  29853. */
  29854. onAudioUnlockedObservable: Observable<AudioEngine>;
  29855. /**
  29856. * Event raised when audio has been locked on the browser.
  29857. */
  29858. onAudioLockedObservable: Observable<AudioEngine>;
  29859. /**
  29860. * Flags the audio engine in Locked state.
  29861. * This happens due to new browser policies preventing audio to autoplay.
  29862. */
  29863. lock(): void;
  29864. /**
  29865. * Unlocks the audio engine once a user action has been done on the dom.
  29866. * This is helpful to resume play once browser policies have been satisfied.
  29867. */
  29868. unlock(): void;
  29869. }
  29870. /**
  29871. * This represents the default audio engine used in babylon.
  29872. * It is responsible to play, synchronize and analyse sounds throughout the application.
  29873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29874. */
  29875. export class AudioEngine implements IAudioEngine {
  29876. private _audioContext;
  29877. private _audioContextInitialized;
  29878. private _muteButton;
  29879. private _hostElement;
  29880. /**
  29881. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  29882. */
  29883. canUseWebAudio: boolean;
  29884. /**
  29885. * The master gain node defines the global audio volume of your audio engine.
  29886. */
  29887. masterGain: GainNode;
  29888. /**
  29889. * Defines if Babylon should emit a warning if WebAudio is not supported.
  29890. * @ignoreNaming
  29891. */
  29892. WarnedWebAudioUnsupported: boolean;
  29893. /**
  29894. * Gets whether or not mp3 are supported by your browser.
  29895. */
  29896. isMP3supported: boolean;
  29897. /**
  29898. * Gets whether or not ogg are supported by your browser.
  29899. */
  29900. isOGGsupported: boolean;
  29901. /**
  29902. * Gets whether audio has been unlocked on the device.
  29903. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  29904. * a user interaction has happened.
  29905. */
  29906. unlocked: boolean;
  29907. /**
  29908. * Defines if the audio engine relies on a custom unlocked button.
  29909. * In this case, the embedded button will not be displayed.
  29910. */
  29911. useCustomUnlockedButton: boolean;
  29912. /**
  29913. * Event raised when audio has been unlocked on the browser.
  29914. */
  29915. onAudioUnlockedObservable: Observable<AudioEngine>;
  29916. /**
  29917. * Event raised when audio has been locked on the browser.
  29918. */
  29919. onAudioLockedObservable: Observable<AudioEngine>;
  29920. /**
  29921. * Gets the current AudioContext if available.
  29922. */
  29923. readonly audioContext: Nullable<AudioContext>;
  29924. private _connectedAnalyser;
  29925. /**
  29926. * Instantiates a new audio engine.
  29927. *
  29928. * There should be only one per page as some browsers restrict the number
  29929. * of audio contexts you can create.
  29930. * @param hostElement defines the host element where to display the mute icon if necessary
  29931. */
  29932. constructor(hostElement?: Nullable<HTMLElement>);
  29933. /**
  29934. * Flags the audio engine in Locked state.
  29935. * This happens due to new browser policies preventing audio to autoplay.
  29936. */
  29937. lock(): void;
  29938. /**
  29939. * Unlocks the audio engine once a user action has been done on the dom.
  29940. * This is helpful to resume play once browser policies have been satisfied.
  29941. */
  29942. unlock(): void;
  29943. private _resumeAudioContext;
  29944. private _initializeAudioContext;
  29945. private _tryToRun;
  29946. private _triggerRunningState;
  29947. private _triggerSuspendedState;
  29948. private _displayMuteButton;
  29949. private _moveButtonToTopLeft;
  29950. private _onResize;
  29951. private _hideMuteButton;
  29952. /**
  29953. * Destroy and release the resources associated with the audio ccontext.
  29954. */
  29955. dispose(): void;
  29956. /**
  29957. * Gets the global volume sets on the master gain.
  29958. * @returns the global volume if set or -1 otherwise
  29959. */
  29960. getGlobalVolume(): number;
  29961. /**
  29962. * Sets the global volume of your experience (sets on the master gain).
  29963. * @param newVolume Defines the new global volume of the application
  29964. */
  29965. setGlobalVolume(newVolume: number): void;
  29966. /**
  29967. * Connect the audio engine to an audio analyser allowing some amazing
  29968. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  29969. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  29970. * @param analyser The analyser to connect to the engine
  29971. */
  29972. connectToAnalyser(analyser: Analyser): void;
  29973. }
  29974. }
  29975. declare module "babylonjs/Loading/loadingScreen" {
  29976. /**
  29977. * Interface used to present a loading screen while loading a scene
  29978. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29979. */
  29980. export interface ILoadingScreen {
  29981. /**
  29982. * Function called to display the loading screen
  29983. */
  29984. displayLoadingUI: () => void;
  29985. /**
  29986. * Function called to hide the loading screen
  29987. */
  29988. hideLoadingUI: () => void;
  29989. /**
  29990. * Gets or sets the color to use for the background
  29991. */
  29992. loadingUIBackgroundColor: string;
  29993. /**
  29994. * Gets or sets the text to display while loading
  29995. */
  29996. loadingUIText: string;
  29997. }
  29998. /**
  29999. * Class used for the default loading screen
  30000. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30001. */
  30002. export class DefaultLoadingScreen implements ILoadingScreen {
  30003. private _renderingCanvas;
  30004. private _loadingText;
  30005. private _loadingDivBackgroundColor;
  30006. private _loadingDiv;
  30007. private _loadingTextDiv;
  30008. /** Gets or sets the logo url to use for the default loading screen */
  30009. static DefaultLogoUrl: string;
  30010. /** Gets or sets the spinner url to use for the default loading screen */
  30011. static DefaultSpinnerUrl: string;
  30012. /**
  30013. * Creates a new default loading screen
  30014. * @param _renderingCanvas defines the canvas used to render the scene
  30015. * @param _loadingText defines the default text to display
  30016. * @param _loadingDivBackgroundColor defines the default background color
  30017. */
  30018. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  30019. /**
  30020. * Function called to display the loading screen
  30021. */
  30022. displayLoadingUI(): void;
  30023. /**
  30024. * Function called to hide the loading screen
  30025. */
  30026. hideLoadingUI(): void;
  30027. /**
  30028. * Gets or sets the text to display while loading
  30029. */
  30030. loadingUIText: string;
  30031. /**
  30032. * Gets or sets the color to use for the background
  30033. */
  30034. loadingUIBackgroundColor: string;
  30035. private _resizeLoadingUI;
  30036. }
  30037. }
  30038. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  30039. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30040. import { Engine } from "babylonjs/Engines/engine";
  30041. import { Nullable } from "babylonjs/types";
  30042. /** @hidden */
  30043. export class WebGLPipelineContext implements IPipelineContext {
  30044. engine: Engine;
  30045. program: Nullable<WebGLProgram>;
  30046. context?: WebGLRenderingContext;
  30047. vertexShader?: WebGLShader;
  30048. fragmentShader?: WebGLShader;
  30049. isParallelCompiled: boolean;
  30050. onCompiled?: () => void;
  30051. transformFeedback?: WebGLTransformFeedback | null;
  30052. readonly isAsync: boolean;
  30053. readonly isReady: boolean;
  30054. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  30055. }
  30056. }
  30057. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  30058. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30059. /** @hidden */
  30060. export class WebGLDataBuffer extends DataBuffer {
  30061. private _buffer;
  30062. constructor(resource: WebGLBuffer);
  30063. readonly underlyingResource: any;
  30064. }
  30065. }
  30066. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  30067. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30068. /** @hidden */
  30069. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30070. attributeProcessor(attribute: string): string;
  30071. varyingProcessor(varying: string, isFragment: boolean): string;
  30072. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30073. }
  30074. }
  30075. declare module "babylonjs/Misc/perfCounter" {
  30076. /**
  30077. * This class is used to track a performance counter which is number based.
  30078. * The user has access to many properties which give statistics of different nature.
  30079. *
  30080. * The implementer can track two kinds of Performance Counter: time and count.
  30081. * 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.
  30082. * 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.
  30083. */
  30084. export class PerfCounter {
  30085. /**
  30086. * Gets or sets a global boolean to turn on and off all the counters
  30087. */
  30088. static Enabled: boolean;
  30089. /**
  30090. * Returns the smallest value ever
  30091. */
  30092. readonly min: number;
  30093. /**
  30094. * Returns the biggest value ever
  30095. */
  30096. readonly max: number;
  30097. /**
  30098. * Returns the average value since the performance counter is running
  30099. */
  30100. readonly average: number;
  30101. /**
  30102. * Returns the average value of the last second the counter was monitored
  30103. */
  30104. readonly lastSecAverage: number;
  30105. /**
  30106. * Returns the current value
  30107. */
  30108. readonly current: number;
  30109. /**
  30110. * Gets the accumulated total
  30111. */
  30112. readonly total: number;
  30113. /**
  30114. * Gets the total value count
  30115. */
  30116. readonly count: number;
  30117. /**
  30118. * Creates a new counter
  30119. */
  30120. constructor();
  30121. /**
  30122. * Call this method to start monitoring a new frame.
  30123. * 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.
  30124. */
  30125. fetchNewFrame(): void;
  30126. /**
  30127. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30128. * @param newCount the count value to add to the monitored count
  30129. * @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.
  30130. */
  30131. addCount(newCount: number, fetchResult: boolean): void;
  30132. /**
  30133. * Start monitoring this performance counter
  30134. */
  30135. beginMonitoring(): void;
  30136. /**
  30137. * Compute the time lapsed since the previous beginMonitoring() call.
  30138. * @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
  30139. */
  30140. endMonitoring(newFrame?: boolean): void;
  30141. private _fetchResult;
  30142. private _startMonitoringTime;
  30143. private _min;
  30144. private _max;
  30145. private _average;
  30146. private _current;
  30147. private _totalValueCount;
  30148. private _totalAccumulated;
  30149. private _lastSecAverage;
  30150. private _lastSecAccumulated;
  30151. private _lastSecTime;
  30152. private _lastSecValueCount;
  30153. }
  30154. }
  30155. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  30156. /**
  30157. * Interface for any object that can request an animation frame
  30158. */
  30159. export interface ICustomAnimationFrameRequester {
  30160. /**
  30161. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30162. */
  30163. renderFunction?: Function;
  30164. /**
  30165. * Called to request the next frame to render to
  30166. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30167. */
  30168. requestAnimationFrame: Function;
  30169. /**
  30170. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30171. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30172. */
  30173. requestID?: number;
  30174. }
  30175. }
  30176. declare module "babylonjs/Materials/Textures/videoTexture" {
  30177. import { Observable } from "babylonjs/Misc/observable";
  30178. import { Nullable } from "babylonjs/types";
  30179. import { Scene } from "babylonjs/scene";
  30180. import { Texture } from "babylonjs/Materials/Textures/texture";
  30181. /**
  30182. * Settings for finer control over video usage
  30183. */
  30184. export interface VideoTextureSettings {
  30185. /**
  30186. * Applies `autoplay` to video, if specified
  30187. */
  30188. autoPlay?: boolean;
  30189. /**
  30190. * Applies `loop` to video, if specified
  30191. */
  30192. loop?: boolean;
  30193. /**
  30194. * Automatically updates internal texture from video at every frame in the render loop
  30195. */
  30196. autoUpdateTexture: boolean;
  30197. /**
  30198. * Image src displayed during the video loading or until the user interacts with the video.
  30199. */
  30200. poster?: string;
  30201. }
  30202. /**
  30203. * If you want to display a video in your scene, this is the special texture for that.
  30204. * This special texture works similar to other textures, with the exception of a few parameters.
  30205. * @see https://doc.babylonjs.com/how_to/video_texture
  30206. */
  30207. export class VideoTexture extends Texture {
  30208. /**
  30209. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30210. */
  30211. readonly autoUpdateTexture: boolean;
  30212. /**
  30213. * The video instance used by the texture internally
  30214. */
  30215. readonly video: HTMLVideoElement;
  30216. private _onUserActionRequestedObservable;
  30217. /**
  30218. * Event triggerd when a dom action is required by the user to play the video.
  30219. * This happens due to recent changes in browser policies preventing video to auto start.
  30220. */
  30221. readonly onUserActionRequestedObservable: Observable<Texture>;
  30222. private _generateMipMaps;
  30223. private _engine;
  30224. private _stillImageCaptured;
  30225. private _displayingPosterTexture;
  30226. private _settings;
  30227. private _createInternalTextureOnEvent;
  30228. /**
  30229. * Creates a video texture.
  30230. * If you want to display a video in your scene, this is the special texture for that.
  30231. * This special texture works similar to other textures, with the exception of a few parameters.
  30232. * @see https://doc.babylonjs.com/how_to/video_texture
  30233. * @param name optional name, will detect from video source, if not defined
  30234. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30235. * @param scene is obviously the current scene.
  30236. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30237. * @param invertY is false by default but can be used to invert video on Y axis
  30238. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30239. * @param settings allows finer control over video usage
  30240. */
  30241. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30242. private _getName;
  30243. private _getVideo;
  30244. private _createInternalTexture;
  30245. private reset;
  30246. /**
  30247. * @hidden Internal method to initiate `update`.
  30248. */
  30249. _rebuild(): void;
  30250. /**
  30251. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30252. */
  30253. update(): void;
  30254. /**
  30255. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30256. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30257. */
  30258. updateTexture(isVisible: boolean): void;
  30259. protected _updateInternalTexture: () => void;
  30260. /**
  30261. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30262. * @param url New url.
  30263. */
  30264. updateURL(url: string): void;
  30265. /**
  30266. * Dispose the texture and release its associated resources.
  30267. */
  30268. dispose(): void;
  30269. /**
  30270. * Creates a video texture straight from a stream.
  30271. * @param scene Define the scene the texture should be created in
  30272. * @param stream Define the stream the texture should be created from
  30273. * @returns The created video texture as a promise
  30274. */
  30275. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30276. /**
  30277. * Creates a video texture straight from your WebCam video feed.
  30278. * @param scene Define the scene the texture should be created in
  30279. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30280. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30281. * @returns The created video texture as a promise
  30282. */
  30283. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30284. minWidth: number;
  30285. maxWidth: number;
  30286. minHeight: number;
  30287. maxHeight: number;
  30288. deviceId: string;
  30289. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30290. /**
  30291. * Creates a video texture straight from your WebCam video feed.
  30292. * @param scene Define the scene the texture should be created in
  30293. * @param onReady Define a callback to triggered once the texture will be ready
  30294. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30295. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30296. */
  30297. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30298. minWidth: number;
  30299. maxWidth: number;
  30300. minHeight: number;
  30301. maxHeight: number;
  30302. deviceId: string;
  30303. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30304. }
  30305. }
  30306. declare module "babylonjs/Engines/engine" {
  30307. import { Observable } from "babylonjs/Misc/observable";
  30308. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  30309. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  30310. import { Scene } from "babylonjs/scene";
  30311. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  30312. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30313. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  30314. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  30315. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30317. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  30318. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30319. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  30320. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  30321. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  30322. import { WebRequest } from "babylonjs/Misc/webRequest";
  30323. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  30324. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30325. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30326. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  30327. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  30328. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  30329. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  30330. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  30331. import { Material } from "babylonjs/Materials/material";
  30332. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30333. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30334. /**
  30335. * Defines the interface used by objects containing a viewport (like a camera)
  30336. */
  30337. interface IViewportOwnerLike {
  30338. /**
  30339. * Gets or sets the viewport
  30340. */
  30341. viewport: IViewportLike;
  30342. }
  30343. /**
  30344. * Interface for attribute information associated with buffer instanciation
  30345. */
  30346. export class InstancingAttributeInfo {
  30347. /**
  30348. * Index/offset of the attribute in the vertex shader
  30349. */
  30350. index: number;
  30351. /**
  30352. * size of the attribute, 1, 2, 3 or 4
  30353. */
  30354. attributeSize: number;
  30355. /**
  30356. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30357. * default is FLOAT
  30358. */
  30359. attribyteType: number;
  30360. /**
  30361. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30362. */
  30363. normalized: boolean;
  30364. /**
  30365. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30366. */
  30367. offset: number;
  30368. /**
  30369. * Name of the GLSL attribute, for debugging purpose only
  30370. */
  30371. attributeName: string;
  30372. }
  30373. /**
  30374. * Define options used to create a depth texture
  30375. */
  30376. export class DepthTextureCreationOptions {
  30377. /** Specifies whether or not a stencil should be allocated in the texture */
  30378. generateStencil?: boolean;
  30379. /** Specifies whether or not bilinear filtering is enable on the texture */
  30380. bilinearFiltering?: boolean;
  30381. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  30382. comparisonFunction?: number;
  30383. /** Specifies if the created texture is a cube texture */
  30384. isCube?: boolean;
  30385. }
  30386. /**
  30387. * Class used to describe the capabilities of the engine relatively to the current browser
  30388. */
  30389. export class EngineCapabilities {
  30390. /** Maximum textures units per fragment shader */
  30391. maxTexturesImageUnits: number;
  30392. /** Maximum texture units per vertex shader */
  30393. maxVertexTextureImageUnits: number;
  30394. /** Maximum textures units in the entire pipeline */
  30395. maxCombinedTexturesImageUnits: number;
  30396. /** Maximum texture size */
  30397. maxTextureSize: number;
  30398. /** Maximum cube texture size */
  30399. maxCubemapTextureSize: number;
  30400. /** Maximum render texture size */
  30401. maxRenderTextureSize: number;
  30402. /** Maximum number of vertex attributes */
  30403. maxVertexAttribs: number;
  30404. /** Maximum number of varyings */
  30405. maxVaryingVectors: number;
  30406. /** Maximum number of uniforms per vertex shader */
  30407. maxVertexUniformVectors: number;
  30408. /** Maximum number of uniforms per fragment shader */
  30409. maxFragmentUniformVectors: number;
  30410. /** Defines if standard derivates (dx/dy) are supported */
  30411. standardDerivatives: boolean;
  30412. /** Defines if s3tc texture compression is supported */
  30413. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  30414. /** Defines if pvrtc texture compression is supported */
  30415. pvrtc: any;
  30416. /** Defines if etc1 texture compression is supported */
  30417. etc1: any;
  30418. /** Defines if etc2 texture compression is supported */
  30419. etc2: any;
  30420. /** Defines if astc texture compression is supported */
  30421. astc: any;
  30422. /** Defines if float textures are supported */
  30423. textureFloat: boolean;
  30424. /** Defines if vertex array objects are supported */
  30425. vertexArrayObject: boolean;
  30426. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30427. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  30428. /** Gets the maximum level of anisotropy supported */
  30429. maxAnisotropy: number;
  30430. /** Defines if instancing is supported */
  30431. instancedArrays: boolean;
  30432. /** Defines if 32 bits indices are supported */
  30433. uintIndices: boolean;
  30434. /** Defines if high precision shaders are supported */
  30435. highPrecisionShaderSupported: boolean;
  30436. /** Defines if depth reading in the fragment shader is supported */
  30437. fragmentDepthSupported: boolean;
  30438. /** Defines if float texture linear filtering is supported*/
  30439. textureFloatLinearFiltering: boolean;
  30440. /** Defines if rendering to float textures is supported */
  30441. textureFloatRender: boolean;
  30442. /** Defines if half float textures are supported*/
  30443. textureHalfFloat: boolean;
  30444. /** Defines if half float texture linear filtering is supported*/
  30445. textureHalfFloatLinearFiltering: boolean;
  30446. /** Defines if rendering to half float textures is supported */
  30447. textureHalfFloatRender: boolean;
  30448. /** Defines if textureLOD shader command is supported */
  30449. textureLOD: boolean;
  30450. /** Defines if draw buffers extension is supported */
  30451. drawBuffersExtension: boolean;
  30452. /** Defines if depth textures are supported */
  30453. depthTextureExtension: boolean;
  30454. /** Defines if float color buffer are supported */
  30455. colorBufferFloat: boolean;
  30456. /** Gets disjoint timer query extension (null if not supported) */
  30457. timerQuery: EXT_disjoint_timer_query;
  30458. /** Defines if timestamp can be used with timer query */
  30459. canUseTimestampForTimerQuery: boolean;
  30460. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30461. multiview: any;
  30462. /** Function used to let the system compiles shaders in background */
  30463. parallelShaderCompile: {
  30464. COMPLETION_STATUS_KHR: number;
  30465. };
  30466. }
  30467. /** Interface defining initialization parameters for Engine class */
  30468. export interface EngineOptions extends WebGLContextAttributes {
  30469. /**
  30470. * Defines if the engine should no exceed a specified device ratio
  30471. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30472. */
  30473. limitDeviceRatio?: number;
  30474. /**
  30475. * Defines if webvr should be enabled automatically
  30476. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30477. */
  30478. autoEnableWebVR?: boolean;
  30479. /**
  30480. * Defines if webgl2 should be turned off even if supported
  30481. * @see http://doc.babylonjs.com/features/webgl2
  30482. */
  30483. disableWebGL2Support?: boolean;
  30484. /**
  30485. * Defines if webaudio should be initialized as well
  30486. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30487. */
  30488. audioEngine?: boolean;
  30489. /**
  30490. * Defines if animations should run using a deterministic lock step
  30491. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30492. */
  30493. deterministicLockstep?: boolean;
  30494. /** Defines the maximum steps to use with deterministic lock step mode */
  30495. lockstepMaxSteps?: number;
  30496. /**
  30497. * Defines that engine should ignore context lost events
  30498. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30499. */
  30500. doNotHandleContextLost?: boolean;
  30501. /**
  30502. * Defines that engine should ignore modifying touch action attribute and style
  30503. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30504. */
  30505. doNotHandleTouchAction?: boolean;
  30506. /**
  30507. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30508. */
  30509. useHighPrecisionFloats?: boolean;
  30510. }
  30511. /**
  30512. * Defines the interface used by display changed events
  30513. */
  30514. export interface IDisplayChangedEventArgs {
  30515. /** Gets the vrDisplay object (if any) */
  30516. vrDisplay: Nullable<any>;
  30517. /** Gets a boolean indicating if webVR is supported */
  30518. vrSupported: boolean;
  30519. }
  30520. /**
  30521. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  30522. */
  30523. export class Engine {
  30524. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30525. static ExceptionList: ({
  30526. key: string;
  30527. capture: string;
  30528. captureConstraint: number;
  30529. targets: string[];
  30530. } | {
  30531. key: string;
  30532. capture: null;
  30533. captureConstraint: null;
  30534. targets: string[];
  30535. })[];
  30536. /** Gets the list of created engines */
  30537. static readonly Instances: Engine[];
  30538. /**
  30539. * Gets the latest created engine
  30540. */
  30541. static readonly LastCreatedEngine: Nullable<Engine>;
  30542. /**
  30543. * Gets the latest created scene
  30544. */
  30545. static readonly LastCreatedScene: Nullable<Scene>;
  30546. /**
  30547. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  30548. * @param flag defines which part of the materials must be marked as dirty
  30549. * @param predicate defines a predicate used to filter which materials should be affected
  30550. */
  30551. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  30552. /** @hidden */
  30553. static _TextureLoaders: IInternalTextureLoader[];
  30554. /** Defines that alpha blending is disabled */
  30555. static readonly ALPHA_DISABLE: number;
  30556. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  30557. static readonly ALPHA_ADD: number;
  30558. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  30559. static readonly ALPHA_COMBINE: number;
  30560. /** Defines that alpha blending to DEST - SRC * DEST */
  30561. static readonly ALPHA_SUBTRACT: number;
  30562. /** Defines that alpha blending to SRC * DEST */
  30563. static readonly ALPHA_MULTIPLY: number;
  30564. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  30565. static readonly ALPHA_MAXIMIZED: number;
  30566. /** Defines that alpha blending to SRC + DEST */
  30567. static readonly ALPHA_ONEONE: number;
  30568. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  30569. static readonly ALPHA_PREMULTIPLIED: number;
  30570. /**
  30571. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  30572. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  30573. */
  30574. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  30575. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  30576. static readonly ALPHA_INTERPOLATE: number;
  30577. /**
  30578. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  30579. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  30580. */
  30581. static readonly ALPHA_SCREENMODE: number;
  30582. /** Defines that the ressource is not delayed*/
  30583. static readonly DELAYLOADSTATE_NONE: number;
  30584. /** Defines that the ressource was successfully delay loaded */
  30585. static readonly DELAYLOADSTATE_LOADED: number;
  30586. /** Defines that the ressource is currently delay loading */
  30587. static readonly DELAYLOADSTATE_LOADING: number;
  30588. /** Defines that the ressource is delayed and has not started loading */
  30589. static readonly DELAYLOADSTATE_NOTLOADED: number;
  30590. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  30591. static readonly NEVER: number;
  30592. /** 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 */
  30593. static readonly ALWAYS: number;
  30594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  30595. static readonly LESS: number;
  30596. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  30597. static readonly EQUAL: number;
  30598. /** 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 */
  30599. static readonly LEQUAL: number;
  30600. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  30601. static readonly GREATER: number;
  30602. /** 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 */
  30603. static readonly GEQUAL: number;
  30604. /** 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 */
  30605. static readonly NOTEQUAL: number;
  30606. /** Passed to stencilOperation to specify that stencil value must be kept */
  30607. static readonly KEEP: number;
  30608. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30609. static readonly REPLACE: number;
  30610. /** Passed to stencilOperation to specify that stencil value must be incremented */
  30611. static readonly INCR: number;
  30612. /** Passed to stencilOperation to specify that stencil value must be decremented */
  30613. static readonly DECR: number;
  30614. /** Passed to stencilOperation to specify that stencil value must be inverted */
  30615. static readonly INVERT: number;
  30616. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  30617. static readonly INCR_WRAP: number;
  30618. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  30619. static readonly DECR_WRAP: number;
  30620. /** Texture is not repeating outside of 0..1 UVs */
  30621. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  30622. /** Texture is repeating outside of 0..1 UVs */
  30623. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  30624. /** Texture is repeating and mirrored */
  30625. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  30626. /** ALPHA */
  30627. static readonly TEXTUREFORMAT_ALPHA: number;
  30628. /** LUMINANCE */
  30629. static readonly TEXTUREFORMAT_LUMINANCE: number;
  30630. /** LUMINANCE_ALPHA */
  30631. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  30632. /** RGB */
  30633. static readonly TEXTUREFORMAT_RGB: number;
  30634. /** RGBA */
  30635. static readonly TEXTUREFORMAT_RGBA: number;
  30636. /** RED */
  30637. static readonly TEXTUREFORMAT_RED: number;
  30638. /** RED (2nd reference) */
  30639. static readonly TEXTUREFORMAT_R: number;
  30640. /** RG */
  30641. static readonly TEXTUREFORMAT_RG: number;
  30642. /** RED_INTEGER */
  30643. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  30644. /** RED_INTEGER (2nd reference) */
  30645. static readonly TEXTUREFORMAT_R_INTEGER: number;
  30646. /** RG_INTEGER */
  30647. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  30648. /** RGB_INTEGER */
  30649. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  30650. /** RGBA_INTEGER */
  30651. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  30652. /** UNSIGNED_BYTE */
  30653. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  30654. /** UNSIGNED_BYTE (2nd reference) */
  30655. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  30656. /** FLOAT */
  30657. static readonly TEXTURETYPE_FLOAT: number;
  30658. /** HALF_FLOAT */
  30659. static readonly TEXTURETYPE_HALF_FLOAT: number;
  30660. /** BYTE */
  30661. static readonly TEXTURETYPE_BYTE: number;
  30662. /** SHORT */
  30663. static readonly TEXTURETYPE_SHORT: number;
  30664. /** UNSIGNED_SHORT */
  30665. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  30666. /** INT */
  30667. static readonly TEXTURETYPE_INT: number;
  30668. /** UNSIGNED_INT */
  30669. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  30670. /** UNSIGNED_SHORT_4_4_4_4 */
  30671. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  30672. /** UNSIGNED_SHORT_5_5_5_1 */
  30673. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  30674. /** UNSIGNED_SHORT_5_6_5 */
  30675. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  30676. /** UNSIGNED_INT_2_10_10_10_REV */
  30677. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  30678. /** UNSIGNED_INT_24_8 */
  30679. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  30680. /** UNSIGNED_INT_10F_11F_11F_REV */
  30681. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  30682. /** UNSIGNED_INT_5_9_9_9_REV */
  30683. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  30684. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  30685. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  30686. /** nearest is mag = nearest and min = nearest and mip = linear */
  30687. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  30688. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30689. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  30690. /** Trilinear is mag = linear and min = linear and mip = linear */
  30691. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  30692. /** nearest is mag = nearest and min = nearest and mip = linear */
  30693. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  30694. /** Bilinear is mag = linear and min = linear and mip = nearest */
  30695. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  30696. /** Trilinear is mag = linear and min = linear and mip = linear */
  30697. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  30698. /** mag = nearest and min = nearest and mip = nearest */
  30699. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  30700. /** mag = nearest and min = linear and mip = nearest */
  30701. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  30702. /** mag = nearest and min = linear and mip = linear */
  30703. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  30704. /** mag = nearest and min = linear and mip = none */
  30705. static readonly TEXTURE_NEAREST_LINEAR: number;
  30706. /** mag = nearest and min = nearest and mip = none */
  30707. static readonly TEXTURE_NEAREST_NEAREST: number;
  30708. /** mag = linear and min = nearest and mip = nearest */
  30709. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  30710. /** mag = linear and min = nearest and mip = linear */
  30711. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  30712. /** mag = linear and min = linear and mip = none */
  30713. static readonly TEXTURE_LINEAR_LINEAR: number;
  30714. /** mag = linear and min = nearest and mip = none */
  30715. static readonly TEXTURE_LINEAR_NEAREST: number;
  30716. /** Explicit coordinates mode */
  30717. static readonly TEXTURE_EXPLICIT_MODE: number;
  30718. /** Spherical coordinates mode */
  30719. static readonly TEXTURE_SPHERICAL_MODE: number;
  30720. /** Planar coordinates mode */
  30721. static readonly TEXTURE_PLANAR_MODE: number;
  30722. /** Cubic coordinates mode */
  30723. static readonly TEXTURE_CUBIC_MODE: number;
  30724. /** Projection coordinates mode */
  30725. static readonly TEXTURE_PROJECTION_MODE: number;
  30726. /** Skybox coordinates mode */
  30727. static readonly TEXTURE_SKYBOX_MODE: number;
  30728. /** Inverse Cubic coordinates mode */
  30729. static readonly TEXTURE_INVCUBIC_MODE: number;
  30730. /** Equirectangular coordinates mode */
  30731. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  30732. /** Equirectangular Fixed coordinates mode */
  30733. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  30734. /** Equirectangular Fixed Mirrored coordinates mode */
  30735. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  30736. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  30737. static readonly SCALEMODE_FLOOR: number;
  30738. /** Defines that texture rescaling will look for the nearest power of 2 size */
  30739. static readonly SCALEMODE_NEAREST: number;
  30740. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  30741. static readonly SCALEMODE_CEILING: number;
  30742. /**
  30743. * Returns the current npm package of the sdk
  30744. */
  30745. static readonly NpmPackage: string;
  30746. /**
  30747. * Returns the current version of the framework
  30748. */
  30749. static readonly Version: string;
  30750. /**
  30751. * Returns a string describing the current engine
  30752. */
  30753. readonly description: string;
  30754. /**
  30755. * Gets or sets the epsilon value used by collision engine
  30756. */
  30757. static CollisionsEpsilon: number;
  30758. /**
  30759. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30760. */
  30761. static ShadersRepository: string;
  30762. /**
  30763. * Method called to create the default loading screen.
  30764. * This can be overriden in your own app.
  30765. * @param canvas The rendering canvas element
  30766. * @returns The loading screen
  30767. */
  30768. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  30769. /**
  30770. * Method called to create the default rescale post process on each engine.
  30771. */
  30772. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  30773. /** @hidden */
  30774. _shaderProcessor: IShaderProcessor;
  30775. /**
  30776. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30777. */
  30778. forcePOTTextures: boolean;
  30779. /**
  30780. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30781. */
  30782. isFullscreen: boolean;
  30783. /**
  30784. * Gets a boolean indicating if the pointer is currently locked
  30785. */
  30786. isPointerLock: boolean;
  30787. /**
  30788. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30789. */
  30790. cullBackFaces: boolean;
  30791. /**
  30792. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30793. */
  30794. renderEvenInBackground: boolean;
  30795. /**
  30796. * Gets or sets a boolean indicating that cache can be kept between frames
  30797. */
  30798. preventCacheWipeBetweenFrames: boolean;
  30799. /**
  30800. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  30801. **/
  30802. enableOfflineSupport: boolean;
  30803. /**
  30804. * 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)
  30805. **/
  30806. disableManifestCheck: boolean;
  30807. /**
  30808. * Gets the list of created scenes
  30809. */
  30810. scenes: Scene[];
  30811. /**
  30812. * Event raised when a new scene is created
  30813. */
  30814. onNewSceneAddedObservable: Observable<Scene>;
  30815. /**
  30816. * Gets the list of created postprocesses
  30817. */
  30818. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  30819. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30820. validateShaderPrograms: boolean;
  30821. /**
  30822. * Observable event triggered each time the rendering canvas is resized
  30823. */
  30824. onResizeObservable: Observable<Engine>;
  30825. /**
  30826. * Observable event triggered each time the canvas loses focus
  30827. */
  30828. onCanvasBlurObservable: Observable<Engine>;
  30829. /**
  30830. * Observable event triggered each time the canvas gains focus
  30831. */
  30832. onCanvasFocusObservable: Observable<Engine>;
  30833. /**
  30834. * Observable event triggered each time the canvas receives pointerout event
  30835. */
  30836. onCanvasPointerOutObservable: Observable<PointerEvent>;
  30837. /**
  30838. * Observable event triggered before each texture is initialized
  30839. */
  30840. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  30841. /**
  30842. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30843. */
  30844. disableUniformBuffers: boolean;
  30845. /** @hidden */
  30846. _uniformBuffers: UniformBuffer[];
  30847. /**
  30848. * Gets a boolean indicating that the engine supports uniform buffers
  30849. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30850. */
  30851. readonly supportsUniformBuffers: boolean;
  30852. /**
  30853. * Observable raised when the engine begins a new frame
  30854. */
  30855. onBeginFrameObservable: Observable<Engine>;
  30856. /**
  30857. * If set, will be used to request the next animation frame for the render loop
  30858. */
  30859. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  30860. /**
  30861. * Observable raised when the engine ends the current frame
  30862. */
  30863. onEndFrameObservable: Observable<Engine>;
  30864. /**
  30865. * Observable raised when the engine is about to compile a shader
  30866. */
  30867. onBeforeShaderCompilationObservable: Observable<Engine>;
  30868. /**
  30869. * Observable raised when the engine has jsut compiled a shader
  30870. */
  30871. onAfterShaderCompilationObservable: Observable<Engine>;
  30872. /** @hidden */
  30873. _gl: WebGLRenderingContext;
  30874. private _renderingCanvas;
  30875. private _windowIsBackground;
  30876. private _webGLVersion;
  30877. protected _highPrecisionShadersAllowed: boolean;
  30878. /** @hidden */
  30879. readonly _shouldUseHighPrecisionShader: boolean;
  30880. /**
  30881. * Gets a boolean indicating that only power of 2 textures are supported
  30882. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30883. */
  30884. readonly needPOTTextures: boolean;
  30885. /** @hidden */
  30886. _badOS: boolean;
  30887. /** @hidden */
  30888. _badDesktopOS: boolean;
  30889. /**
  30890. * Gets the audio engine
  30891. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30892. * @ignorenaming
  30893. */
  30894. static audioEngine: IAudioEngine;
  30895. /**
  30896. * Default AudioEngine factory responsible of creating the Audio Engine.
  30897. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  30898. */
  30899. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  30900. /**
  30901. * Default offline support factory responsible of creating a tool used to store data locally.
  30902. * By default, this will create a Database object if the workload has been embedded.
  30903. */
  30904. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  30905. private _onFocus;
  30906. private _onBlur;
  30907. private _onCanvasPointerOut;
  30908. private _onCanvasBlur;
  30909. private _onCanvasFocus;
  30910. private _onFullscreenChange;
  30911. private _onPointerLockChange;
  30912. private _hardwareScalingLevel;
  30913. /** @hidden */
  30914. _caps: EngineCapabilities;
  30915. private _pointerLockRequested;
  30916. private _isStencilEnable;
  30917. private _colorWrite;
  30918. private _loadingScreen;
  30919. /** @hidden */
  30920. _drawCalls: PerfCounter;
  30921. private _glVersion;
  30922. private _glRenderer;
  30923. private _glVendor;
  30924. private _videoTextureSupported;
  30925. private _renderingQueueLaunched;
  30926. private _activeRenderLoops;
  30927. private _deterministicLockstep;
  30928. private _lockstepMaxSteps;
  30929. /**
  30930. * Observable signaled when a context lost event is raised
  30931. */
  30932. onContextLostObservable: Observable<Engine>;
  30933. /**
  30934. * Observable signaled when a context restored event is raised
  30935. */
  30936. onContextRestoredObservable: Observable<Engine>;
  30937. private _onContextLost;
  30938. private _onContextRestored;
  30939. private _contextWasLost;
  30940. /** @hidden */
  30941. _doNotHandleContextLost: boolean;
  30942. /**
  30943. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30944. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30945. */
  30946. doNotHandleContextLost: boolean;
  30947. private _performanceMonitor;
  30948. private _fps;
  30949. private _deltaTime;
  30950. /**
  30951. * Turn this value on if you want to pause FPS computation when in background
  30952. */
  30953. disablePerformanceMonitorInBackground: boolean;
  30954. /**
  30955. * Gets the performance monitor attached to this engine
  30956. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  30957. */
  30958. readonly performanceMonitor: PerformanceMonitor;
  30959. /**
  30960. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30961. */
  30962. disableVertexArrayObjects: boolean;
  30963. /** @hidden */
  30964. protected _depthCullingState: _DepthCullingState;
  30965. /** @hidden */
  30966. protected _stencilState: _StencilState;
  30967. /** @hidden */
  30968. protected _alphaState: _AlphaState;
  30969. /** @hidden */
  30970. protected _alphaMode: number;
  30971. /** @hidden */
  30972. _internalTexturesCache: InternalTexture[];
  30973. /** @hidden */
  30974. protected _activeChannel: number;
  30975. private _currentTextureChannel;
  30976. /** @hidden */
  30977. protected _boundTexturesCache: {
  30978. [key: string]: Nullable<InternalTexture>;
  30979. };
  30980. /** @hidden */
  30981. protected _currentEffect: Nullable<Effect>;
  30982. /** @hidden */
  30983. protected _currentProgram: Nullable<WebGLProgram>;
  30984. private _compiledEffects;
  30985. private _vertexAttribArraysEnabled;
  30986. /** @hidden */
  30987. protected _cachedViewport: Nullable<IViewportLike>;
  30988. private _cachedVertexArrayObject;
  30989. /** @hidden */
  30990. protected _cachedVertexBuffers: any;
  30991. /** @hidden */
  30992. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30993. /** @hidden */
  30994. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30995. /** @hidden */
  30996. _currentRenderTarget: Nullable<InternalTexture>;
  30997. private _uintIndicesCurrentlySet;
  30998. private _currentBoundBuffer;
  30999. /** @hidden */
  31000. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31001. private _currentBufferPointers;
  31002. private _currentInstanceLocations;
  31003. private _currentInstanceBuffers;
  31004. private _textureUnits;
  31005. /** @hidden */
  31006. _workingCanvas: Nullable<HTMLCanvasElement>;
  31007. /** @hidden */
  31008. _workingContext: Nullable<CanvasRenderingContext2D>;
  31009. private _rescalePostProcess;
  31010. private _dummyFramebuffer;
  31011. private _externalData;
  31012. /** @hidden */
  31013. _bindedRenderFunction: any;
  31014. private _vaoRecordInProgress;
  31015. private _mustWipeVertexAttributes;
  31016. private _emptyTexture;
  31017. private _emptyCubeTexture;
  31018. private _emptyTexture3D;
  31019. /** @hidden */
  31020. _frameHandler: number;
  31021. private _nextFreeTextureSlots;
  31022. private _maxSimultaneousTextures;
  31023. private _activeRequests;
  31024. private _texturesSupported;
  31025. /** @hidden */
  31026. _textureFormatInUse: Nullable<string>;
  31027. /**
  31028. * Gets the list of texture formats supported
  31029. */
  31030. readonly texturesSupported: Array<string>;
  31031. /**
  31032. * Gets the list of texture formats in use
  31033. */
  31034. readonly textureFormatInUse: Nullable<string>;
  31035. /**
  31036. * Gets the current viewport
  31037. */
  31038. readonly currentViewport: Nullable<IViewportLike>;
  31039. /**
  31040. * Gets the default empty texture
  31041. */
  31042. readonly emptyTexture: InternalTexture;
  31043. /**
  31044. * Gets the default empty 3D texture
  31045. */
  31046. readonly emptyTexture3D: InternalTexture;
  31047. /**
  31048. * Gets the default empty cube texture
  31049. */
  31050. readonly emptyCubeTexture: InternalTexture;
  31051. /**
  31052. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31053. */
  31054. readonly premultipliedAlpha: boolean;
  31055. /**
  31056. * Creates a new engine
  31057. * @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
  31058. * @param antialias defines enable antialiasing (default: false)
  31059. * @param options defines further options to be sent to the getContext() function
  31060. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31061. */
  31062. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31063. /**
  31064. * Initializes a webVR display and starts listening to display change events
  31065. * The onVRDisplayChangedObservable will be notified upon these changes
  31066. * @returns The onVRDisplayChangedObservable
  31067. */
  31068. initWebVR(): Observable<IDisplayChangedEventArgs>;
  31069. /** @hidden */
  31070. _prepareVRComponent(): void;
  31071. /** @hidden */
  31072. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  31073. /** @hidden */
  31074. _submitVRFrame(): void;
  31075. /**
  31076. * Call this function to leave webVR mode
  31077. * Will do nothing if webVR is not supported or if there is no webVR device
  31078. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31079. */
  31080. disableVR(): void;
  31081. /**
  31082. * Gets a boolean indicating that the system is in VR mode and is presenting
  31083. * @returns true if VR mode is engaged
  31084. */
  31085. isVRPresenting(): boolean;
  31086. /** @hidden */
  31087. _requestVRFrame(): void;
  31088. private _disableTouchAction;
  31089. private _rebuildInternalTextures;
  31090. private _rebuildEffects;
  31091. /**
  31092. * Gets a boolean indicating if all created effects are ready
  31093. * @returns true if all effects are ready
  31094. */
  31095. areAllEffectsReady(): boolean;
  31096. private _rebuildBuffers;
  31097. private _initGLContext;
  31098. /**
  31099. * Gets version of the current webGL context
  31100. */
  31101. readonly webGLVersion: number;
  31102. /**
  31103. * Gets a string idenfifying the name of the class
  31104. * @returns "Engine" string
  31105. */
  31106. getClassName(): string;
  31107. /**
  31108. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31109. */
  31110. readonly isStencilEnable: boolean;
  31111. /** @hidden */
  31112. _prepareWorkingCanvas(): void;
  31113. /**
  31114. * Reset the texture cache to empty state
  31115. */
  31116. resetTextureCache(): void;
  31117. /**
  31118. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  31119. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31120. * @returns true if engine is in deterministic lock step mode
  31121. */
  31122. isDeterministicLockStep(): boolean;
  31123. /**
  31124. * Gets the max steps when engine is running in deterministic lock step
  31125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31126. * @returns the max steps
  31127. */
  31128. getLockstepMaxSteps(): number;
  31129. /**
  31130. * Gets an object containing information about the current webGL context
  31131. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31132. */
  31133. getGlInfo(): {
  31134. vendor: string;
  31135. renderer: string;
  31136. version: string;
  31137. };
  31138. /**
  31139. * Gets current aspect ratio
  31140. * @param viewportOwner defines the camera to use to get the aspect ratio
  31141. * @param useScreen defines if screen size must be used (or the current render target if any)
  31142. * @returns a number defining the aspect ratio
  31143. */
  31144. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  31145. /**
  31146. * Gets current screen aspect ratio
  31147. * @returns a number defining the aspect ratio
  31148. */
  31149. getScreenAspectRatio(): number;
  31150. /**
  31151. * Gets the current render width
  31152. * @param useScreen defines if screen size must be used (or the current render target if any)
  31153. * @returns a number defining the current render width
  31154. */
  31155. getRenderWidth(useScreen?: boolean): number;
  31156. /**
  31157. * Gets the current render height
  31158. * @param useScreen defines if screen size must be used (or the current render target if any)
  31159. * @returns a number defining the current render height
  31160. */
  31161. getRenderHeight(useScreen?: boolean): number;
  31162. /**
  31163. * Gets the HTML canvas attached with the current webGL context
  31164. * @returns a HTML canvas
  31165. */
  31166. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31167. /**
  31168. * Gets the client rect of the HTML canvas attached with the current webGL context
  31169. * @returns a client rectanglee
  31170. */
  31171. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  31172. /**
  31173. * Defines the hardware scaling level.
  31174. * By default the hardware scaling level is computed from the window device ratio.
  31175. * 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.
  31176. * @param level defines the level to use
  31177. */
  31178. setHardwareScalingLevel(level: number): void;
  31179. /**
  31180. * Gets the current hardware scaling level.
  31181. * By default the hardware scaling level is computed from the window device ratio.
  31182. * 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.
  31183. * @returns a number indicating the current hardware scaling level
  31184. */
  31185. getHardwareScalingLevel(): number;
  31186. /**
  31187. * Gets the list of loaded textures
  31188. * @returns an array containing all loaded textures
  31189. */
  31190. getLoadedTexturesCache(): InternalTexture[];
  31191. /**
  31192. * Gets the object containing all engine capabilities
  31193. * @returns the EngineCapabilities object
  31194. */
  31195. getCaps(): EngineCapabilities;
  31196. /**
  31197. * Gets the current depth function
  31198. * @returns a number defining the depth function
  31199. */
  31200. getDepthFunction(): Nullable<number>;
  31201. /**
  31202. * Sets the current depth function
  31203. * @param depthFunc defines the function to use
  31204. */
  31205. setDepthFunction(depthFunc: number): void;
  31206. /**
  31207. * Sets the current depth function to GREATER
  31208. */
  31209. setDepthFunctionToGreater(): void;
  31210. /**
  31211. * Sets the current depth function to GEQUAL
  31212. */
  31213. setDepthFunctionToGreaterOrEqual(): void;
  31214. /**
  31215. * Sets the current depth function to LESS
  31216. */
  31217. setDepthFunctionToLess(): void;
  31218. private _cachedStencilBuffer;
  31219. private _cachedStencilFunction;
  31220. private _cachedStencilMask;
  31221. private _cachedStencilOperationPass;
  31222. private _cachedStencilOperationFail;
  31223. private _cachedStencilOperationDepthFail;
  31224. private _cachedStencilReference;
  31225. /**
  31226. * Caches the the state of the stencil buffer
  31227. */
  31228. cacheStencilState(): void;
  31229. /**
  31230. * Restores the state of the stencil buffer
  31231. */
  31232. restoreStencilState(): void;
  31233. /**
  31234. * Sets the current depth function to LEQUAL
  31235. */
  31236. setDepthFunctionToLessOrEqual(): void;
  31237. /**
  31238. * Gets a boolean indicating if stencil buffer is enabled
  31239. * @returns the current stencil buffer state
  31240. */
  31241. getStencilBuffer(): boolean;
  31242. /**
  31243. * Enable or disable the stencil buffer
  31244. * @param enable defines if the stencil buffer must be enabled or disabled
  31245. */
  31246. setStencilBuffer(enable: boolean): void;
  31247. /**
  31248. * Gets the current stencil mask
  31249. * @returns a number defining the new stencil mask to use
  31250. */
  31251. getStencilMask(): number;
  31252. /**
  31253. * Sets the current stencil mask
  31254. * @param mask defines the new stencil mask to use
  31255. */
  31256. setStencilMask(mask: number): void;
  31257. /**
  31258. * Gets the current stencil function
  31259. * @returns a number defining the stencil function to use
  31260. */
  31261. getStencilFunction(): number;
  31262. /**
  31263. * Gets the current stencil reference value
  31264. * @returns a number defining the stencil reference value to use
  31265. */
  31266. getStencilFunctionReference(): number;
  31267. /**
  31268. * Gets the current stencil mask
  31269. * @returns a number defining the stencil mask to use
  31270. */
  31271. getStencilFunctionMask(): number;
  31272. /**
  31273. * Sets the current stencil function
  31274. * @param stencilFunc defines the new stencil function to use
  31275. */
  31276. setStencilFunction(stencilFunc: number): void;
  31277. /**
  31278. * Sets the current stencil reference
  31279. * @param reference defines the new stencil reference to use
  31280. */
  31281. setStencilFunctionReference(reference: number): void;
  31282. /**
  31283. * Sets the current stencil mask
  31284. * @param mask defines the new stencil mask to use
  31285. */
  31286. setStencilFunctionMask(mask: number): void;
  31287. /**
  31288. * Gets the current stencil operation when stencil fails
  31289. * @returns a number defining stencil operation to use when stencil fails
  31290. */
  31291. getStencilOperationFail(): number;
  31292. /**
  31293. * Gets the current stencil operation when depth fails
  31294. * @returns a number defining stencil operation to use when depth fails
  31295. */
  31296. getStencilOperationDepthFail(): number;
  31297. /**
  31298. * Gets the current stencil operation when stencil passes
  31299. * @returns a number defining stencil operation to use when stencil passes
  31300. */
  31301. getStencilOperationPass(): number;
  31302. /**
  31303. * Sets the stencil operation to use when stencil fails
  31304. * @param operation defines the stencil operation to use when stencil fails
  31305. */
  31306. setStencilOperationFail(operation: number): void;
  31307. /**
  31308. * Sets the stencil operation to use when depth fails
  31309. * @param operation defines the stencil operation to use when depth fails
  31310. */
  31311. setStencilOperationDepthFail(operation: number): void;
  31312. /**
  31313. * Sets the stencil operation to use when stencil passes
  31314. * @param operation defines the stencil operation to use when stencil passes
  31315. */
  31316. setStencilOperationPass(operation: number): void;
  31317. /**
  31318. * Sets a boolean indicating if the dithering state is enabled or disabled
  31319. * @param value defines the dithering state
  31320. */
  31321. setDitheringState(value: boolean): void;
  31322. /**
  31323. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  31324. * @param value defines the rasterizer state
  31325. */
  31326. setRasterizerState(value: boolean): void;
  31327. /**
  31328. * stop executing a render loop function and remove it from the execution array
  31329. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31330. */
  31331. stopRenderLoop(renderFunction?: () => void): void;
  31332. /** @hidden */
  31333. _renderLoop(): void;
  31334. /**
  31335. * Register and execute a render loop. The engine can have more than one render function
  31336. * @param renderFunction defines the function to continuously execute
  31337. */
  31338. runRenderLoop(renderFunction: () => void): void;
  31339. /**
  31340. * Toggle full screen mode
  31341. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31342. */
  31343. switchFullscreen(requestPointerLock: boolean): void;
  31344. /**
  31345. * Enters full screen mode
  31346. * @param requestPointerLock defines if a pointer lock should be requested from the user
  31347. */
  31348. enterFullscreen(requestPointerLock: boolean): void;
  31349. /**
  31350. * Exits full screen mode
  31351. */
  31352. exitFullscreen(): void;
  31353. /**
  31354. * Enters Pointerlock mode
  31355. */
  31356. enterPointerlock(): void;
  31357. /**
  31358. * Exits Pointerlock mode
  31359. */
  31360. exitPointerlock(): void;
  31361. /**
  31362. * Clear the current render buffer or the current render target (if any is set up)
  31363. * @param color defines the color to use
  31364. * @param backBuffer defines if the back buffer must be cleared
  31365. * @param depth defines if the depth buffer must be cleared
  31366. * @param stencil defines if the stencil buffer must be cleared
  31367. */
  31368. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31369. /**
  31370. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  31371. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31372. * @param y defines the y-coordinate of the corner of the clear rectangle
  31373. * @param width defines the width of the clear rectangle
  31374. * @param height defines the height of the clear rectangle
  31375. * @param clearColor defines the clear color
  31376. */
  31377. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  31378. /**
  31379. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  31380. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  31381. * @param y defines the y-coordinate of the corner of the clear rectangle
  31382. * @param width defines the width of the clear rectangle
  31383. * @param height defines the height of the clear rectangle
  31384. */
  31385. enableScissor(x: number, y: number, width: number, height: number): void;
  31386. /**
  31387. * Disable previously set scissor test rectangle
  31388. */
  31389. disableScissor(): void;
  31390. private _viewportCached;
  31391. /** @hidden */
  31392. _viewport(x: number, y: number, width: number, height: number): void;
  31393. /**
  31394. * Set the WebGL's viewport
  31395. * @param viewport defines the viewport element to be used
  31396. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31397. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31398. */
  31399. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31400. /**
  31401. * Directly set the WebGL Viewport
  31402. * @param x defines the x coordinate of the viewport (in screen space)
  31403. * @param y defines the y coordinate of the viewport (in screen space)
  31404. * @param width defines the width of the viewport (in screen space)
  31405. * @param height defines the height of the viewport (in screen space)
  31406. * @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
  31407. */
  31408. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  31409. /**
  31410. * Begin a new frame
  31411. */
  31412. beginFrame(): void;
  31413. /**
  31414. * Enf the current frame
  31415. */
  31416. endFrame(): void;
  31417. /**
  31418. * Resize the view according to the canvas' size
  31419. */
  31420. resize(): void;
  31421. /**
  31422. * Force a specific size of the canvas
  31423. * @param width defines the new canvas' width
  31424. * @param height defines the new canvas' height
  31425. */
  31426. setSize(width: number, height: number): void;
  31427. /**
  31428. * Binds the frame buffer to the specified texture.
  31429. * @param texture The texture to render to or null for the default canvas
  31430. * @param faceIndex The face of the texture to render to in case of cube texture
  31431. * @param requiredWidth The width of the target to render to
  31432. * @param requiredHeight The height of the target to render to
  31433. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31434. * @param depthStencilTexture The depth stencil texture to use to render
  31435. * @param lodLevel defines le lod level to bind to the frame buffer
  31436. */
  31437. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  31438. /** @hidden */
  31439. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31440. /**
  31441. * Unbind the current render target texture from the webGL context
  31442. * @param texture defines the render target texture to unbind
  31443. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31444. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31445. */
  31446. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31447. /**
  31448. * Force the mipmap generation for the given render target texture
  31449. * @param texture defines the render target texture to use
  31450. */
  31451. generateMipMapsForCubemap(texture: InternalTexture): void;
  31452. /**
  31453. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31454. */
  31455. flushFramebuffer(): void;
  31456. /**
  31457. * Unbind the current render target and bind the default framebuffer
  31458. */
  31459. restoreDefaultFramebuffer(): void;
  31460. /**
  31461. * Create an uniform buffer
  31462. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31463. * @param elements defines the content of the uniform buffer
  31464. * @returns the webGL uniform buffer
  31465. */
  31466. createUniformBuffer(elements: FloatArray): DataBuffer;
  31467. /**
  31468. * Create a dynamic uniform buffer
  31469. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31470. * @param elements defines the content of the uniform buffer
  31471. * @returns the webGL uniform buffer
  31472. */
  31473. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  31474. /**
  31475. * Update an existing uniform buffer
  31476. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31477. * @param uniformBuffer defines the target uniform buffer
  31478. * @param elements defines the content to update
  31479. * @param offset defines the offset in the uniform buffer where update should start
  31480. * @param count defines the size of the data to update
  31481. */
  31482. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  31483. private _resetVertexBufferBinding;
  31484. /**
  31485. * Creates a vertex buffer
  31486. * @param data the data for the vertex buffer
  31487. * @returns the new WebGL static buffer
  31488. */
  31489. createVertexBuffer(data: DataArray): DataBuffer;
  31490. /**
  31491. * Creates a dynamic vertex buffer
  31492. * @param data the data for the dynamic vertex buffer
  31493. * @returns the new WebGL dynamic buffer
  31494. */
  31495. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31496. /**
  31497. * Update a dynamic index buffer
  31498. * @param indexBuffer defines the target index buffer
  31499. * @param indices defines the data to update
  31500. * @param offset defines the offset in the target index buffer where update should start
  31501. */
  31502. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  31503. /**
  31504. * Updates a dynamic vertex buffer.
  31505. * @param vertexBuffer the vertex buffer to update
  31506. * @param data the data used to update the vertex buffer
  31507. * @param byteOffset the byte offset of the data
  31508. * @param byteLength the byte length of the data
  31509. */
  31510. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  31511. private _resetIndexBufferBinding;
  31512. /**
  31513. * Creates a new index buffer
  31514. * @param indices defines the content of the index buffer
  31515. * @param updatable defines if the index buffer must be updatable
  31516. * @returns a new webGL buffer
  31517. */
  31518. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31519. /**
  31520. * Bind a webGL buffer to the webGL context
  31521. * @param buffer defines the buffer to bind
  31522. */
  31523. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31524. /**
  31525. * Bind an uniform buffer to the current webGL context
  31526. * @param buffer defines the buffer to bind
  31527. */
  31528. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  31529. /**
  31530. * Bind a buffer to the current webGL context at a given location
  31531. * @param buffer defines the buffer to bind
  31532. * @param location defines the index where to bind the buffer
  31533. */
  31534. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  31535. /**
  31536. * Bind a specific block at a given index in a specific shader program
  31537. * @param pipelineContext defines the pipeline context to use
  31538. * @param blockName defines the block name
  31539. * @param index defines the index where to bind the block
  31540. */
  31541. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  31542. private bindIndexBuffer;
  31543. private bindBuffer;
  31544. /**
  31545. * update the bound buffer with the given data
  31546. * @param data defines the data to update
  31547. */
  31548. updateArrayBuffer(data: Float32Array): void;
  31549. private _vertexAttribPointer;
  31550. private _bindIndexBufferWithCache;
  31551. private _bindVertexBuffersAttributes;
  31552. /**
  31553. * Records a vertex array object
  31554. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31555. * @param vertexBuffers defines the list of vertex buffers to store
  31556. * @param indexBuffer defines the index buffer to store
  31557. * @param effect defines the effect to store
  31558. * @returns the new vertex array object
  31559. */
  31560. recordVertexArrayObject(vertexBuffers: {
  31561. [key: string]: VertexBuffer;
  31562. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31563. /**
  31564. * Bind a specific vertex array object
  31565. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31566. * @param vertexArrayObject defines the vertex array object to bind
  31567. * @param indexBuffer defines the index buffer to bind
  31568. */
  31569. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31570. /**
  31571. * Bind webGl buffers directly to the webGL context
  31572. * @param vertexBuffer defines the vertex buffer to bind
  31573. * @param indexBuffer defines the index buffer to bind
  31574. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31575. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31576. * @param effect defines the effect associated with the vertex buffer
  31577. */
  31578. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31579. private _unbindVertexArrayObject;
  31580. /**
  31581. * Bind a list of vertex buffers to the webGL context
  31582. * @param vertexBuffers defines the list of vertex buffers to bind
  31583. * @param indexBuffer defines the index buffer to bind
  31584. * @param effect defines the effect associated with the vertex buffers
  31585. */
  31586. bindBuffers(vertexBuffers: {
  31587. [key: string]: Nullable<VertexBuffer>;
  31588. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31589. /**
  31590. * Unbind all instance attributes
  31591. */
  31592. unbindInstanceAttributes(): void;
  31593. /**
  31594. * Release and free the memory of a vertex array object
  31595. * @param vao defines the vertex array object to delete
  31596. */
  31597. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31598. /** @hidden */
  31599. _releaseBuffer(buffer: DataBuffer): boolean;
  31600. /**
  31601. * Creates a webGL buffer to use with instanciation
  31602. * @param capacity defines the size of the buffer
  31603. * @returns the webGL buffer
  31604. */
  31605. createInstancesBuffer(capacity: number): DataBuffer;
  31606. /**
  31607. * Delete a webGL buffer used with instanciation
  31608. * @param buffer defines the webGL buffer to delete
  31609. */
  31610. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  31611. /**
  31612. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31613. * @param instancesBuffer defines the webGL buffer to update and bind
  31614. * @param data defines the data to store in the buffer
  31615. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31616. */
  31617. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31618. /**
  31619. * Apply all cached states (depth, culling, stencil and alpha)
  31620. */
  31621. applyStates(): void;
  31622. /**
  31623. * Send a draw order
  31624. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31625. * @param indexStart defines the starting index
  31626. * @param indexCount defines the number of index to draw
  31627. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31628. */
  31629. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31630. /**
  31631. * Draw a list of points
  31632. * @param verticesStart defines the index of first vertex to draw
  31633. * @param verticesCount defines the count of vertices to draw
  31634. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31635. */
  31636. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31637. /**
  31638. * Draw a list of unindexed primitives
  31639. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31640. * @param verticesStart defines the index of first vertex to draw
  31641. * @param verticesCount defines the count of vertices to draw
  31642. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31643. */
  31644. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31645. /**
  31646. * Draw a list of indexed primitives
  31647. * @param fillMode defines the primitive to use
  31648. * @param indexStart defines the starting index
  31649. * @param indexCount defines the number of index to draw
  31650. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31651. */
  31652. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31653. /**
  31654. * Draw a list of unindexed primitives
  31655. * @param fillMode defines the primitive to use
  31656. * @param verticesStart defines the index of first vertex to draw
  31657. * @param verticesCount defines the count of vertices to draw
  31658. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31659. */
  31660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31661. private _drawMode;
  31662. /** @hidden */
  31663. _releaseEffect(effect: Effect): void;
  31664. /** @hidden */
  31665. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31666. /**
  31667. * Create a new effect (used to store vertex/fragment shaders)
  31668. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31669. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  31670. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31671. * @param samplers defines an array of string used to represent textures
  31672. * @param defines defines the string containing the defines to use to compile the shaders
  31673. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31674. * @param onCompiled defines a function to call when the effect creation is successful
  31675. * @param onError defines a function to call when the effect creation has failed
  31676. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31677. * @returns the new Effect
  31678. */
  31679. 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;
  31680. private _compileShader;
  31681. private _compileRawShader;
  31682. /**
  31683. * Directly creates a webGL program
  31684. * @param pipelineContext defines the pipeline context to attach to
  31685. * @param vertexCode defines the vertex shader code to use
  31686. * @param fragmentCode defines the fragment shader code to use
  31687. * @param context defines the webGL context to use (if not set, the current one will be used)
  31688. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31689. * @returns the new webGL program
  31690. */
  31691. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31692. /**
  31693. * Creates a webGL program
  31694. * @param pipelineContext defines the pipeline context to attach to
  31695. * @param vertexCode defines the vertex shader code to use
  31696. * @param fragmentCode defines the fragment shader code to use
  31697. * @param defines defines the string containing the defines to use to compile the shaders
  31698. * @param context defines the webGL context to use (if not set, the current one will be used)
  31699. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31700. * @returns the new webGL program
  31701. */
  31702. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31703. /**
  31704. * Creates a new pipeline context
  31705. * @returns the new pipeline
  31706. */
  31707. createPipelineContext(): WebGLPipelineContext;
  31708. private _createShaderProgram;
  31709. private _finalizePipelineContext;
  31710. /** @hidden */
  31711. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31712. /** @hidden */
  31713. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31714. /** @hidden */
  31715. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31716. /**
  31717. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31718. * @param pipelineContext defines the pipeline context to use
  31719. * @param uniformsNames defines the list of uniform names
  31720. * @returns an array of webGL uniform locations
  31721. */
  31722. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31723. /**
  31724. * Gets the lsit of active attributes for a given webGL program
  31725. * @param pipelineContext defines the pipeline context to use
  31726. * @param attributesNames defines the list of attribute names to get
  31727. * @returns an array of indices indicating the offset of each attribute
  31728. */
  31729. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31730. /**
  31731. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31732. * @param effect defines the effect to activate
  31733. */
  31734. enableEffect(effect: Nullable<Effect>): void;
  31735. /**
  31736. * Set the value of an uniform to an array of int32
  31737. * @param uniform defines the webGL uniform location where to store the value
  31738. * @param array defines the array of int32 to store
  31739. */
  31740. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31741. /**
  31742. * Set the value of an uniform to an array of int32 (stored as vec2)
  31743. * @param uniform defines the webGL uniform location where to store the value
  31744. * @param array defines the array of int32 to store
  31745. */
  31746. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31747. /**
  31748. * Set the value of an uniform to an array of int32 (stored as vec3)
  31749. * @param uniform defines the webGL uniform location where to store the value
  31750. * @param array defines the array of int32 to store
  31751. */
  31752. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31753. /**
  31754. * Set the value of an uniform to an array of int32 (stored as vec4)
  31755. * @param uniform defines the webGL uniform location where to store the value
  31756. * @param array defines the array of int32 to store
  31757. */
  31758. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31759. /**
  31760. * Set the value of an uniform to an array of float32
  31761. * @param uniform defines the webGL uniform location where to store the value
  31762. * @param array defines the array of float32 to store
  31763. */
  31764. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31765. /**
  31766. * Set the value of an uniform to an array of float32 (stored as vec2)
  31767. * @param uniform defines the webGL uniform location where to store the value
  31768. * @param array defines the array of float32 to store
  31769. */
  31770. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31771. /**
  31772. * Set the value of an uniform to an array of float32 (stored as vec3)
  31773. * @param uniform defines the webGL uniform location where to store the value
  31774. * @param array defines the array of float32 to store
  31775. */
  31776. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31777. /**
  31778. * Set the value of an uniform to an array of float32 (stored as vec4)
  31779. * @param uniform defines the webGL uniform location where to store the value
  31780. * @param array defines the array of float32 to store
  31781. */
  31782. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  31783. /**
  31784. * Set the value of an uniform to an array of number
  31785. * @param uniform defines the webGL uniform location where to store the value
  31786. * @param array defines the array of number to store
  31787. */
  31788. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31789. /**
  31790. * Set the value of an uniform to an array of number (stored as vec2)
  31791. * @param uniform defines the webGL uniform location where to store the value
  31792. * @param array defines the array of number to store
  31793. */
  31794. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31795. /**
  31796. * Set the value of an uniform to an array of number (stored as vec3)
  31797. * @param uniform defines the webGL uniform location where to store the value
  31798. * @param array defines the array of number to store
  31799. */
  31800. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31801. /**
  31802. * Set the value of an uniform to an array of number (stored as vec4)
  31803. * @param uniform defines the webGL uniform location where to store the value
  31804. * @param array defines the array of number to store
  31805. */
  31806. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  31807. /**
  31808. * Set the value of an uniform to an array of float32 (stored as matrices)
  31809. * @param uniform defines the webGL uniform location where to store the value
  31810. * @param matrices defines the array of float32 to store
  31811. */
  31812. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31813. /**
  31814. * Set the value of an uniform to a matrix (3x3)
  31815. * @param uniform defines the webGL uniform location where to store the value
  31816. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31817. */
  31818. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31819. /**
  31820. * Set the value of an uniform to a matrix (2x2)
  31821. * @param uniform defines the webGL uniform location where to store the value
  31822. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31823. */
  31824. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31825. /**
  31826. * Set the value of an uniform to a number (int)
  31827. * @param uniform defines the webGL uniform location where to store the value
  31828. * @param value defines the int number to store
  31829. */
  31830. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31831. /**
  31832. * Set the value of an uniform to a number (float)
  31833. * @param uniform defines the webGL uniform location where to store the value
  31834. * @param value defines the float number to store
  31835. */
  31836. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31837. /**
  31838. * Set the value of an uniform to a vec2
  31839. * @param uniform defines the webGL uniform location where to store the value
  31840. * @param x defines the 1st component of the value
  31841. * @param y defines the 2nd component of the value
  31842. */
  31843. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31844. /**
  31845. * Set the value of an uniform to a vec3
  31846. * @param uniform defines the webGL uniform location where to store the value
  31847. * @param x defines the 1st component of the value
  31848. * @param y defines the 2nd component of the value
  31849. * @param z defines the 3rd component of the value
  31850. */
  31851. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31852. /**
  31853. * Set the value of an uniform to a boolean
  31854. * @param uniform defines the webGL uniform location where to store the value
  31855. * @param bool defines the boolean to store
  31856. */
  31857. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  31858. /**
  31859. * Set the value of an uniform to a vec4
  31860. * @param uniform defines the webGL uniform location where to store the value
  31861. * @param x defines the 1st component of the value
  31862. * @param y defines the 2nd component of the value
  31863. * @param z defines the 3rd component of the value
  31864. * @param w defines the 4th component of the value
  31865. */
  31866. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31867. /**
  31868. * Sets a Color4 on a uniform variable
  31869. * @param uniform defines the uniform location
  31870. * @param color4 defines the value to be set
  31871. */
  31872. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  31873. /**
  31874. * Set various states to the webGL context
  31875. * @param culling defines backface culling state
  31876. * @param zOffset defines the value to apply to zOffset (0 by default)
  31877. * @param force defines if states must be applied even if cache is up to date
  31878. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  31879. */
  31880. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  31881. /**
  31882. * Set the z offset to apply to current rendering
  31883. * @param value defines the offset to apply
  31884. */
  31885. setZOffset(value: number): void;
  31886. /**
  31887. * Gets the current value of the zOffset
  31888. * @returns the current zOffset state
  31889. */
  31890. getZOffset(): number;
  31891. /**
  31892. * Enable or disable depth buffering
  31893. * @param enable defines the state to set
  31894. */
  31895. setDepthBuffer(enable: boolean): void;
  31896. /**
  31897. * Gets a boolean indicating if depth writing is enabled
  31898. * @returns the current depth writing state
  31899. */
  31900. getDepthWrite(): boolean;
  31901. /**
  31902. * Enable or disable depth writing
  31903. * @param enable defines the state to set
  31904. */
  31905. setDepthWrite(enable: boolean): void;
  31906. /**
  31907. * Enable or disable color writing
  31908. * @param enable defines the state to set
  31909. */
  31910. setColorWrite(enable: boolean): void;
  31911. /**
  31912. * Gets a boolean indicating if color writing is enabled
  31913. * @returns the current color writing state
  31914. */
  31915. getColorWrite(): boolean;
  31916. /**
  31917. * Sets alpha constants used by some alpha blending modes
  31918. * @param r defines the red component
  31919. * @param g defines the green component
  31920. * @param b defines the blue component
  31921. * @param a defines the alpha component
  31922. */
  31923. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  31924. /**
  31925. * Sets the current alpha mode
  31926. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  31927. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  31928. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31929. */
  31930. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  31931. /**
  31932. * Gets the current alpha mode
  31933. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  31934. * @returns the current alpha mode
  31935. */
  31936. getAlphaMode(): number;
  31937. /**
  31938. * Clears the list of texture accessible through engine.
  31939. * This can help preventing texture load conflict due to name collision.
  31940. */
  31941. clearInternalTexturesCache(): void;
  31942. /**
  31943. * Force the entire cache to be cleared
  31944. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31945. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31946. */
  31947. wipeCaches(bruteForce?: boolean): void;
  31948. /**
  31949. * Set the compressed texture format to use, based on the formats you have, and the formats
  31950. * supported by the hardware / browser.
  31951. *
  31952. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  31953. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  31954. * to API arguments needed to compressed textures. This puts the burden on the container
  31955. * generator to house the arcane code for determining these for current & future formats.
  31956. *
  31957. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  31958. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  31959. *
  31960. * Note: The result of this call is not taken into account when a texture is base64.
  31961. *
  31962. * @param formatsAvailable defines the list of those format families you have created
  31963. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  31964. *
  31965. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  31966. * @returns The extension selected.
  31967. */
  31968. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  31969. /** @hidden */
  31970. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31971. min: number;
  31972. mag: number;
  31973. };
  31974. /** @hidden */
  31975. _createTexture(): WebGLTexture;
  31976. /**
  31977. * Usually called from Texture.ts.
  31978. * Passed information to create a WebGLTexture
  31979. * @param urlArg defines a value which contains one of the following:
  31980. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31981. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31982. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31983. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31984. * @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)
  31985. * @param scene needed for loading to the correct scene
  31986. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31987. * @param onLoad optional callback to be called upon successful completion
  31988. * @param onError optional callback to be called upon failure
  31989. * @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
  31990. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31991. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31992. * @param forcedExtension defines the extension to use to pick the right loader
  31993. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31994. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31995. */
  31996. 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;
  31997. /**
  31998. * @hidden
  31999. * Rescales a texture
  32000. * @param source input texutre
  32001. * @param destination destination texture
  32002. * @param scene scene to use to render the resize
  32003. * @param internalFormat format to use when resizing
  32004. * @param onComplete callback to be called when resize has completed
  32005. */
  32006. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  32007. private _unpackFlipYCached;
  32008. /**
  32009. * In case you are sharing the context with other applications, it might
  32010. * be interested to not cache the unpack flip y state to ensure a consistent
  32011. * value would be set.
  32012. */
  32013. enableUnpackFlipYCached: boolean;
  32014. /** @hidden */
  32015. _unpackFlipY(value: boolean): void;
  32016. /** @hidden */
  32017. _getUnpackAlignement(): number;
  32018. /**
  32019. * Creates a dynamic texture
  32020. * @param width defines the width of the texture
  32021. * @param height defines the height of the texture
  32022. * @param generateMipMaps defines if the engine should generate the mip levels
  32023. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32024. * @returns the dynamic texture inside an InternalTexture
  32025. */
  32026. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  32027. /**
  32028. * Update the sampling mode of a given texture
  32029. * @param samplingMode defines the required sampling mode
  32030. * @param texture defines the texture to update
  32031. */
  32032. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  32033. /**
  32034. * Update the content of a dynamic texture
  32035. * @param texture defines the texture to update
  32036. * @param canvas defines the canvas containing the source
  32037. * @param invertY defines if data must be stored with Y axis inverted
  32038. * @param premulAlpha defines if alpha is stored as premultiplied
  32039. * @param format defines the format of the data
  32040. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  32041. */
  32042. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  32043. /**
  32044. * Update a video texture
  32045. * @param texture defines the texture to update
  32046. * @param video defines the video element to use
  32047. * @param invertY defines if data must be stored with Y axis inverted
  32048. */
  32049. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32050. /**
  32051. * Updates a depth texture Comparison Mode and Function.
  32052. * If the comparison Function is equal to 0, the mode will be set to none.
  32053. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  32054. * @param texture The texture to set the comparison function for
  32055. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  32056. */
  32057. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  32058. /** @hidden */
  32059. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32060. width: number;
  32061. height: number;
  32062. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32063. /**
  32064. * Creates a depth stencil texture.
  32065. * This is only available in WebGL 2 or with the depth texture extension available.
  32066. * @param size The size of face edge in the texture.
  32067. * @param options The options defining the texture.
  32068. * @returns The texture
  32069. */
  32070. createDepthStencilTexture(size: number | {
  32071. width: number;
  32072. height: number;
  32073. }, options: DepthTextureCreationOptions): InternalTexture;
  32074. /**
  32075. * Creates a depth stencil texture.
  32076. * This is only available in WebGL 2 or with the depth texture extension available.
  32077. * @param size The size of face edge in the texture.
  32078. * @param options The options defining the texture.
  32079. * @returns The texture
  32080. */
  32081. private _createDepthStencilTexture;
  32082. /**
  32083. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32084. * @param renderTarget The render target to set the frame buffer for
  32085. */
  32086. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32087. /**
  32088. * Creates a new render target texture
  32089. * @param size defines the size of the texture
  32090. * @param options defines the options used to create the texture
  32091. * @returns a new render target texture stored in an InternalTexture
  32092. */
  32093. createRenderTargetTexture(size: number | {
  32094. width: number;
  32095. height: number;
  32096. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32097. /** @hidden */
  32098. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32099. /**
  32100. * Updates the sample count of a render target texture
  32101. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32102. * @param texture defines the texture to update
  32103. * @param samples defines the sample count to set
  32104. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32105. */
  32106. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32107. /** @hidden */
  32108. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32109. /** @hidden */
  32110. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32111. /** @hidden */
  32112. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32113. /** @hidden */
  32114. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  32115. /**
  32116. * @hidden
  32117. */
  32118. _setCubeMapTextureParams(loadMipmap: boolean): void;
  32119. private _prepareWebGLTextureContinuation;
  32120. private _prepareWebGLTexture;
  32121. /** @hidden */
  32122. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32123. /** @hidden */
  32124. _releaseFramebufferObjects(texture: InternalTexture): void;
  32125. /** @hidden */
  32126. _releaseTexture(texture: InternalTexture): void;
  32127. private setProgram;
  32128. private _boundUniforms;
  32129. /**
  32130. * Binds an effect to the webGL context
  32131. * @param effect defines the effect to bind
  32132. */
  32133. bindSamplers(effect: Effect): void;
  32134. private _activateCurrentTexture;
  32135. /** @hidden */
  32136. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32137. /** @hidden */
  32138. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32139. /**
  32140. * Sets a texture to the webGL context from a postprocess
  32141. * @param channel defines the channel to use
  32142. * @param postProcess defines the source postprocess
  32143. */
  32144. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32145. /**
  32146. * Binds the output of the passed in post process to the texture channel specified
  32147. * @param channel The channel the texture should be bound to
  32148. * @param postProcess The post process which's output should be bound
  32149. */
  32150. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32151. /**
  32152. * Unbind all textures from the webGL context
  32153. */
  32154. unbindAllTextures(): void;
  32155. /**
  32156. * Sets a texture to the according uniform.
  32157. * @param channel The texture channel
  32158. * @param uniform The uniform to set
  32159. * @param texture The texture to apply
  32160. */
  32161. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32162. /**
  32163. * Sets a depth stencil texture from a render target to the according uniform.
  32164. * @param channel The texture channel
  32165. * @param uniform The uniform to set
  32166. * @param texture The render target texture containing the depth stencil texture to apply
  32167. */
  32168. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32169. private _bindSamplerUniformToChannel;
  32170. private _getTextureWrapMode;
  32171. private _setTexture;
  32172. /**
  32173. * Sets an array of texture to the webGL context
  32174. * @param channel defines the channel where the texture array must be set
  32175. * @param uniform defines the associated uniform location
  32176. * @param textures defines the array of textures to bind
  32177. */
  32178. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32179. /** @hidden */
  32180. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  32181. private _setTextureParameterFloat;
  32182. private _setTextureParameterInteger;
  32183. /**
  32184. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32185. * @param x defines the x coordinate of the rectangle where pixels must be read
  32186. * @param y defines the y coordinate of the rectangle where pixels must be read
  32187. * @param width defines the width of the rectangle where pixels must be read
  32188. * @param height defines the height of the rectangle where pixels must be read
  32189. * @returns a Uint8Array containing RGBA colors
  32190. */
  32191. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32192. /**
  32193. * Add an externaly attached data from its key.
  32194. * This method call will fail and return false, if such key already exists.
  32195. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32196. * @param key the unique key that identifies the data
  32197. * @param data the data object to associate to the key for this Engine instance
  32198. * @return true if no such key were already present and the data was added successfully, false otherwise
  32199. */
  32200. addExternalData<T>(key: string, data: T): boolean;
  32201. /**
  32202. * Get an externaly attached data from its key
  32203. * @param key the unique key that identifies the data
  32204. * @return the associated data, if present (can be null), or undefined if not present
  32205. */
  32206. getExternalData<T>(key: string): T;
  32207. /**
  32208. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32209. * @param key the unique key that identifies the data
  32210. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32211. * @return the associated data, can be null if the factory returned null.
  32212. */
  32213. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32214. /**
  32215. * Remove an externaly attached data from the Engine instance
  32216. * @param key the unique key that identifies the data
  32217. * @return true if the data was successfully removed, false if it doesn't exist
  32218. */
  32219. removeExternalData(key: string): boolean;
  32220. /**
  32221. * Unbind all vertex attributes from the webGL context
  32222. */
  32223. unbindAllAttributes(): void;
  32224. /**
  32225. * 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
  32226. */
  32227. releaseEffects(): void;
  32228. /**
  32229. * Dispose and release all associated resources
  32230. */
  32231. dispose(): void;
  32232. /**
  32233. * Display the loading screen
  32234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32235. */
  32236. displayLoadingUI(): void;
  32237. /**
  32238. * Hide the loading screen
  32239. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32240. */
  32241. hideLoadingUI(): void;
  32242. /**
  32243. * Gets the current loading screen object
  32244. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32245. */
  32246. /**
  32247. * Sets the current loading screen object
  32248. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32249. */
  32250. loadingScreen: ILoadingScreen;
  32251. /**
  32252. * Sets the current loading screen text
  32253. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32254. */
  32255. loadingUIText: string;
  32256. /**
  32257. * Sets the current loading screen background color
  32258. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32259. */
  32260. loadingUIBackgroundColor: string;
  32261. /**
  32262. * Attach a new callback raised when context lost event is fired
  32263. * @param callback defines the callback to call
  32264. */
  32265. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32266. /**
  32267. * Attach a new callback raised when context restored event is fired
  32268. * @param callback defines the callback to call
  32269. */
  32270. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32271. /**
  32272. * Gets the source code of the vertex shader associated with a specific webGL program
  32273. * @param program defines the program to use
  32274. * @returns a string containing the source code of the vertex shader associated with the program
  32275. */
  32276. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32277. /**
  32278. * Gets the source code of the fragment shader associated with a specific webGL program
  32279. * @param program defines the program to use
  32280. * @returns a string containing the source code of the fragment shader associated with the program
  32281. */
  32282. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32283. /**
  32284. * Get the current error code of the webGL context
  32285. * @returns the error code
  32286. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32287. */
  32288. getError(): number;
  32289. /**
  32290. * Gets the current framerate
  32291. * @returns a number representing the framerate
  32292. */
  32293. getFps(): number;
  32294. /**
  32295. * Gets the time spent between current and previous frame
  32296. * @returns a number representing the delta time in ms
  32297. */
  32298. getDeltaTime(): number;
  32299. private _measureFps;
  32300. /** @hidden */
  32301. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32302. private _canRenderToFloatFramebuffer;
  32303. private _canRenderToHalfFloatFramebuffer;
  32304. private _canRenderToFramebuffer;
  32305. /** @hidden */
  32306. _getWebGLTextureType(type: number): number;
  32307. /** @hidden */
  32308. _getInternalFormat(format: number): number;
  32309. /** @hidden */
  32310. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32311. /** @hidden */
  32312. _getRGBAMultiSampleBufferFormat(type: number): number;
  32313. /** @hidden */
  32314. _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;
  32315. /** @hidden */
  32316. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32317. /**
  32318. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32319. * @returns true if the engine can be created
  32320. * @ignorenaming
  32321. */
  32322. static isSupported(): boolean;
  32323. /**
  32324. * Find the next highest power of two.
  32325. * @param x Number to start search from.
  32326. * @return Next highest power of two.
  32327. */
  32328. static CeilingPOT(x: number): number;
  32329. /**
  32330. * Find the next lowest power of two.
  32331. * @param x Number to start search from.
  32332. * @return Next lowest power of two.
  32333. */
  32334. static FloorPOT(x: number): number;
  32335. /**
  32336. * Find the nearest power of two.
  32337. * @param x Number to start search from.
  32338. * @return Next nearest power of two.
  32339. */
  32340. static NearestPOT(x: number): number;
  32341. /**
  32342. * Get the closest exponent of two
  32343. * @param value defines the value to approximate
  32344. * @param max defines the maximum value to return
  32345. * @param mode defines how to define the closest value
  32346. * @returns closest exponent of two of the given value
  32347. */
  32348. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32349. /**
  32350. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32351. * @param func - the function to be called
  32352. * @param requester - the object that will request the next frame. Falls back to window.
  32353. * @returns frame number
  32354. */
  32355. static QueueNewFrame(func: () => void, requester?: any): number;
  32356. /**
  32357. * Ask the browser to promote the current element to pointerlock mode
  32358. * @param element defines the DOM element to promote
  32359. */
  32360. static _RequestPointerlock(element: HTMLElement): void;
  32361. /**
  32362. * Asks the browser to exit pointerlock mode
  32363. */
  32364. static _ExitPointerlock(): void;
  32365. /**
  32366. * Ask the browser to promote the current element to fullscreen rendering mode
  32367. * @param element defines the DOM element to promote
  32368. */
  32369. static _RequestFullscreen(element: HTMLElement): void;
  32370. /**
  32371. * Asks the browser to exit fullscreen mode
  32372. */
  32373. static _ExitFullscreen(): void;
  32374. }
  32375. }
  32376. declare module "babylonjs/Engines/engineStore" {
  32377. import { Nullable } from "babylonjs/types";
  32378. import { Engine } from "babylonjs/Engines/engine";
  32379. import { Scene } from "babylonjs/scene";
  32380. /**
  32381. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32382. * during the life time of the application.
  32383. */
  32384. export class EngineStore {
  32385. /** Gets the list of created engines */
  32386. static Instances: import("babylonjs/Engines/engine").Engine[];
  32387. /** @hidden */
  32388. static _LastCreatedScene: Nullable<Scene>;
  32389. /**
  32390. * Gets the latest created engine
  32391. */
  32392. static readonly LastCreatedEngine: Nullable<Engine>;
  32393. /**
  32394. * Gets the latest created scene
  32395. */
  32396. static readonly LastCreatedScene: Nullable<Scene>;
  32397. /**
  32398. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32399. * @ignorenaming
  32400. */
  32401. static UseFallbackTexture: boolean;
  32402. /**
  32403. * Texture content used if a texture cannot loaded
  32404. * @ignorenaming
  32405. */
  32406. static FallbackTexture: string;
  32407. }
  32408. }
  32409. declare module "babylonjs/Misc/promise" {
  32410. /**
  32411. * Helper class that provides a small promise polyfill
  32412. */
  32413. export class PromisePolyfill {
  32414. /**
  32415. * Static function used to check if the polyfill is required
  32416. * If this is the case then the function will inject the polyfill to window.Promise
  32417. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32418. */
  32419. static Apply(force?: boolean): void;
  32420. }
  32421. }
  32422. declare module "babylonjs/Misc/tools" {
  32423. import { Nullable, float } from "babylonjs/types";
  32424. import { DomManagement } from "babylonjs/Misc/domManagement";
  32425. import { WebRequest } from "babylonjs/Misc/webRequest";
  32426. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32427. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32428. import { Camera } from "babylonjs/Cameras/camera";
  32429. import { Engine } from "babylonjs/Engines/engine";
  32430. interface IColor4Like {
  32431. r: float;
  32432. g: float;
  32433. b: float;
  32434. a: float;
  32435. }
  32436. /**
  32437. * Class containing a set of static utilities functions
  32438. */
  32439. export class Tools {
  32440. /**
  32441. * Gets or sets the base URL to use to load assets
  32442. */
  32443. static BaseUrl: string;
  32444. /**
  32445. * Enable/Disable Custom HTTP Request Headers globally.
  32446. * default = false
  32447. * @see CustomRequestHeaders
  32448. */
  32449. static UseCustomRequestHeaders: boolean;
  32450. /**
  32451. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32452. * i.e. when loading files, where the server/service expects an Authorization header
  32453. */
  32454. static CustomRequestHeaders: {
  32455. [key: string]: string;
  32456. };
  32457. /**
  32458. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32459. */
  32460. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32461. /**
  32462. * Default behaviour for cors in the application.
  32463. * It can be a string if the expected behavior is identical in the entire app.
  32464. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32465. */
  32466. static CorsBehavior: string | ((url: string | string[]) => string);
  32467. /**
  32468. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32469. * @ignorenaming
  32470. */
  32471. static UseFallbackTexture: boolean;
  32472. /**
  32473. * Use this object to register external classes like custom textures or material
  32474. * to allow the laoders to instantiate them
  32475. */
  32476. static RegisteredExternalClasses: {
  32477. [key: string]: Object;
  32478. };
  32479. /**
  32480. * Texture content used if a texture cannot loaded
  32481. * @ignorenaming
  32482. */
  32483. static fallbackTexture: string;
  32484. /**
  32485. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32486. * @param u defines the coordinate on X axis
  32487. * @param v defines the coordinate on Y axis
  32488. * @param width defines the width of the source data
  32489. * @param height defines the height of the source data
  32490. * @param pixels defines the source byte array
  32491. * @param color defines the output color
  32492. */
  32493. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32494. /**
  32495. * Interpolates between a and b via alpha
  32496. * @param a The lower value (returned when alpha = 0)
  32497. * @param b The upper value (returned when alpha = 1)
  32498. * @param alpha The interpolation-factor
  32499. * @return The mixed value
  32500. */
  32501. static Mix(a: number, b: number, alpha: number): number;
  32502. /**
  32503. * Tries to instantiate a new object from a given class name
  32504. * @param className defines the class name to instantiate
  32505. * @returns the new object or null if the system was not able to do the instantiation
  32506. */
  32507. static Instantiate(className: string): any;
  32508. /**
  32509. * Provides a slice function that will work even on IE
  32510. * @param data defines the array to slice
  32511. * @param start defines the start of the data (optional)
  32512. * @param end defines the end of the data (optional)
  32513. * @returns the new sliced array
  32514. */
  32515. static Slice<T>(data: T, start?: number, end?: number): T;
  32516. /**
  32517. * Polyfill for setImmediate
  32518. * @param action defines the action to execute after the current execution block
  32519. */
  32520. static SetImmediate(action: () => void): void;
  32521. /**
  32522. * Function indicating if a number is an exponent of 2
  32523. * @param value defines the value to test
  32524. * @returns true if the value is an exponent of 2
  32525. */
  32526. static IsExponentOfTwo(value: number): boolean;
  32527. private static _tmpFloatArray;
  32528. /**
  32529. * Returns the nearest 32-bit single precision float representation of a Number
  32530. * @param value A Number. If the parameter is of a different type, it will get converted
  32531. * to a number or to NaN if it cannot be converted
  32532. * @returns number
  32533. */
  32534. static FloatRound(value: number): number;
  32535. /**
  32536. * Extracts the filename from a path
  32537. * @param path defines the path to use
  32538. * @returns the filename
  32539. */
  32540. static GetFilename(path: string): string;
  32541. /**
  32542. * Extracts the "folder" part of a path (everything before the filename).
  32543. * @param uri The URI to extract the info from
  32544. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32545. * @returns The "folder" part of the path
  32546. */
  32547. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32548. /**
  32549. * Extracts text content from a DOM element hierarchy
  32550. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32551. */
  32552. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32553. /**
  32554. * Convert an angle in radians to degrees
  32555. * @param angle defines the angle to convert
  32556. * @returns the angle in degrees
  32557. */
  32558. static ToDegrees(angle: number): number;
  32559. /**
  32560. * Convert an angle in degrees to radians
  32561. * @param angle defines the angle to convert
  32562. * @returns the angle in radians
  32563. */
  32564. static ToRadians(angle: number): number;
  32565. /**
  32566. * Encode a buffer to a base64 string
  32567. * @param buffer defines the buffer to encode
  32568. * @returns the encoded string
  32569. */
  32570. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32571. /**
  32572. * Returns an array if obj is not an array
  32573. * @param obj defines the object to evaluate as an array
  32574. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32575. * @returns either obj directly if obj is an array or a new array containing obj
  32576. */
  32577. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32578. /**
  32579. * Gets the pointer prefix to use
  32580. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32581. */
  32582. static GetPointerPrefix(): string;
  32583. /**
  32584. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32585. * @param url define the url we are trying
  32586. * @param element define the dom element where to configure the cors policy
  32587. */
  32588. static SetCorsBehavior(url: string | string[], element: {
  32589. crossOrigin: string | null;
  32590. }): void;
  32591. /**
  32592. * Removes unwanted characters from an url
  32593. * @param url defines the url to clean
  32594. * @returns the cleaned url
  32595. */
  32596. static CleanUrl(url: string): string;
  32597. /**
  32598. * Gets or sets a function used to pre-process url before using them to load assets
  32599. */
  32600. static PreprocessUrl: (url: string) => string;
  32601. /**
  32602. * Loads an image as an HTMLImageElement.
  32603. * @param input url string, ArrayBuffer, or Blob to load
  32604. * @param onLoad callback called when the image successfully loads
  32605. * @param onError callback called when the image fails to load
  32606. * @param offlineProvider offline provider for caching
  32607. * @returns the HTMLImageElement of the loaded image
  32608. */
  32609. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32610. /**
  32611. * Loads a file
  32612. * @param url url string, ArrayBuffer, or Blob to load
  32613. * @param onSuccess callback called when the file successfully loads
  32614. * @param onProgress callback called while file is loading (if the server supports this mode)
  32615. * @param offlineProvider defines the offline provider for caching
  32616. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32617. * @param onError callback called when the file fails to load
  32618. * @returns a file request object
  32619. */
  32620. 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;
  32621. /**
  32622. * Loads a file from a url
  32623. * @param url the file url to load
  32624. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32625. */
  32626. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32627. /**
  32628. * Load a script (identified by an url). When the url returns, the
  32629. * content of this file is added into a new script element, attached to the DOM (body element)
  32630. * @param scriptUrl defines the url of the script to laod
  32631. * @param onSuccess defines the callback called when the script is loaded
  32632. * @param onError defines the callback to call if an error occurs
  32633. * @param scriptId defines the id of the script element
  32634. */
  32635. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32636. /**
  32637. * Load an asynchronous script (identified by an url). When the url returns, the
  32638. * content of this file is added into a new script element, attached to the DOM (body element)
  32639. * @param scriptUrl defines the url of the script to laod
  32640. * @param scriptId defines the id of the script element
  32641. * @returns a promise request object
  32642. */
  32643. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32644. /**
  32645. * Loads a file from a blob
  32646. * @param fileToLoad defines the blob to use
  32647. * @param callback defines the callback to call when data is loaded
  32648. * @param progressCallback defines the callback to call during loading process
  32649. * @returns a file request object
  32650. */
  32651. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32652. /**
  32653. * Loads a file
  32654. * @param fileToLoad defines the file to load
  32655. * @param callback defines the callback to call when data is loaded
  32656. * @param progressCallBack defines the callback to call during loading process
  32657. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32658. * @returns a file request object
  32659. */
  32660. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32661. /**
  32662. * Creates a data url from a given string content
  32663. * @param content defines the content to convert
  32664. * @returns the new data url link
  32665. */
  32666. static FileAsURL(content: string): string;
  32667. /**
  32668. * Format the given number to a specific decimal format
  32669. * @param value defines the number to format
  32670. * @param decimals defines the number of decimals to use
  32671. * @returns the formatted string
  32672. */
  32673. static Format(value: number, decimals?: number): string;
  32674. /**
  32675. * Tries to copy an object by duplicating every property
  32676. * @param source defines the source object
  32677. * @param destination defines the target object
  32678. * @param doNotCopyList defines a list of properties to avoid
  32679. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32680. */
  32681. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32682. /**
  32683. * Gets a boolean indicating if the given object has no own property
  32684. * @param obj defines the object to test
  32685. * @returns true if object has no own property
  32686. */
  32687. static IsEmpty(obj: any): boolean;
  32688. /**
  32689. * Function used to register events at window level
  32690. * @param events defines the events to register
  32691. */
  32692. static RegisterTopRootEvents(events: {
  32693. name: string;
  32694. handler: Nullable<(e: FocusEvent) => any>;
  32695. }[]): void;
  32696. /**
  32697. * Function used to unregister events from window level
  32698. * @param events defines the events to unregister
  32699. */
  32700. static UnregisterTopRootEvents(events: {
  32701. name: string;
  32702. handler: Nullable<(e: FocusEvent) => any>;
  32703. }[]): void;
  32704. /**
  32705. * @ignore
  32706. */
  32707. static _ScreenshotCanvas: HTMLCanvasElement;
  32708. /**
  32709. * Dumps the current bound framebuffer
  32710. * @param width defines the rendering width
  32711. * @param height defines the rendering height
  32712. * @param engine defines the hosting engine
  32713. * @param successCallback defines the callback triggered once the data are available
  32714. * @param mimeType defines the mime type of the result
  32715. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32716. */
  32717. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32718. /**
  32719. * Converts the canvas data to blob.
  32720. * This acts as a polyfill for browsers not supporting the to blob function.
  32721. * @param canvas Defines the canvas to extract the data from
  32722. * @param successCallback Defines the callback triggered once the data are available
  32723. * @param mimeType Defines the mime type of the result
  32724. */
  32725. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32726. /**
  32727. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32728. * @param successCallback defines the callback triggered once the data are available
  32729. * @param mimeType defines the mime type of the result
  32730. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32731. */
  32732. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32733. /**
  32734. * Downloads a blob in the browser
  32735. * @param blob defines the blob to download
  32736. * @param fileName defines the name of the downloaded file
  32737. */
  32738. static Download(blob: Blob, fileName: string): void;
  32739. /**
  32740. * Captures a screenshot of the current rendering
  32741. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32742. * @param engine defines the rendering engine
  32743. * @param camera defines the source camera
  32744. * @param size This parameter can be set to a single number or to an object with the
  32745. * following (optional) properties: precision, width, height. If a single number is passed,
  32746. * it will be used for both width and height. If an object is passed, the screenshot size
  32747. * will be derived from the parameters. The precision property is a multiplier allowing
  32748. * rendering at a higher or lower resolution
  32749. * @param successCallback defines the callback receives a single parameter which contains the
  32750. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32751. * src parameter of an <img> to display it
  32752. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32753. * Check your browser for supported MIME types
  32754. */
  32755. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32756. /**
  32757. * Captures a screenshot of the current rendering
  32758. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32759. * @param engine defines the rendering engine
  32760. * @param camera defines the source camera
  32761. * @param size This parameter can be set to a single number or to an object with the
  32762. * following (optional) properties: precision, width, height. If a single number is passed,
  32763. * it will be used for both width and height. If an object is passed, the screenshot size
  32764. * will be derived from the parameters. The precision property is a multiplier allowing
  32765. * rendering at a higher or lower resolution
  32766. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32767. * Check your browser for supported MIME types
  32768. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32769. * to the src parameter of an <img> to display it
  32770. */
  32771. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  32772. /**
  32773. * Generates an image screenshot from the specified camera.
  32774. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32775. * @param engine The engine to use for rendering
  32776. * @param camera The camera to use for rendering
  32777. * @param size This parameter can be set to a single number or to an object with the
  32778. * following (optional) properties: precision, width, height. If a single number is passed,
  32779. * it will be used for both width and height. If an object is passed, the screenshot size
  32780. * will be derived from the parameters. The precision property is a multiplier allowing
  32781. * rendering at a higher or lower resolution
  32782. * @param successCallback The callback receives a single parameter which contains the
  32783. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32784. * src parameter of an <img> to display it
  32785. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32786. * Check your browser for supported MIME types
  32787. * @param samples Texture samples (default: 1)
  32788. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32789. * @param fileName A name for for the downloaded file.
  32790. */
  32791. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32792. /**
  32793. * Generates an image screenshot from the specified camera.
  32794. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32795. * @param engine The engine to use for rendering
  32796. * @param camera The camera to use for rendering
  32797. * @param size This parameter can be set to a single number or to an object with the
  32798. * following (optional) properties: precision, width, height. If a single number is passed,
  32799. * it will be used for both width and height. If an object is passed, the screenshot size
  32800. * will be derived from the parameters. The precision property is a multiplier allowing
  32801. * rendering at a higher or lower resolution
  32802. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32803. * Check your browser for supported MIME types
  32804. * @param samples Texture samples (default: 1)
  32805. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32806. * @param fileName A name for for the downloaded file.
  32807. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  32808. * to the src parameter of an <img> to display it
  32809. */
  32810. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  32811. /**
  32812. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32813. * Be aware Math.random() could cause collisions, but:
  32814. * "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"
  32815. * @returns a pseudo random id
  32816. */
  32817. static RandomId(): string;
  32818. /**
  32819. * Test if the given uri is a base64 string
  32820. * @param uri The uri to test
  32821. * @return True if the uri is a base64 string or false otherwise
  32822. */
  32823. static IsBase64(uri: string): boolean;
  32824. /**
  32825. * Decode the given base64 uri.
  32826. * @param uri The uri to decode
  32827. * @return The decoded base64 data.
  32828. */
  32829. static DecodeBase64(uri: string): ArrayBuffer;
  32830. /**
  32831. * Gets the absolute url.
  32832. * @param url the input url
  32833. * @return the absolute url
  32834. */
  32835. static GetAbsoluteUrl(url: string): string;
  32836. /**
  32837. * No log
  32838. */
  32839. static readonly NoneLogLevel: number;
  32840. /**
  32841. * Only message logs
  32842. */
  32843. static readonly MessageLogLevel: number;
  32844. /**
  32845. * Only warning logs
  32846. */
  32847. static readonly WarningLogLevel: number;
  32848. /**
  32849. * Only error logs
  32850. */
  32851. static readonly ErrorLogLevel: number;
  32852. /**
  32853. * All logs
  32854. */
  32855. static readonly AllLogLevel: number;
  32856. /**
  32857. * Gets a value indicating the number of loading errors
  32858. * @ignorenaming
  32859. */
  32860. static readonly errorsCount: number;
  32861. /**
  32862. * Callback called when a new log is added
  32863. */
  32864. static OnNewCacheEntry: (entry: string) => void;
  32865. /**
  32866. * Log a message to the console
  32867. * @param message defines the message to log
  32868. */
  32869. static Log(message: string): void;
  32870. /**
  32871. * Write a warning message to the console
  32872. * @param message defines the message to log
  32873. */
  32874. static Warn(message: string): void;
  32875. /**
  32876. * Write an error message to the console
  32877. * @param message defines the message to log
  32878. */
  32879. static Error(message: string): void;
  32880. /**
  32881. * Gets current log cache (list of logs)
  32882. */
  32883. static readonly LogCache: string;
  32884. /**
  32885. * Clears the log cache
  32886. */
  32887. static ClearLogCache(): void;
  32888. /**
  32889. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32890. */
  32891. static LogLevels: number;
  32892. /**
  32893. * Checks if the window object exists
  32894. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32895. */
  32896. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32897. /**
  32898. * No performance log
  32899. */
  32900. static readonly PerformanceNoneLogLevel: number;
  32901. /**
  32902. * Use user marks to log performance
  32903. */
  32904. static readonly PerformanceUserMarkLogLevel: number;
  32905. /**
  32906. * Log performance to the console
  32907. */
  32908. static readonly PerformanceConsoleLogLevel: number;
  32909. private static _performance;
  32910. /**
  32911. * Sets the current performance log level
  32912. */
  32913. static PerformanceLogLevel: number;
  32914. private static _StartPerformanceCounterDisabled;
  32915. private static _EndPerformanceCounterDisabled;
  32916. private static _StartUserMark;
  32917. private static _EndUserMark;
  32918. private static _StartPerformanceConsole;
  32919. private static _EndPerformanceConsole;
  32920. /**
  32921. * Starts a performance counter
  32922. */
  32923. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32924. /**
  32925. * Ends a specific performance coutner
  32926. */
  32927. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32928. /**
  32929. * Gets either window.performance.now() if supported or Date.now() else
  32930. */
  32931. static readonly Now: number;
  32932. /**
  32933. * This method will return the name of the class used to create the instance of the given object.
  32934. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32935. * @param object the object to get the class name from
  32936. * @param isType defines if the object is actually a type
  32937. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32938. */
  32939. static GetClassName(object: any, isType?: boolean): string;
  32940. /**
  32941. * Gets the first element of an array satisfying a given predicate
  32942. * @param array defines the array to browse
  32943. * @param predicate defines the predicate to use
  32944. * @returns null if not found or the element
  32945. */
  32946. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32947. /**
  32948. * This method will return the name of the full name of the class, including its owning module (if any).
  32949. * 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).
  32950. * @param object the object to get the class name from
  32951. * @param isType defines if the object is actually a type
  32952. * @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.
  32953. * @ignorenaming
  32954. */
  32955. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32956. /**
  32957. * Returns a promise that resolves after the given amount of time.
  32958. * @param delay Number of milliseconds to delay
  32959. * @returns Promise that resolves after the given amount of time
  32960. */
  32961. static DelayAsync(delay: number): Promise<void>;
  32962. }
  32963. /**
  32964. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32965. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32966. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32967. * @param name The name of the class, case should be preserved
  32968. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32969. */
  32970. export function className(name: string, module?: string): (target: Object) => void;
  32971. /**
  32972. * An implementation of a loop for asynchronous functions.
  32973. */
  32974. export class AsyncLoop {
  32975. /**
  32976. * Defines the number of iterations for the loop
  32977. */
  32978. iterations: number;
  32979. /**
  32980. * Defines the current index of the loop.
  32981. */
  32982. index: number;
  32983. private _done;
  32984. private _fn;
  32985. private _successCallback;
  32986. /**
  32987. * Constructor.
  32988. * @param iterations the number of iterations.
  32989. * @param func the function to run each iteration
  32990. * @param successCallback the callback that will be called upon succesful execution
  32991. * @param offset starting offset.
  32992. */
  32993. constructor(
  32994. /**
  32995. * Defines the number of iterations for the loop
  32996. */
  32997. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32998. /**
  32999. * Execute the next iteration. Must be called after the last iteration was finished.
  33000. */
  33001. executeNext(): void;
  33002. /**
  33003. * Break the loop and run the success callback.
  33004. */
  33005. breakLoop(): void;
  33006. /**
  33007. * Create and run an async loop.
  33008. * @param iterations the number of iterations.
  33009. * @param fn the function to run each iteration
  33010. * @param successCallback the callback that will be called upon succesful execution
  33011. * @param offset starting offset.
  33012. * @returns the created async loop object
  33013. */
  33014. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33015. /**
  33016. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33017. * @param iterations total number of iterations
  33018. * @param syncedIterations number of synchronous iterations in each async iteration.
  33019. * @param fn the function to call each iteration.
  33020. * @param callback a success call back that will be called when iterating stops.
  33021. * @param breakFunction a break condition (optional)
  33022. * @param timeout timeout settings for the setTimeout function. default - 0.
  33023. * @returns the created async loop object
  33024. */
  33025. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33026. }
  33027. }
  33028. declare module "babylonjs/Collisions/collisionCoordinator" {
  33029. import { Nullable } from "babylonjs/types";
  33030. import { Scene } from "babylonjs/scene";
  33031. import { Vector3 } from "babylonjs/Maths/math.vector";
  33032. import { Collider } from "babylonjs/Collisions/collider";
  33033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33034. /** @hidden */
  33035. export interface ICollisionCoordinator {
  33036. createCollider(): Collider;
  33037. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33038. init(scene: Scene): void;
  33039. }
  33040. /** @hidden */
  33041. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33042. private _scene;
  33043. private _scaledPosition;
  33044. private _scaledVelocity;
  33045. private _finalPosition;
  33046. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33047. createCollider(): Collider;
  33048. init(scene: Scene): void;
  33049. private _collideWithWorld;
  33050. }
  33051. }
  33052. declare module "babylonjs/Inputs/scene.inputManager" {
  33053. import { Nullable } from "babylonjs/types";
  33054. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33055. import { Vector2 } from "babylonjs/Maths/math.vector";
  33056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33057. import { Scene } from "babylonjs/scene";
  33058. /**
  33059. * Class used to manage all inputs for the scene.
  33060. */
  33061. export class InputManager {
  33062. /** The distance in pixel that you have to move to prevent some events */
  33063. static DragMovementThreshold: number;
  33064. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33065. static LongPressDelay: number;
  33066. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33067. static DoubleClickDelay: number;
  33068. /** If you need to check double click without raising a single click at first click, enable this flag */
  33069. static ExclusiveDoubleClickMode: boolean;
  33070. private _wheelEventName;
  33071. private _onPointerMove;
  33072. private _onPointerDown;
  33073. private _onPointerUp;
  33074. private _initClickEvent;
  33075. private _initActionManager;
  33076. private _delayedSimpleClick;
  33077. private _delayedSimpleClickTimeout;
  33078. private _previousDelayedSimpleClickTimeout;
  33079. private _meshPickProceed;
  33080. private _previousButtonPressed;
  33081. private _currentPickResult;
  33082. private _previousPickResult;
  33083. private _totalPointersPressed;
  33084. private _doubleClickOccured;
  33085. private _pointerOverMesh;
  33086. private _pickedDownMesh;
  33087. private _pickedUpMesh;
  33088. private _pointerX;
  33089. private _pointerY;
  33090. private _unTranslatedPointerX;
  33091. private _unTranslatedPointerY;
  33092. private _startingPointerPosition;
  33093. private _previousStartingPointerPosition;
  33094. private _startingPointerTime;
  33095. private _previousStartingPointerTime;
  33096. private _pointerCaptures;
  33097. private _onKeyDown;
  33098. private _onKeyUp;
  33099. private _onCanvasFocusObserver;
  33100. private _onCanvasBlurObserver;
  33101. private _scene;
  33102. /**
  33103. * Creates a new InputManager
  33104. * @param scene defines the hosting scene
  33105. */
  33106. constructor(scene: Scene);
  33107. /**
  33108. * Gets the mesh that is currently under the pointer
  33109. */
  33110. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33111. /**
  33112. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33113. */
  33114. readonly unTranslatedPointer: Vector2;
  33115. /**
  33116. * Gets or sets the current on-screen X position of the pointer
  33117. */
  33118. pointerX: number;
  33119. /**
  33120. * Gets or sets the current on-screen Y position of the pointer
  33121. */
  33122. pointerY: number;
  33123. private _updatePointerPosition;
  33124. private _processPointerMove;
  33125. private _setRayOnPointerInfo;
  33126. private _checkPrePointerObservable;
  33127. /**
  33128. * Use this method to simulate a pointer move on a mesh
  33129. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33130. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33131. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33132. */
  33133. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33134. /**
  33135. * Use this method to simulate a pointer down on a mesh
  33136. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33137. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33138. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33139. */
  33140. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33141. private _processPointerDown;
  33142. /** @hidden */
  33143. _isPointerSwiping(): boolean;
  33144. /**
  33145. * Use this method to simulate a pointer up on a mesh
  33146. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33147. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33148. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33149. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33150. */
  33151. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33152. private _processPointerUp;
  33153. /**
  33154. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33155. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33156. * @returns true if the pointer was captured
  33157. */
  33158. isPointerCaptured(pointerId?: number): boolean;
  33159. /**
  33160. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33161. * @param attachUp defines if you want to attach events to pointerup
  33162. * @param attachDown defines if you want to attach events to pointerdown
  33163. * @param attachMove defines if you want to attach events to pointermove
  33164. */
  33165. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33166. /**
  33167. * Detaches all event handlers
  33168. */
  33169. detachControl(): void;
  33170. /**
  33171. * Force the value of meshUnderPointer
  33172. * @param mesh defines the mesh to use
  33173. */
  33174. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33175. /**
  33176. * Gets the mesh under the pointer
  33177. * @returns a Mesh or null if no mesh is under the pointer
  33178. */
  33179. getPointerOverMesh(): Nullable<AbstractMesh>;
  33180. }
  33181. }
  33182. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33183. /**
  33184. * Helper class used to generate session unique ID
  33185. */
  33186. export class UniqueIdGenerator {
  33187. private static _UniqueIdCounter;
  33188. /**
  33189. * Gets an unique (relatively to the current scene) Id
  33190. */
  33191. static readonly UniqueId: number;
  33192. }
  33193. }
  33194. declare module "babylonjs/Animations/animationGroup" {
  33195. import { Animatable } from "babylonjs/Animations/animatable";
  33196. import { Animation } from "babylonjs/Animations/animation";
  33197. import { Scene, IDisposable } from "babylonjs/scene";
  33198. import { Observable } from "babylonjs/Misc/observable";
  33199. import { Nullable } from "babylonjs/types";
  33200. import "babylonjs/Animations/animatable";
  33201. /**
  33202. * This class defines the direct association between an animation and a target
  33203. */
  33204. export class TargetedAnimation {
  33205. /**
  33206. * Animation to perform
  33207. */
  33208. animation: Animation;
  33209. /**
  33210. * Target to animate
  33211. */
  33212. target: any;
  33213. /**
  33214. * Serialize the object
  33215. * @returns the JSON object representing the current entity
  33216. */
  33217. serialize(): any;
  33218. }
  33219. /**
  33220. * Use this class to create coordinated animations on multiple targets
  33221. */
  33222. export class AnimationGroup implements IDisposable {
  33223. /** The name of the animation group */
  33224. name: string;
  33225. private _scene;
  33226. private _targetedAnimations;
  33227. private _animatables;
  33228. private _from;
  33229. private _to;
  33230. private _isStarted;
  33231. private _isPaused;
  33232. private _speedRatio;
  33233. private _loopAnimation;
  33234. /**
  33235. * Gets or sets the unique id of the node
  33236. */
  33237. uniqueId: number;
  33238. /**
  33239. * This observable will notify when one animation have ended
  33240. */
  33241. onAnimationEndObservable: Observable<TargetedAnimation>;
  33242. /**
  33243. * Observer raised when one animation loops
  33244. */
  33245. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33246. /**
  33247. * This observable will notify when all animations have ended.
  33248. */
  33249. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33250. /**
  33251. * This observable will notify when all animations have paused.
  33252. */
  33253. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33254. /**
  33255. * This observable will notify when all animations are playing.
  33256. */
  33257. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33258. /**
  33259. * Gets the first frame
  33260. */
  33261. readonly from: number;
  33262. /**
  33263. * Gets the last frame
  33264. */
  33265. readonly to: number;
  33266. /**
  33267. * Define if the animations are started
  33268. */
  33269. readonly isStarted: boolean;
  33270. /**
  33271. * Gets a value indicating that the current group is playing
  33272. */
  33273. readonly isPlaying: boolean;
  33274. /**
  33275. * Gets or sets the speed ratio to use for all animations
  33276. */
  33277. /**
  33278. * Gets or sets the speed ratio to use for all animations
  33279. */
  33280. speedRatio: number;
  33281. /**
  33282. * Gets or sets if all animations should loop or not
  33283. */
  33284. loopAnimation: boolean;
  33285. /**
  33286. * Gets the targeted animations for this animation group
  33287. */
  33288. readonly targetedAnimations: Array<TargetedAnimation>;
  33289. /**
  33290. * returning the list of animatables controlled by this animation group.
  33291. */
  33292. readonly animatables: Array<Animatable>;
  33293. /**
  33294. * Instantiates a new Animation Group.
  33295. * This helps managing several animations at once.
  33296. * @see http://doc.babylonjs.com/how_to/group
  33297. * @param name Defines the name of the group
  33298. * @param scene Defines the scene the group belongs to
  33299. */
  33300. constructor(
  33301. /** The name of the animation group */
  33302. name: string, scene?: Nullable<Scene>);
  33303. /**
  33304. * Add an animation (with its target) in the group
  33305. * @param animation defines the animation we want to add
  33306. * @param target defines the target of the animation
  33307. * @returns the TargetedAnimation object
  33308. */
  33309. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33310. /**
  33311. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33312. * It can add constant keys at begin or end
  33313. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33314. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33315. * @returns the animation group
  33316. */
  33317. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33318. /**
  33319. * Start all animations on given targets
  33320. * @param loop defines if animations must loop
  33321. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33322. * @param from defines the from key (optional)
  33323. * @param to defines the to key (optional)
  33324. * @returns the current animation group
  33325. */
  33326. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33327. /**
  33328. * Pause all animations
  33329. * @returns the animation group
  33330. */
  33331. pause(): AnimationGroup;
  33332. /**
  33333. * Play all animations to initial state
  33334. * This function will start() the animations if they were not started or will restart() them if they were paused
  33335. * @param loop defines if animations must loop
  33336. * @returns the animation group
  33337. */
  33338. play(loop?: boolean): AnimationGroup;
  33339. /**
  33340. * Reset all animations to initial state
  33341. * @returns the animation group
  33342. */
  33343. reset(): AnimationGroup;
  33344. /**
  33345. * Restart animations from key 0
  33346. * @returns the animation group
  33347. */
  33348. restart(): AnimationGroup;
  33349. /**
  33350. * Stop all animations
  33351. * @returns the animation group
  33352. */
  33353. stop(): AnimationGroup;
  33354. /**
  33355. * Set animation weight for all animatables
  33356. * @param weight defines the weight to use
  33357. * @return the animationGroup
  33358. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33359. */
  33360. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33361. /**
  33362. * Synchronize and normalize all animatables with a source animatable
  33363. * @param root defines the root animatable to synchronize with
  33364. * @return the animationGroup
  33365. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33366. */
  33367. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33368. /**
  33369. * Goes to a specific frame in this animation group
  33370. * @param frame the frame number to go to
  33371. * @return the animationGroup
  33372. */
  33373. goToFrame(frame: number): AnimationGroup;
  33374. /**
  33375. * Dispose all associated resources
  33376. */
  33377. dispose(): void;
  33378. private _checkAnimationGroupEnded;
  33379. /**
  33380. * Clone the current animation group and returns a copy
  33381. * @param newName defines the name of the new group
  33382. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33383. * @returns the new aniamtion group
  33384. */
  33385. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33386. /**
  33387. * Serializes the animationGroup to an object
  33388. * @returns Serialized object
  33389. */
  33390. serialize(): any;
  33391. /**
  33392. * Returns a new AnimationGroup object parsed from the source provided.
  33393. * @param parsedAnimationGroup defines the source
  33394. * @param scene defines the scene that will receive the animationGroup
  33395. * @returns a new AnimationGroup
  33396. */
  33397. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33398. /**
  33399. * Returns the string "AnimationGroup"
  33400. * @returns "AnimationGroup"
  33401. */
  33402. getClassName(): string;
  33403. /**
  33404. * Creates a detailled string about the object
  33405. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33406. * @returns a string representing the object
  33407. */
  33408. toString(fullDetails?: boolean): string;
  33409. }
  33410. }
  33411. declare module "babylonjs/scene" {
  33412. import { Nullable } from "babylonjs/types";
  33413. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33414. import { Observable } from "babylonjs/Misc/observable";
  33415. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33416. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33417. import { Geometry } from "babylonjs/Meshes/geometry";
  33418. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33419. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33421. import { Mesh } from "babylonjs/Meshes/mesh";
  33422. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33423. import { Bone } from "babylonjs/Bones/bone";
  33424. import { Skeleton } from "babylonjs/Bones/skeleton";
  33425. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33426. import { Camera } from "babylonjs/Cameras/camera";
  33427. import { AbstractScene } from "babylonjs/abstractScene";
  33428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33429. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33430. import { Material } from "babylonjs/Materials/material";
  33431. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33432. import { Effect } from "babylonjs/Materials/effect";
  33433. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33434. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33435. import { Light } from "babylonjs/Lights/light";
  33436. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33437. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33438. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33439. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33441. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33442. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33443. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33444. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33445. import { Engine } from "babylonjs/Engines/engine";
  33446. import { Node } from "babylonjs/node";
  33447. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33448. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33449. import { WebRequest } from "babylonjs/Misc/webRequest";
  33450. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33451. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33452. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33453. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33454. import { Plane } from "babylonjs/Maths/math.plane";
  33455. import { Ray } from "babylonjs/Culling/ray";
  33456. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33457. import { Animation } from "babylonjs/Animations/animation";
  33458. import { Animatable } from "babylonjs/Animations/animatable";
  33459. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33460. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33461. import { Collider } from "babylonjs/Collisions/collider";
  33462. /**
  33463. * Define an interface for all classes that will hold resources
  33464. */
  33465. export interface IDisposable {
  33466. /**
  33467. * Releases all held resources
  33468. */
  33469. dispose(): void;
  33470. }
  33471. /** Interface defining initialization parameters for Scene class */
  33472. export interface SceneOptions {
  33473. /**
  33474. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33475. * It will improve performance when the number of geometries becomes important.
  33476. */
  33477. useGeometryUniqueIdsMap?: boolean;
  33478. /**
  33479. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33480. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33481. */
  33482. useMaterialMeshMap?: boolean;
  33483. /**
  33484. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33485. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33486. */
  33487. useClonedMeshhMap?: boolean;
  33488. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33489. virtual?: boolean;
  33490. }
  33491. /**
  33492. * Represents a scene to be rendered by the engine.
  33493. * @see http://doc.babylonjs.com/features/scene
  33494. */
  33495. export class Scene extends AbstractScene implements IAnimatable {
  33496. /** The fog is deactivated */
  33497. static readonly FOGMODE_NONE: number;
  33498. /** The fog density is following an exponential function */
  33499. static readonly FOGMODE_EXP: number;
  33500. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33501. static readonly FOGMODE_EXP2: number;
  33502. /** The fog density is following a linear function. */
  33503. static readonly FOGMODE_LINEAR: number;
  33504. /**
  33505. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33507. */
  33508. static MinDeltaTime: number;
  33509. /**
  33510. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33511. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33512. */
  33513. static MaxDeltaTime: number;
  33514. /**
  33515. * Factory used to create the default material.
  33516. * @param name The name of the material to create
  33517. * @param scene The scene to create the material for
  33518. * @returns The default material
  33519. */
  33520. static DefaultMaterialFactory(scene: Scene): Material;
  33521. /**
  33522. * Factory used to create the a collision coordinator.
  33523. * @returns The collision coordinator
  33524. */
  33525. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33526. /** @hidden */
  33527. _inputManager: InputManager;
  33528. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33529. cameraToUseForPointers: Nullable<Camera>;
  33530. /** @hidden */
  33531. readonly _isScene: boolean;
  33532. /**
  33533. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33534. */
  33535. autoClear: boolean;
  33536. /**
  33537. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33538. */
  33539. autoClearDepthAndStencil: boolean;
  33540. /**
  33541. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33542. */
  33543. clearColor: Color4;
  33544. /**
  33545. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33546. */
  33547. ambientColor: Color3;
  33548. /**
  33549. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33550. * It should only be one of the following (if not the default embedded one):
  33551. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33552. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33553. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33554. * The material properties need to be setup according to the type of texture in use.
  33555. */
  33556. environmentBRDFTexture: BaseTexture;
  33557. /** @hidden */
  33558. protected _environmentTexture: Nullable<BaseTexture>;
  33559. /**
  33560. * Texture used in all pbr material as the reflection texture.
  33561. * As in the majority of the scene they are the same (exception for multi room and so on),
  33562. * this is easier to reference from here than from all the materials.
  33563. */
  33564. /**
  33565. * Texture used in all pbr material as the reflection texture.
  33566. * As in the majority of the scene they are the same (exception for multi room and so on),
  33567. * this is easier to set here than in all the materials.
  33568. */
  33569. environmentTexture: Nullable<BaseTexture>;
  33570. /** @hidden */
  33571. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33572. /**
  33573. * Default image processing configuration used either in the rendering
  33574. * Forward main pass or through the imageProcessingPostProcess if present.
  33575. * As in the majority of the scene they are the same (exception for multi camera),
  33576. * this is easier to reference from here than from all the materials and post process.
  33577. *
  33578. * No setter as we it is a shared configuration, you can set the values instead.
  33579. */
  33580. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33581. private _forceWireframe;
  33582. /**
  33583. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33584. */
  33585. forceWireframe: boolean;
  33586. private _forcePointsCloud;
  33587. /**
  33588. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33589. */
  33590. forcePointsCloud: boolean;
  33591. /**
  33592. * Gets or sets the active clipplane 1
  33593. */
  33594. clipPlane: Nullable<Plane>;
  33595. /**
  33596. * Gets or sets the active clipplane 2
  33597. */
  33598. clipPlane2: Nullable<Plane>;
  33599. /**
  33600. * Gets or sets the active clipplane 3
  33601. */
  33602. clipPlane3: Nullable<Plane>;
  33603. /**
  33604. * Gets or sets the active clipplane 4
  33605. */
  33606. clipPlane4: Nullable<Plane>;
  33607. /**
  33608. * Gets or sets a boolean indicating if animations are enabled
  33609. */
  33610. animationsEnabled: boolean;
  33611. private _animationPropertiesOverride;
  33612. /**
  33613. * Gets or sets the animation properties override
  33614. */
  33615. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33616. /**
  33617. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33618. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33619. */
  33620. useConstantAnimationDeltaTime: boolean;
  33621. /**
  33622. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33623. * Please note that it requires to run a ray cast through the scene on every frame
  33624. */
  33625. constantlyUpdateMeshUnderPointer: boolean;
  33626. /**
  33627. * Defines the HTML cursor to use when hovering over interactive elements
  33628. */
  33629. hoverCursor: string;
  33630. /**
  33631. * Defines the HTML default cursor to use (empty by default)
  33632. */
  33633. defaultCursor: string;
  33634. /**
  33635. * This is used to call preventDefault() on pointer down
  33636. * in order to block unwanted artifacts like system double clicks
  33637. */
  33638. preventDefaultOnPointerDown: boolean;
  33639. /**
  33640. * This is used to call preventDefault() on pointer up
  33641. * in order to block unwanted artifacts like system double clicks
  33642. */
  33643. preventDefaultOnPointerUp: boolean;
  33644. /**
  33645. * Gets or sets user defined metadata
  33646. */
  33647. metadata: any;
  33648. /**
  33649. * For internal use only. Please do not use.
  33650. */
  33651. reservedDataStore: any;
  33652. /**
  33653. * Gets the name of the plugin used to load this scene (null by default)
  33654. */
  33655. loadingPluginName: string;
  33656. /**
  33657. * Use this array to add regular expressions used to disable offline support for specific urls
  33658. */
  33659. disableOfflineSupportExceptionRules: RegExp[];
  33660. /**
  33661. * An event triggered when the scene is disposed.
  33662. */
  33663. onDisposeObservable: Observable<Scene>;
  33664. private _onDisposeObserver;
  33665. /** Sets a function to be executed when this scene is disposed. */
  33666. onDispose: () => void;
  33667. /**
  33668. * An event triggered before rendering the scene (right after animations and physics)
  33669. */
  33670. onBeforeRenderObservable: Observable<Scene>;
  33671. private _onBeforeRenderObserver;
  33672. /** Sets a function to be executed before rendering this scene */
  33673. beforeRender: Nullable<() => void>;
  33674. /**
  33675. * An event triggered after rendering the scene
  33676. */
  33677. onAfterRenderObservable: Observable<Scene>;
  33678. /**
  33679. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33680. */
  33681. onAfterRenderCameraObservable: Observable<Camera>;
  33682. private _onAfterRenderObserver;
  33683. /** Sets a function to be executed after rendering this scene */
  33684. afterRender: Nullable<() => void>;
  33685. /**
  33686. * An event triggered before animating the scene
  33687. */
  33688. onBeforeAnimationsObservable: Observable<Scene>;
  33689. /**
  33690. * An event triggered after animations processing
  33691. */
  33692. onAfterAnimationsObservable: Observable<Scene>;
  33693. /**
  33694. * An event triggered before draw calls are ready to be sent
  33695. */
  33696. onBeforeDrawPhaseObservable: Observable<Scene>;
  33697. /**
  33698. * An event triggered after draw calls have been sent
  33699. */
  33700. onAfterDrawPhaseObservable: Observable<Scene>;
  33701. /**
  33702. * An event triggered when the scene is ready
  33703. */
  33704. onReadyObservable: Observable<Scene>;
  33705. /**
  33706. * An event triggered before rendering a camera
  33707. */
  33708. onBeforeCameraRenderObservable: Observable<Camera>;
  33709. private _onBeforeCameraRenderObserver;
  33710. /** Sets a function to be executed before rendering a camera*/
  33711. beforeCameraRender: () => void;
  33712. /**
  33713. * An event triggered after rendering a camera
  33714. */
  33715. onAfterCameraRenderObservable: Observable<Camera>;
  33716. private _onAfterCameraRenderObserver;
  33717. /** Sets a function to be executed after rendering a camera*/
  33718. afterCameraRender: () => void;
  33719. /**
  33720. * An event triggered when active meshes evaluation is about to start
  33721. */
  33722. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33723. /**
  33724. * An event triggered when active meshes evaluation is done
  33725. */
  33726. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33727. /**
  33728. * An event triggered when particles rendering is about to start
  33729. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33730. */
  33731. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33732. /**
  33733. * An event triggered when particles rendering is done
  33734. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33735. */
  33736. onAfterParticlesRenderingObservable: Observable<Scene>;
  33737. /**
  33738. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33739. */
  33740. onDataLoadedObservable: Observable<Scene>;
  33741. /**
  33742. * An event triggered when a camera is created
  33743. */
  33744. onNewCameraAddedObservable: Observable<Camera>;
  33745. /**
  33746. * An event triggered when a camera is removed
  33747. */
  33748. onCameraRemovedObservable: Observable<Camera>;
  33749. /**
  33750. * An event triggered when a light is created
  33751. */
  33752. onNewLightAddedObservable: Observable<Light>;
  33753. /**
  33754. * An event triggered when a light is removed
  33755. */
  33756. onLightRemovedObservable: Observable<Light>;
  33757. /**
  33758. * An event triggered when a geometry is created
  33759. */
  33760. onNewGeometryAddedObservable: Observable<Geometry>;
  33761. /**
  33762. * An event triggered when a geometry is removed
  33763. */
  33764. onGeometryRemovedObservable: Observable<Geometry>;
  33765. /**
  33766. * An event triggered when a transform node is created
  33767. */
  33768. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33769. /**
  33770. * An event triggered when a transform node is removed
  33771. */
  33772. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33773. /**
  33774. * An event triggered when a mesh is created
  33775. */
  33776. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33777. /**
  33778. * An event triggered when a mesh is removed
  33779. */
  33780. onMeshRemovedObservable: Observable<AbstractMesh>;
  33781. /**
  33782. * An event triggered when a skeleton is created
  33783. */
  33784. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33785. /**
  33786. * An event triggered when a skeleton is removed
  33787. */
  33788. onSkeletonRemovedObservable: Observable<Skeleton>;
  33789. /**
  33790. * An event triggered when a material is created
  33791. */
  33792. onNewMaterialAddedObservable: Observable<Material>;
  33793. /**
  33794. * An event triggered when a material is removed
  33795. */
  33796. onMaterialRemovedObservable: Observable<Material>;
  33797. /**
  33798. * An event triggered when a texture is created
  33799. */
  33800. onNewTextureAddedObservable: Observable<BaseTexture>;
  33801. /**
  33802. * An event triggered when a texture is removed
  33803. */
  33804. onTextureRemovedObservable: Observable<BaseTexture>;
  33805. /**
  33806. * An event triggered when render targets are about to be rendered
  33807. * Can happen multiple times per frame.
  33808. */
  33809. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33810. /**
  33811. * An event triggered when render targets were rendered.
  33812. * Can happen multiple times per frame.
  33813. */
  33814. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33815. /**
  33816. * An event triggered before calculating deterministic simulation step
  33817. */
  33818. onBeforeStepObservable: Observable<Scene>;
  33819. /**
  33820. * An event triggered after calculating deterministic simulation step
  33821. */
  33822. onAfterStepObservable: Observable<Scene>;
  33823. /**
  33824. * An event triggered when the activeCamera property is updated
  33825. */
  33826. onActiveCameraChanged: Observable<Scene>;
  33827. /**
  33828. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33829. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33830. * 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)
  33831. */
  33832. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33833. /**
  33834. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33835. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33836. * 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)
  33837. */
  33838. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33839. /**
  33840. * This Observable will when a mesh has been imported into the scene.
  33841. */
  33842. onMeshImportedObservable: Observable<AbstractMesh>;
  33843. /**
  33844. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33845. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33846. */
  33847. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33848. /** @hidden */
  33849. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33850. /**
  33851. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33852. */
  33853. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33854. /**
  33855. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33856. */
  33857. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33858. /**
  33859. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33860. */
  33861. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33862. /** Callback called when a pointer move is detected */
  33863. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33864. /** Callback called when a pointer down is detected */
  33865. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33866. /** Callback called when a pointer up is detected */
  33867. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33868. /** Callback called when a pointer pick is detected */
  33869. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33870. /**
  33871. * 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).
  33872. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33873. */
  33874. onPrePointerObservable: Observable<PointerInfoPre>;
  33875. /**
  33876. * Observable event triggered each time an input event is received from the rendering canvas
  33877. */
  33878. onPointerObservable: Observable<PointerInfo>;
  33879. /**
  33880. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33881. */
  33882. readonly unTranslatedPointer: Vector2;
  33883. /**
  33884. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33885. */
  33886. static DragMovementThreshold: number;
  33887. /**
  33888. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33889. */
  33890. static LongPressDelay: number;
  33891. /**
  33892. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33893. */
  33894. static DoubleClickDelay: number;
  33895. /** If you need to check double click without raising a single click at first click, enable this flag */
  33896. static ExclusiveDoubleClickMode: boolean;
  33897. /** @hidden */
  33898. _mirroredCameraPosition: Nullable<Vector3>;
  33899. /**
  33900. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33901. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33902. */
  33903. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33904. /**
  33905. * Observable event triggered each time an keyboard event is received from the hosting window
  33906. */
  33907. onKeyboardObservable: Observable<KeyboardInfo>;
  33908. private _useRightHandedSystem;
  33909. /**
  33910. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33911. */
  33912. useRightHandedSystem: boolean;
  33913. private _timeAccumulator;
  33914. private _currentStepId;
  33915. private _currentInternalStep;
  33916. /**
  33917. * Sets the step Id used by deterministic lock step
  33918. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33919. * @param newStepId defines the step Id
  33920. */
  33921. setStepId(newStepId: number): void;
  33922. /**
  33923. * Gets the step Id used by deterministic lock step
  33924. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33925. * @returns the step Id
  33926. */
  33927. getStepId(): number;
  33928. /**
  33929. * Gets the internal step used by deterministic lock step
  33930. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33931. * @returns the internal step
  33932. */
  33933. getInternalStep(): number;
  33934. private _fogEnabled;
  33935. /**
  33936. * Gets or sets a boolean indicating if fog is enabled on this scene
  33937. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33938. * (Default is true)
  33939. */
  33940. fogEnabled: boolean;
  33941. private _fogMode;
  33942. /**
  33943. * Gets or sets the fog mode to use
  33944. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33945. * | mode | value |
  33946. * | --- | --- |
  33947. * | FOGMODE_NONE | 0 |
  33948. * | FOGMODE_EXP | 1 |
  33949. * | FOGMODE_EXP2 | 2 |
  33950. * | FOGMODE_LINEAR | 3 |
  33951. */
  33952. fogMode: number;
  33953. /**
  33954. * Gets or sets the fog color to use
  33955. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33956. * (Default is Color3(0.2, 0.2, 0.3))
  33957. */
  33958. fogColor: Color3;
  33959. /**
  33960. * Gets or sets the fog density to use
  33961. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33962. * (Default is 0.1)
  33963. */
  33964. fogDensity: number;
  33965. /**
  33966. * Gets or sets the fog start distance to use
  33967. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33968. * (Default is 0)
  33969. */
  33970. fogStart: number;
  33971. /**
  33972. * Gets or sets the fog end distance to use
  33973. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33974. * (Default is 1000)
  33975. */
  33976. fogEnd: number;
  33977. private _shadowsEnabled;
  33978. /**
  33979. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33980. */
  33981. shadowsEnabled: boolean;
  33982. private _lightsEnabled;
  33983. /**
  33984. * Gets or sets a boolean indicating if lights are enabled on this scene
  33985. */
  33986. lightsEnabled: boolean;
  33987. /** All of the active cameras added to this scene. */
  33988. activeCameras: Camera[];
  33989. /** @hidden */
  33990. _activeCamera: Nullable<Camera>;
  33991. /** Gets or sets the current active camera */
  33992. activeCamera: Nullable<Camera>;
  33993. private _defaultMaterial;
  33994. /** The default material used on meshes when no material is affected */
  33995. /** The default material used on meshes when no material is affected */
  33996. defaultMaterial: Material;
  33997. private _texturesEnabled;
  33998. /**
  33999. * Gets or sets a boolean indicating if textures are enabled on this scene
  34000. */
  34001. texturesEnabled: boolean;
  34002. /**
  34003. * Gets or sets a boolean indicating if particles are enabled on this scene
  34004. */
  34005. particlesEnabled: boolean;
  34006. /**
  34007. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34008. */
  34009. spritesEnabled: boolean;
  34010. private _skeletonsEnabled;
  34011. /**
  34012. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34013. */
  34014. skeletonsEnabled: boolean;
  34015. /**
  34016. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34017. */
  34018. lensFlaresEnabled: boolean;
  34019. /**
  34020. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34021. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34022. */
  34023. collisionsEnabled: boolean;
  34024. private _collisionCoordinator;
  34025. /** @hidden */
  34026. readonly collisionCoordinator: ICollisionCoordinator;
  34027. /**
  34028. * Defines the gravity applied to this scene (used only for collisions)
  34029. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34030. */
  34031. gravity: Vector3;
  34032. /**
  34033. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34034. */
  34035. postProcessesEnabled: boolean;
  34036. /**
  34037. * The list of postprocesses added to the scene
  34038. */
  34039. postProcesses: PostProcess[];
  34040. /**
  34041. * Gets the current postprocess manager
  34042. */
  34043. postProcessManager: PostProcessManager;
  34044. /**
  34045. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34046. */
  34047. renderTargetsEnabled: boolean;
  34048. /**
  34049. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34050. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34051. */
  34052. dumpNextRenderTargets: boolean;
  34053. /**
  34054. * The list of user defined render targets added to the scene
  34055. */
  34056. customRenderTargets: RenderTargetTexture[];
  34057. /**
  34058. * Defines if texture loading must be delayed
  34059. * If true, textures will only be loaded when they need to be rendered
  34060. */
  34061. useDelayedTextureLoading: boolean;
  34062. /**
  34063. * Gets the list of meshes imported to the scene through SceneLoader
  34064. */
  34065. importedMeshesFiles: String[];
  34066. /**
  34067. * Gets or sets a boolean indicating if probes are enabled on this scene
  34068. */
  34069. probesEnabled: boolean;
  34070. /**
  34071. * Gets or sets the current offline provider to use to store scene data
  34072. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34073. */
  34074. offlineProvider: IOfflineProvider;
  34075. /**
  34076. * Gets or sets the action manager associated with the scene
  34077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34078. */
  34079. actionManager: AbstractActionManager;
  34080. private _meshesForIntersections;
  34081. /**
  34082. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34083. */
  34084. proceduralTexturesEnabled: boolean;
  34085. private _engine;
  34086. private _totalVertices;
  34087. /** @hidden */
  34088. _activeIndices: PerfCounter;
  34089. /** @hidden */
  34090. _activeParticles: PerfCounter;
  34091. /** @hidden */
  34092. _activeBones: PerfCounter;
  34093. private _animationRatio;
  34094. /** @hidden */
  34095. _animationTimeLast: number;
  34096. /** @hidden */
  34097. _animationTime: number;
  34098. /**
  34099. * Gets or sets a general scale for animation speed
  34100. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34101. */
  34102. animationTimeScale: number;
  34103. /** @hidden */
  34104. _cachedMaterial: Nullable<Material>;
  34105. /** @hidden */
  34106. _cachedEffect: Nullable<Effect>;
  34107. /** @hidden */
  34108. _cachedVisibility: Nullable<number>;
  34109. private _renderId;
  34110. private _frameId;
  34111. private _executeWhenReadyTimeoutId;
  34112. private _intermediateRendering;
  34113. private _viewUpdateFlag;
  34114. private _projectionUpdateFlag;
  34115. /** @hidden */
  34116. _toBeDisposed: Nullable<IDisposable>[];
  34117. private _activeRequests;
  34118. /** @hidden */
  34119. _pendingData: any[];
  34120. private _isDisposed;
  34121. /**
  34122. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34123. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34124. */
  34125. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34126. private _activeMeshes;
  34127. private _processedMaterials;
  34128. private _renderTargets;
  34129. /** @hidden */
  34130. _activeParticleSystems: SmartArray<IParticleSystem>;
  34131. private _activeSkeletons;
  34132. private _softwareSkinnedMeshes;
  34133. private _renderingManager;
  34134. /** @hidden */
  34135. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34136. private _transformMatrix;
  34137. private _sceneUbo;
  34138. /** @hidden */
  34139. _viewMatrix: Matrix;
  34140. private _projectionMatrix;
  34141. /** @hidden */
  34142. _forcedViewPosition: Nullable<Vector3>;
  34143. /** @hidden */
  34144. _frustumPlanes: Plane[];
  34145. /**
  34146. * Gets the list of frustum planes (built from the active camera)
  34147. */
  34148. readonly frustumPlanes: Plane[];
  34149. /**
  34150. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34151. * This is useful if there are more lights that the maximum simulteanous authorized
  34152. */
  34153. requireLightSorting: boolean;
  34154. /** @hidden */
  34155. readonly useMaterialMeshMap: boolean;
  34156. /** @hidden */
  34157. readonly useClonedMeshhMap: boolean;
  34158. private _externalData;
  34159. private _uid;
  34160. /**
  34161. * @hidden
  34162. * Backing store of defined scene components.
  34163. */
  34164. _components: ISceneComponent[];
  34165. /**
  34166. * @hidden
  34167. * Backing store of defined scene components.
  34168. */
  34169. _serializableComponents: ISceneSerializableComponent[];
  34170. /**
  34171. * List of components to register on the next registration step.
  34172. */
  34173. private _transientComponents;
  34174. /**
  34175. * Registers the transient components if needed.
  34176. */
  34177. private _registerTransientComponents;
  34178. /**
  34179. * @hidden
  34180. * Add a component to the scene.
  34181. * Note that the ccomponent could be registered on th next frame if this is called after
  34182. * the register component stage.
  34183. * @param component Defines the component to add to the scene
  34184. */
  34185. _addComponent(component: ISceneComponent): void;
  34186. /**
  34187. * @hidden
  34188. * Gets a component from the scene.
  34189. * @param name defines the name of the component to retrieve
  34190. * @returns the component or null if not present
  34191. */
  34192. _getComponent(name: string): Nullable<ISceneComponent>;
  34193. /**
  34194. * @hidden
  34195. * Defines the actions happening before camera updates.
  34196. */
  34197. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34198. /**
  34199. * @hidden
  34200. * Defines the actions happening before clear the canvas.
  34201. */
  34202. _beforeClearStage: Stage<SimpleStageAction>;
  34203. /**
  34204. * @hidden
  34205. * Defines the actions when collecting render targets for the frame.
  34206. */
  34207. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34208. /**
  34209. * @hidden
  34210. * Defines the actions happening for one camera in the frame.
  34211. */
  34212. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34213. /**
  34214. * @hidden
  34215. * Defines the actions happening during the per mesh ready checks.
  34216. */
  34217. _isReadyForMeshStage: Stage<MeshStageAction>;
  34218. /**
  34219. * @hidden
  34220. * Defines the actions happening before evaluate active mesh checks.
  34221. */
  34222. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34223. /**
  34224. * @hidden
  34225. * Defines the actions happening during the evaluate sub mesh checks.
  34226. */
  34227. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34228. /**
  34229. * @hidden
  34230. * Defines the actions happening during the active mesh stage.
  34231. */
  34232. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34233. /**
  34234. * @hidden
  34235. * Defines the actions happening during the per camera render target step.
  34236. */
  34237. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34238. /**
  34239. * @hidden
  34240. * Defines the actions happening just before the active camera is drawing.
  34241. */
  34242. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34243. /**
  34244. * @hidden
  34245. * Defines the actions happening just before a render target is drawing.
  34246. */
  34247. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34248. /**
  34249. * @hidden
  34250. * Defines the actions happening just before a rendering group is drawing.
  34251. */
  34252. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34253. /**
  34254. * @hidden
  34255. * Defines the actions happening just before a mesh is drawing.
  34256. */
  34257. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34258. /**
  34259. * @hidden
  34260. * Defines the actions happening just after a mesh has been drawn.
  34261. */
  34262. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34263. /**
  34264. * @hidden
  34265. * Defines the actions happening just after a rendering group has been drawn.
  34266. */
  34267. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34268. /**
  34269. * @hidden
  34270. * Defines the actions happening just after the active camera has been drawn.
  34271. */
  34272. _afterCameraDrawStage: Stage<CameraStageAction>;
  34273. /**
  34274. * @hidden
  34275. * Defines the actions happening just after a render target has been drawn.
  34276. */
  34277. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34278. /**
  34279. * @hidden
  34280. * Defines the actions happening just after rendering all cameras and computing intersections.
  34281. */
  34282. _afterRenderStage: Stage<SimpleStageAction>;
  34283. /**
  34284. * @hidden
  34285. * Defines the actions happening when a pointer move event happens.
  34286. */
  34287. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34288. /**
  34289. * @hidden
  34290. * Defines the actions happening when a pointer down event happens.
  34291. */
  34292. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34293. /**
  34294. * @hidden
  34295. * Defines the actions happening when a pointer up event happens.
  34296. */
  34297. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34298. /**
  34299. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34300. */
  34301. private geometriesByUniqueId;
  34302. /**
  34303. * Creates a new Scene
  34304. * @param engine defines the engine to use to render this scene
  34305. * @param options defines the scene options
  34306. */
  34307. constructor(engine: Engine, options?: SceneOptions);
  34308. /**
  34309. * Gets a string idenfifying the name of the class
  34310. * @returns "Scene" string
  34311. */
  34312. getClassName(): string;
  34313. private _defaultMeshCandidates;
  34314. /**
  34315. * @hidden
  34316. */
  34317. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34318. private _defaultSubMeshCandidates;
  34319. /**
  34320. * @hidden
  34321. */
  34322. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34323. /**
  34324. * Sets the default candidate providers for the scene.
  34325. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34326. * and getCollidingSubMeshCandidates to their default function
  34327. */
  34328. setDefaultCandidateProviders(): void;
  34329. /**
  34330. * Gets the mesh that is currently under the pointer
  34331. */
  34332. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34333. /**
  34334. * Gets or sets the current on-screen X position of the pointer
  34335. */
  34336. pointerX: number;
  34337. /**
  34338. * Gets or sets the current on-screen Y position of the pointer
  34339. */
  34340. pointerY: number;
  34341. /**
  34342. * Gets the cached material (ie. the latest rendered one)
  34343. * @returns the cached material
  34344. */
  34345. getCachedMaterial(): Nullable<Material>;
  34346. /**
  34347. * Gets the cached effect (ie. the latest rendered one)
  34348. * @returns the cached effect
  34349. */
  34350. getCachedEffect(): Nullable<Effect>;
  34351. /**
  34352. * Gets the cached visibility state (ie. the latest rendered one)
  34353. * @returns the cached visibility state
  34354. */
  34355. getCachedVisibility(): Nullable<number>;
  34356. /**
  34357. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34358. * @param material defines the current material
  34359. * @param effect defines the current effect
  34360. * @param visibility defines the current visibility state
  34361. * @returns true if one parameter is not cached
  34362. */
  34363. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34364. /**
  34365. * Gets the engine associated with the scene
  34366. * @returns an Engine
  34367. */
  34368. getEngine(): Engine;
  34369. /**
  34370. * Gets the total number of vertices rendered per frame
  34371. * @returns the total number of vertices rendered per frame
  34372. */
  34373. getTotalVertices(): number;
  34374. /**
  34375. * Gets the performance counter for total vertices
  34376. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34377. */
  34378. readonly totalVerticesPerfCounter: PerfCounter;
  34379. /**
  34380. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34381. * @returns the total number of active indices rendered per frame
  34382. */
  34383. getActiveIndices(): number;
  34384. /**
  34385. * Gets the performance counter for active indices
  34386. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34387. */
  34388. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34389. /**
  34390. * Gets the total number of active particles rendered per frame
  34391. * @returns the total number of active particles rendered per frame
  34392. */
  34393. getActiveParticles(): number;
  34394. /**
  34395. * Gets the performance counter for active particles
  34396. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34397. */
  34398. readonly activeParticlesPerfCounter: PerfCounter;
  34399. /**
  34400. * Gets the total number of active bones rendered per frame
  34401. * @returns the total number of active bones rendered per frame
  34402. */
  34403. getActiveBones(): number;
  34404. /**
  34405. * Gets the performance counter for active bones
  34406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34407. */
  34408. readonly activeBonesPerfCounter: PerfCounter;
  34409. /**
  34410. * Gets the array of active meshes
  34411. * @returns an array of AbstractMesh
  34412. */
  34413. getActiveMeshes(): SmartArray<AbstractMesh>;
  34414. /**
  34415. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34416. * @returns a number
  34417. */
  34418. getAnimationRatio(): number;
  34419. /**
  34420. * Gets an unique Id for the current render phase
  34421. * @returns a number
  34422. */
  34423. getRenderId(): number;
  34424. /**
  34425. * Gets an unique Id for the current frame
  34426. * @returns a number
  34427. */
  34428. getFrameId(): number;
  34429. /** Call this function if you want to manually increment the render Id*/
  34430. incrementRenderId(): void;
  34431. private _createUbo;
  34432. /**
  34433. * Use this method to simulate a pointer move on a mesh
  34434. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34435. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34436. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34437. * @returns the current scene
  34438. */
  34439. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34440. /**
  34441. * Use this method to simulate a pointer down on a mesh
  34442. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34443. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34444. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34445. * @returns the current scene
  34446. */
  34447. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34448. /**
  34449. * Use this method to simulate a pointer up on a mesh
  34450. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34451. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34452. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34453. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34454. * @returns the current scene
  34455. */
  34456. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34457. /**
  34458. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34459. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34460. * @returns true if the pointer was captured
  34461. */
  34462. isPointerCaptured(pointerId?: number): boolean;
  34463. /**
  34464. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34465. * @param attachUp defines if you want to attach events to pointerup
  34466. * @param attachDown defines if you want to attach events to pointerdown
  34467. * @param attachMove defines if you want to attach events to pointermove
  34468. */
  34469. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34470. /** Detaches all event handlers*/
  34471. detachControl(): void;
  34472. /**
  34473. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34474. * Delay loaded resources are not taking in account
  34475. * @return true if all required resources are ready
  34476. */
  34477. isReady(): boolean;
  34478. /** Resets all cached information relative to material (including effect and visibility) */
  34479. resetCachedMaterial(): void;
  34480. /**
  34481. * Registers a function to be called before every frame render
  34482. * @param func defines the function to register
  34483. */
  34484. registerBeforeRender(func: () => void): void;
  34485. /**
  34486. * Unregisters a function called before every frame render
  34487. * @param func defines the function to unregister
  34488. */
  34489. unregisterBeforeRender(func: () => void): void;
  34490. /**
  34491. * Registers a function to be called after every frame render
  34492. * @param func defines the function to register
  34493. */
  34494. registerAfterRender(func: () => void): void;
  34495. /**
  34496. * Unregisters a function called after every frame render
  34497. * @param func defines the function to unregister
  34498. */
  34499. unregisterAfterRender(func: () => void): void;
  34500. private _executeOnceBeforeRender;
  34501. /**
  34502. * The provided function will run before render once and will be disposed afterwards.
  34503. * A timeout delay can be provided so that the function will be executed in N ms.
  34504. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34505. * @param func The function to be executed.
  34506. * @param timeout optional delay in ms
  34507. */
  34508. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34509. /** @hidden */
  34510. _addPendingData(data: any): void;
  34511. /** @hidden */
  34512. _removePendingData(data: any): void;
  34513. /**
  34514. * Returns the number of items waiting to be loaded
  34515. * @returns the number of items waiting to be loaded
  34516. */
  34517. getWaitingItemsCount(): number;
  34518. /**
  34519. * Returns a boolean indicating if the scene is still loading data
  34520. */
  34521. readonly isLoading: boolean;
  34522. /**
  34523. * Registers a function to be executed when the scene is ready
  34524. * @param {Function} func - the function to be executed
  34525. */
  34526. executeWhenReady(func: () => void): void;
  34527. /**
  34528. * Returns a promise that resolves when the scene is ready
  34529. * @returns A promise that resolves when the scene is ready
  34530. */
  34531. whenReadyAsync(): Promise<void>;
  34532. /** @hidden */
  34533. _checkIsReady(): void;
  34534. /**
  34535. * Gets all animatable attached to the scene
  34536. */
  34537. readonly animatables: Animatable[];
  34538. /**
  34539. * Resets the last animation time frame.
  34540. * Useful to override when animations start running when loading a scene for the first time.
  34541. */
  34542. resetLastAnimationTimeFrame(): void;
  34543. /**
  34544. * Gets the current view matrix
  34545. * @returns a Matrix
  34546. */
  34547. getViewMatrix(): Matrix;
  34548. /**
  34549. * Gets the current projection matrix
  34550. * @returns a Matrix
  34551. */
  34552. getProjectionMatrix(): Matrix;
  34553. /**
  34554. * Gets the current transform matrix
  34555. * @returns a Matrix made of View * Projection
  34556. */
  34557. getTransformMatrix(): Matrix;
  34558. /**
  34559. * Sets the current transform matrix
  34560. * @param viewL defines the View matrix to use
  34561. * @param projectionL defines the Projection matrix to use
  34562. * @param viewR defines the right View matrix to use (if provided)
  34563. * @param projectionR defines the right Projection matrix to use (if provided)
  34564. */
  34565. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34566. /**
  34567. * Gets the uniform buffer used to store scene data
  34568. * @returns a UniformBuffer
  34569. */
  34570. getSceneUniformBuffer(): UniformBuffer;
  34571. /**
  34572. * Gets an unique (relatively to the current scene) Id
  34573. * @returns an unique number for the scene
  34574. */
  34575. getUniqueId(): number;
  34576. /**
  34577. * Add a mesh to the list of scene's meshes
  34578. * @param newMesh defines the mesh to add
  34579. * @param recursive if all child meshes should also be added to the scene
  34580. */
  34581. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34582. /**
  34583. * Remove a mesh for the list of scene's meshes
  34584. * @param toRemove defines the mesh to remove
  34585. * @param recursive if all child meshes should also be removed from the scene
  34586. * @returns the index where the mesh was in the mesh list
  34587. */
  34588. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34589. /**
  34590. * Add a transform node to the list of scene's transform nodes
  34591. * @param newTransformNode defines the transform node to add
  34592. */
  34593. addTransformNode(newTransformNode: TransformNode): void;
  34594. /**
  34595. * Remove a transform node for the list of scene's transform nodes
  34596. * @param toRemove defines the transform node to remove
  34597. * @returns the index where the transform node was in the transform node list
  34598. */
  34599. removeTransformNode(toRemove: TransformNode): number;
  34600. /**
  34601. * Remove a skeleton for the list of scene's skeletons
  34602. * @param toRemove defines the skeleton to remove
  34603. * @returns the index where the skeleton was in the skeleton list
  34604. */
  34605. removeSkeleton(toRemove: Skeleton): number;
  34606. /**
  34607. * Remove a morph target for the list of scene's morph targets
  34608. * @param toRemove defines the morph target to remove
  34609. * @returns the index where the morph target was in the morph target list
  34610. */
  34611. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34612. /**
  34613. * Remove a light for the list of scene's lights
  34614. * @param toRemove defines the light to remove
  34615. * @returns the index where the light was in the light list
  34616. */
  34617. removeLight(toRemove: Light): number;
  34618. /**
  34619. * Remove a camera for the list of scene's cameras
  34620. * @param toRemove defines the camera to remove
  34621. * @returns the index where the camera was in the camera list
  34622. */
  34623. removeCamera(toRemove: Camera): number;
  34624. /**
  34625. * Remove a particle system for the list of scene's particle systems
  34626. * @param toRemove defines the particle system to remove
  34627. * @returns the index where the particle system was in the particle system list
  34628. */
  34629. removeParticleSystem(toRemove: IParticleSystem): number;
  34630. /**
  34631. * Remove a animation for the list of scene's animations
  34632. * @param toRemove defines the animation to remove
  34633. * @returns the index where the animation was in the animation list
  34634. */
  34635. removeAnimation(toRemove: Animation): number;
  34636. /**
  34637. * Will stop the animation of the given target
  34638. * @param target - the target
  34639. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34640. * @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)
  34641. */
  34642. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34643. /**
  34644. * Removes the given animation group from this scene.
  34645. * @param toRemove The animation group to remove
  34646. * @returns The index of the removed animation group
  34647. */
  34648. removeAnimationGroup(toRemove: AnimationGroup): number;
  34649. /**
  34650. * Removes the given multi-material from this scene.
  34651. * @param toRemove The multi-material to remove
  34652. * @returns The index of the removed multi-material
  34653. */
  34654. removeMultiMaterial(toRemove: MultiMaterial): number;
  34655. /**
  34656. * Removes the given material from this scene.
  34657. * @param toRemove The material to remove
  34658. * @returns The index of the removed material
  34659. */
  34660. removeMaterial(toRemove: Material): number;
  34661. /**
  34662. * Removes the given action manager from this scene.
  34663. * @param toRemove The action manager to remove
  34664. * @returns The index of the removed action manager
  34665. */
  34666. removeActionManager(toRemove: AbstractActionManager): number;
  34667. /**
  34668. * Removes the given texture from this scene.
  34669. * @param toRemove The texture to remove
  34670. * @returns The index of the removed texture
  34671. */
  34672. removeTexture(toRemove: BaseTexture): number;
  34673. /**
  34674. * Adds the given light to this scene
  34675. * @param newLight The light to add
  34676. */
  34677. addLight(newLight: Light): void;
  34678. /**
  34679. * Sorts the list list based on light priorities
  34680. */
  34681. sortLightsByPriority(): void;
  34682. /**
  34683. * Adds the given camera to this scene
  34684. * @param newCamera The camera to add
  34685. */
  34686. addCamera(newCamera: Camera): void;
  34687. /**
  34688. * Adds the given skeleton to this scene
  34689. * @param newSkeleton The skeleton to add
  34690. */
  34691. addSkeleton(newSkeleton: Skeleton): void;
  34692. /**
  34693. * Adds the given particle system to this scene
  34694. * @param newParticleSystem The particle system to add
  34695. */
  34696. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34697. /**
  34698. * Adds the given animation to this scene
  34699. * @param newAnimation The animation to add
  34700. */
  34701. addAnimation(newAnimation: Animation): void;
  34702. /**
  34703. * Adds the given animation group to this scene.
  34704. * @param newAnimationGroup The animation group to add
  34705. */
  34706. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34707. /**
  34708. * Adds the given multi-material to this scene
  34709. * @param newMultiMaterial The multi-material to add
  34710. */
  34711. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34712. /**
  34713. * Adds the given material to this scene
  34714. * @param newMaterial The material to add
  34715. */
  34716. addMaterial(newMaterial: Material): void;
  34717. /**
  34718. * Adds the given morph target to this scene
  34719. * @param newMorphTargetManager The morph target to add
  34720. */
  34721. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34722. /**
  34723. * Adds the given geometry to this scene
  34724. * @param newGeometry The geometry to add
  34725. */
  34726. addGeometry(newGeometry: Geometry): void;
  34727. /**
  34728. * Adds the given action manager to this scene
  34729. * @param newActionManager The action manager to add
  34730. */
  34731. addActionManager(newActionManager: AbstractActionManager): void;
  34732. /**
  34733. * Adds the given texture to this scene.
  34734. * @param newTexture The texture to add
  34735. */
  34736. addTexture(newTexture: BaseTexture): void;
  34737. /**
  34738. * Switch active camera
  34739. * @param newCamera defines the new active camera
  34740. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34741. */
  34742. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34743. /**
  34744. * sets the active camera of the scene using its ID
  34745. * @param id defines the camera's ID
  34746. * @return the new active camera or null if none found.
  34747. */
  34748. setActiveCameraByID(id: string): Nullable<Camera>;
  34749. /**
  34750. * sets the active camera of the scene using its name
  34751. * @param name defines the camera's name
  34752. * @returns the new active camera or null if none found.
  34753. */
  34754. setActiveCameraByName(name: string): Nullable<Camera>;
  34755. /**
  34756. * get an animation group using its name
  34757. * @param name defines the material's name
  34758. * @return the animation group or null if none found.
  34759. */
  34760. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34761. /**
  34762. * Get a material using its unique id
  34763. * @param uniqueId defines the material's unique id
  34764. * @return the material or null if none found.
  34765. */
  34766. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34767. /**
  34768. * get a material using its id
  34769. * @param id defines the material's ID
  34770. * @return the material or null if none found.
  34771. */
  34772. getMaterialByID(id: string): Nullable<Material>;
  34773. /**
  34774. * Gets a the last added material using a given id
  34775. * @param id defines the material's ID
  34776. * @return the last material with the given id or null if none found.
  34777. */
  34778. getLastMaterialByID(id: string): Nullable<Material>;
  34779. /**
  34780. * Gets a material using its name
  34781. * @param name defines the material's name
  34782. * @return the material or null if none found.
  34783. */
  34784. getMaterialByName(name: string): Nullable<Material>;
  34785. /**
  34786. * Gets a camera using its id
  34787. * @param id defines the id to look for
  34788. * @returns the camera or null if not found
  34789. */
  34790. getCameraByID(id: string): Nullable<Camera>;
  34791. /**
  34792. * Gets a camera using its unique id
  34793. * @param uniqueId defines the unique id to look for
  34794. * @returns the camera or null if not found
  34795. */
  34796. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34797. /**
  34798. * Gets a camera using its name
  34799. * @param name defines the camera's name
  34800. * @return the camera or null if none found.
  34801. */
  34802. getCameraByName(name: string): Nullable<Camera>;
  34803. /**
  34804. * Gets a bone using its id
  34805. * @param id defines the bone's id
  34806. * @return the bone or null if not found
  34807. */
  34808. getBoneByID(id: string): Nullable<Bone>;
  34809. /**
  34810. * Gets a bone using its id
  34811. * @param name defines the bone's name
  34812. * @return the bone or null if not found
  34813. */
  34814. getBoneByName(name: string): Nullable<Bone>;
  34815. /**
  34816. * Gets a light node using its name
  34817. * @param name defines the the light's name
  34818. * @return the light or null if none found.
  34819. */
  34820. getLightByName(name: string): Nullable<Light>;
  34821. /**
  34822. * Gets a light node using its id
  34823. * @param id defines the light's id
  34824. * @return the light or null if none found.
  34825. */
  34826. getLightByID(id: string): Nullable<Light>;
  34827. /**
  34828. * Gets a light node using its scene-generated unique ID
  34829. * @param uniqueId defines the light's unique id
  34830. * @return the light or null if none found.
  34831. */
  34832. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34833. /**
  34834. * Gets a particle system by id
  34835. * @param id defines the particle system id
  34836. * @return the corresponding system or null if none found
  34837. */
  34838. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34839. /**
  34840. * Gets a geometry using its ID
  34841. * @param id defines the geometry's id
  34842. * @return the geometry or null if none found.
  34843. */
  34844. getGeometryByID(id: string): Nullable<Geometry>;
  34845. private _getGeometryByUniqueID;
  34846. /**
  34847. * Add a new geometry to this scene
  34848. * @param geometry defines the geometry to be added to the scene.
  34849. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34850. * @return a boolean defining if the geometry was added or not
  34851. */
  34852. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34853. /**
  34854. * Removes an existing geometry
  34855. * @param geometry defines the geometry to be removed from the scene
  34856. * @return a boolean defining if the geometry was removed or not
  34857. */
  34858. removeGeometry(geometry: Geometry): boolean;
  34859. /**
  34860. * Gets the list of geometries attached to the scene
  34861. * @returns an array of Geometry
  34862. */
  34863. getGeometries(): Geometry[];
  34864. /**
  34865. * Gets the first added mesh found of a given ID
  34866. * @param id defines the id to search for
  34867. * @return the mesh found or null if not found at all
  34868. */
  34869. getMeshByID(id: string): Nullable<AbstractMesh>;
  34870. /**
  34871. * Gets a list of meshes using their id
  34872. * @param id defines the id to search for
  34873. * @returns a list of meshes
  34874. */
  34875. getMeshesByID(id: string): Array<AbstractMesh>;
  34876. /**
  34877. * Gets the first added transform node found of a given ID
  34878. * @param id defines the id to search for
  34879. * @return the found transform node or null if not found at all.
  34880. */
  34881. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34882. /**
  34883. * Gets a transform node with its auto-generated unique id
  34884. * @param uniqueId efines the unique id to search for
  34885. * @return the found transform node or null if not found at all.
  34886. */
  34887. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34888. /**
  34889. * Gets a list of transform nodes using their id
  34890. * @param id defines the id to search for
  34891. * @returns a list of transform nodes
  34892. */
  34893. getTransformNodesByID(id: string): Array<TransformNode>;
  34894. /**
  34895. * Gets a mesh with its auto-generated unique id
  34896. * @param uniqueId defines the unique id to search for
  34897. * @return the found mesh or null if not found at all.
  34898. */
  34899. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34900. /**
  34901. * Gets a the last added mesh using a given id
  34902. * @param id defines the id to search for
  34903. * @return the found mesh or null if not found at all.
  34904. */
  34905. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34906. /**
  34907. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34908. * @param id defines the id to search for
  34909. * @return the found node or null if not found at all
  34910. */
  34911. getLastEntryByID(id: string): Nullable<Node>;
  34912. /**
  34913. * Gets a node (Mesh, Camera, Light) using a given id
  34914. * @param id defines the id to search for
  34915. * @return the found node or null if not found at all
  34916. */
  34917. getNodeByID(id: string): Nullable<Node>;
  34918. /**
  34919. * Gets a node (Mesh, Camera, Light) using a given name
  34920. * @param name defines the name to search for
  34921. * @return the found node or null if not found at all.
  34922. */
  34923. getNodeByName(name: string): Nullable<Node>;
  34924. /**
  34925. * Gets a mesh using a given name
  34926. * @param name defines the name to search for
  34927. * @return the found mesh or null if not found at all.
  34928. */
  34929. getMeshByName(name: string): Nullable<AbstractMesh>;
  34930. /**
  34931. * Gets a transform node using a given name
  34932. * @param name defines the name to search for
  34933. * @return the found transform node or null if not found at all.
  34934. */
  34935. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34936. /**
  34937. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34938. * @param id defines the id to search for
  34939. * @return the found skeleton or null if not found at all.
  34940. */
  34941. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34942. /**
  34943. * Gets a skeleton using a given auto generated unique id
  34944. * @param uniqueId defines the unique id to search for
  34945. * @return the found skeleton or null if not found at all.
  34946. */
  34947. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34948. /**
  34949. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34950. * @param id defines the id to search for
  34951. * @return the found skeleton or null if not found at all.
  34952. */
  34953. getSkeletonById(id: string): Nullable<Skeleton>;
  34954. /**
  34955. * Gets a skeleton using a given name
  34956. * @param name defines the name to search for
  34957. * @return the found skeleton or null if not found at all.
  34958. */
  34959. getSkeletonByName(name: string): Nullable<Skeleton>;
  34960. /**
  34961. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34962. * @param id defines the id to search for
  34963. * @return the found morph target manager or null if not found at all.
  34964. */
  34965. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34966. /**
  34967. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34968. * @param id defines the id to search for
  34969. * @return the found morph target or null if not found at all.
  34970. */
  34971. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34972. /**
  34973. * Gets a boolean indicating if the given mesh is active
  34974. * @param mesh defines the mesh to look for
  34975. * @returns true if the mesh is in the active list
  34976. */
  34977. isActiveMesh(mesh: AbstractMesh): boolean;
  34978. /**
  34979. * Return a unique id as a string which can serve as an identifier for the scene
  34980. */
  34981. readonly uid: string;
  34982. /**
  34983. * Add an externaly attached data from its key.
  34984. * This method call will fail and return false, if such key already exists.
  34985. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34986. * @param key the unique key that identifies the data
  34987. * @param data the data object to associate to the key for this Engine instance
  34988. * @return true if no such key were already present and the data was added successfully, false otherwise
  34989. */
  34990. addExternalData<T>(key: string, data: T): boolean;
  34991. /**
  34992. * Get an externaly attached data from its key
  34993. * @param key the unique key that identifies the data
  34994. * @return the associated data, if present (can be null), or undefined if not present
  34995. */
  34996. getExternalData<T>(key: string): Nullable<T>;
  34997. /**
  34998. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34999. * @param key the unique key that identifies the data
  35000. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35001. * @return the associated data, can be null if the factory returned null.
  35002. */
  35003. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35004. /**
  35005. * Remove an externaly attached data from the Engine instance
  35006. * @param key the unique key that identifies the data
  35007. * @return true if the data was successfully removed, false if it doesn't exist
  35008. */
  35009. removeExternalData(key: string): boolean;
  35010. private _evaluateSubMesh;
  35011. /**
  35012. * Clear the processed materials smart array preventing retention point in material dispose.
  35013. */
  35014. freeProcessedMaterials(): void;
  35015. private _preventFreeActiveMeshesAndRenderingGroups;
  35016. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35017. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35018. * when disposing several meshes in a row or a hierarchy of meshes.
  35019. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35020. */
  35021. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35022. /**
  35023. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35024. */
  35025. freeActiveMeshes(): void;
  35026. /**
  35027. * Clear the info related to rendering groups preventing retention points during dispose.
  35028. */
  35029. freeRenderingGroups(): void;
  35030. /** @hidden */
  35031. _isInIntermediateRendering(): boolean;
  35032. /**
  35033. * Lambda returning the list of potentially active meshes.
  35034. */
  35035. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35036. /**
  35037. * Lambda returning the list of potentially active sub meshes.
  35038. */
  35039. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35040. /**
  35041. * Lambda returning the list of potentially intersecting sub meshes.
  35042. */
  35043. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35044. /**
  35045. * Lambda returning the list of potentially colliding sub meshes.
  35046. */
  35047. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35048. private _activeMeshesFrozen;
  35049. /**
  35050. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35051. * @returns the current scene
  35052. */
  35053. freezeActiveMeshes(): Scene;
  35054. /**
  35055. * Use this function to restart evaluating active meshes on every frame
  35056. * @returns the current scene
  35057. */
  35058. unfreezeActiveMeshes(): Scene;
  35059. private _evaluateActiveMeshes;
  35060. private _activeMesh;
  35061. /**
  35062. * Update the transform matrix to update from the current active camera
  35063. * @param force defines a boolean used to force the update even if cache is up to date
  35064. */
  35065. updateTransformMatrix(force?: boolean): void;
  35066. private _bindFrameBuffer;
  35067. /** @hidden */
  35068. _allowPostProcessClearColor: boolean;
  35069. /** @hidden */
  35070. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35071. private _processSubCameras;
  35072. private _checkIntersections;
  35073. /** @hidden */
  35074. _advancePhysicsEngineStep(step: number): void;
  35075. /**
  35076. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35077. */
  35078. getDeterministicFrameTime: () => number;
  35079. /** @hidden */
  35080. _animate(): void;
  35081. /** Execute all animations (for a frame) */
  35082. animate(): void;
  35083. /**
  35084. * Render the scene
  35085. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35086. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35087. */
  35088. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35089. /**
  35090. * Freeze all materials
  35091. * A frozen material will not be updatable but should be faster to render
  35092. */
  35093. freezeMaterials(): void;
  35094. /**
  35095. * Unfreeze all materials
  35096. * A frozen material will not be updatable but should be faster to render
  35097. */
  35098. unfreezeMaterials(): void;
  35099. /**
  35100. * Releases all held ressources
  35101. */
  35102. dispose(): void;
  35103. /**
  35104. * Gets if the scene is already disposed
  35105. */
  35106. readonly isDisposed: boolean;
  35107. /**
  35108. * Call this function to reduce memory footprint of the scene.
  35109. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35110. */
  35111. clearCachedVertexData(): void;
  35112. /**
  35113. * This function will remove the local cached buffer data from texture.
  35114. * It will save memory but will prevent the texture from being rebuilt
  35115. */
  35116. cleanCachedTextureBuffer(): void;
  35117. /**
  35118. * Get the world extend vectors with an optional filter
  35119. *
  35120. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35121. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35122. */
  35123. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35124. min: Vector3;
  35125. max: Vector3;
  35126. };
  35127. /**
  35128. * Creates a ray that can be used to pick in the scene
  35129. * @param x defines the x coordinate of the origin (on-screen)
  35130. * @param y defines the y coordinate of the origin (on-screen)
  35131. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35132. * @param camera defines the camera to use for the picking
  35133. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35134. * @returns a Ray
  35135. */
  35136. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35137. /**
  35138. * Creates a ray that can be used to pick in the scene
  35139. * @param x defines the x coordinate of the origin (on-screen)
  35140. * @param y defines the y coordinate of the origin (on-screen)
  35141. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35142. * @param result defines the ray where to store the picking ray
  35143. * @param camera defines the camera to use for the picking
  35144. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35145. * @returns the current scene
  35146. */
  35147. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35148. /**
  35149. * Creates a ray that can be used to pick in the scene
  35150. * @param x defines the x coordinate of the origin (on-screen)
  35151. * @param y defines the y coordinate of the origin (on-screen)
  35152. * @param camera defines the camera to use for the picking
  35153. * @returns a Ray
  35154. */
  35155. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35156. /**
  35157. * Creates a ray that can be used to pick in the scene
  35158. * @param x defines the x coordinate of the origin (on-screen)
  35159. * @param y defines the y coordinate of the origin (on-screen)
  35160. * @param result defines the ray where to store the picking ray
  35161. * @param camera defines the camera to use for the picking
  35162. * @returns the current scene
  35163. */
  35164. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35165. /** Launch a ray to try to pick a mesh in the scene
  35166. * @param x position on screen
  35167. * @param y position on screen
  35168. * @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
  35169. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35170. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35171. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35172. * @returns a PickingInfo
  35173. */
  35174. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35175. /** Use the given ray to pick a mesh in the scene
  35176. * @param ray The ray to use to pick meshes
  35177. * @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
  35178. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35179. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35180. * @returns a PickingInfo
  35181. */
  35182. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35183. /**
  35184. * Launch a ray to try to pick a mesh in the scene
  35185. * @param x X position on screen
  35186. * @param y Y position on screen
  35187. * @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
  35188. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35189. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35190. * @returns an array of PickingInfo
  35191. */
  35192. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35193. /**
  35194. * Launch a ray to try to pick a mesh in the scene
  35195. * @param ray Ray to use
  35196. * @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
  35197. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35198. * @returns an array of PickingInfo
  35199. */
  35200. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35201. /**
  35202. * Force the value of meshUnderPointer
  35203. * @param mesh defines the mesh to use
  35204. */
  35205. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35206. /**
  35207. * Gets the mesh under the pointer
  35208. * @returns a Mesh or null if no mesh is under the pointer
  35209. */
  35210. getPointerOverMesh(): Nullable<AbstractMesh>;
  35211. /** @hidden */
  35212. _rebuildGeometries(): void;
  35213. /** @hidden */
  35214. _rebuildTextures(): void;
  35215. private _getByTags;
  35216. /**
  35217. * Get a list of meshes by tags
  35218. * @param tagsQuery defines the tags query to use
  35219. * @param forEach defines a predicate used to filter results
  35220. * @returns an array of Mesh
  35221. */
  35222. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35223. /**
  35224. * Get a list of cameras by tags
  35225. * @param tagsQuery defines the tags query to use
  35226. * @param forEach defines a predicate used to filter results
  35227. * @returns an array of Camera
  35228. */
  35229. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35230. /**
  35231. * Get a list of lights by tags
  35232. * @param tagsQuery defines the tags query to use
  35233. * @param forEach defines a predicate used to filter results
  35234. * @returns an array of Light
  35235. */
  35236. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35237. /**
  35238. * Get a list of materials by tags
  35239. * @param tagsQuery defines the tags query to use
  35240. * @param forEach defines a predicate used to filter results
  35241. * @returns an array of Material
  35242. */
  35243. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35244. /**
  35245. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35246. * This allowed control for front to back rendering or reversly depending of the special needs.
  35247. *
  35248. * @param renderingGroupId The rendering group id corresponding to its index
  35249. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35250. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35251. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35252. */
  35253. 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;
  35254. /**
  35255. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35256. *
  35257. * @param renderingGroupId The rendering group id corresponding to its index
  35258. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35259. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35260. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35261. */
  35262. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35263. /**
  35264. * Gets the current auto clear configuration for one rendering group of the rendering
  35265. * manager.
  35266. * @param index the rendering group index to get the information for
  35267. * @returns The auto clear setup for the requested rendering group
  35268. */
  35269. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35270. private _blockMaterialDirtyMechanism;
  35271. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35272. blockMaterialDirtyMechanism: boolean;
  35273. /**
  35274. * Will flag all materials as dirty to trigger new shader compilation
  35275. * @param flag defines the flag used to specify which material part must be marked as dirty
  35276. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35277. */
  35278. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35279. /** @hidden */
  35280. _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;
  35281. /** @hidden */
  35282. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35283. }
  35284. }
  35285. declare module "babylonjs/assetContainer" {
  35286. import { AbstractScene } from "babylonjs/abstractScene";
  35287. import { Scene } from "babylonjs/scene";
  35288. import { Mesh } from "babylonjs/Meshes/mesh";
  35289. /**
  35290. * Set of assets to keep when moving a scene into an asset container.
  35291. */
  35292. export class KeepAssets extends AbstractScene {
  35293. }
  35294. /**
  35295. * Container with a set of assets that can be added or removed from a scene.
  35296. */
  35297. export class AssetContainer extends AbstractScene {
  35298. /**
  35299. * The scene the AssetContainer belongs to.
  35300. */
  35301. scene: Scene;
  35302. /**
  35303. * Instantiates an AssetContainer.
  35304. * @param scene The scene the AssetContainer belongs to.
  35305. */
  35306. constructor(scene: Scene);
  35307. /**
  35308. * Adds all the assets from the container to the scene.
  35309. */
  35310. addAllToScene(): void;
  35311. /**
  35312. * Removes all the assets in the container from the scene
  35313. */
  35314. removeAllFromScene(): void;
  35315. /**
  35316. * Disposes all the assets in the container
  35317. */
  35318. dispose(): void;
  35319. private _moveAssets;
  35320. /**
  35321. * Removes all the assets contained in the scene and adds them to the container.
  35322. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35323. */
  35324. moveAllFromScene(keepAssets?: KeepAssets): void;
  35325. /**
  35326. * 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.
  35327. * @returns the root mesh
  35328. */
  35329. createRootMesh(): Mesh;
  35330. }
  35331. }
  35332. declare module "babylonjs/abstractScene" {
  35333. import { Scene } from "babylonjs/scene";
  35334. import { Nullable } from "babylonjs/types";
  35335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35336. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35337. import { Geometry } from "babylonjs/Meshes/geometry";
  35338. import { Skeleton } from "babylonjs/Bones/skeleton";
  35339. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35340. import { AssetContainer } from "babylonjs/assetContainer";
  35341. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35342. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35344. import { Material } from "babylonjs/Materials/material";
  35345. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35346. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35347. import { Camera } from "babylonjs/Cameras/camera";
  35348. import { Light } from "babylonjs/Lights/light";
  35349. import { Node } from "babylonjs/node";
  35350. import { Animation } from "babylonjs/Animations/animation";
  35351. /**
  35352. * Defines how the parser contract is defined.
  35353. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35354. */
  35355. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35356. /**
  35357. * Defines how the individual parser contract is defined.
  35358. * These parser can parse an individual asset
  35359. */
  35360. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35361. /**
  35362. * Base class of the scene acting as a container for the different elements composing a scene.
  35363. * This class is dynamically extended by the different components of the scene increasing
  35364. * flexibility and reducing coupling
  35365. */
  35366. export abstract class AbstractScene {
  35367. /**
  35368. * Stores the list of available parsers in the application.
  35369. */
  35370. private static _BabylonFileParsers;
  35371. /**
  35372. * Stores the list of available individual parsers in the application.
  35373. */
  35374. private static _IndividualBabylonFileParsers;
  35375. /**
  35376. * Adds a parser in the list of available ones
  35377. * @param name Defines the name of the parser
  35378. * @param parser Defines the parser to add
  35379. */
  35380. static AddParser(name: string, parser: BabylonFileParser): void;
  35381. /**
  35382. * Gets a general parser from the list of avaialble ones
  35383. * @param name Defines the name of the parser
  35384. * @returns the requested parser or null
  35385. */
  35386. static GetParser(name: string): Nullable<BabylonFileParser>;
  35387. /**
  35388. * Adds n individual parser in the list of available ones
  35389. * @param name Defines the name of the parser
  35390. * @param parser Defines the parser to add
  35391. */
  35392. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35393. /**
  35394. * Gets an individual parser from the list of avaialble ones
  35395. * @param name Defines the name of the parser
  35396. * @returns the requested parser or null
  35397. */
  35398. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35399. /**
  35400. * Parser json data and populate both a scene and its associated container object
  35401. * @param jsonData Defines the data to parse
  35402. * @param scene Defines the scene to parse the data for
  35403. * @param container Defines the container attached to the parsing sequence
  35404. * @param rootUrl Defines the root url of the data
  35405. */
  35406. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35407. /**
  35408. * Gets the list of root nodes (ie. nodes with no parent)
  35409. */
  35410. rootNodes: Node[];
  35411. /** All of the cameras added to this scene
  35412. * @see http://doc.babylonjs.com/babylon101/cameras
  35413. */
  35414. cameras: Camera[];
  35415. /**
  35416. * All of the lights added to this scene
  35417. * @see http://doc.babylonjs.com/babylon101/lights
  35418. */
  35419. lights: Light[];
  35420. /**
  35421. * All of the (abstract) meshes added to this scene
  35422. */
  35423. meshes: AbstractMesh[];
  35424. /**
  35425. * The list of skeletons added to the scene
  35426. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35427. */
  35428. skeletons: Skeleton[];
  35429. /**
  35430. * All of the particle systems added to this scene
  35431. * @see http://doc.babylonjs.com/babylon101/particles
  35432. */
  35433. particleSystems: IParticleSystem[];
  35434. /**
  35435. * Gets a list of Animations associated with the scene
  35436. */
  35437. animations: Animation[];
  35438. /**
  35439. * All of the animation groups added to this scene
  35440. * @see http://doc.babylonjs.com/how_to/group
  35441. */
  35442. animationGroups: AnimationGroup[];
  35443. /**
  35444. * All of the multi-materials added to this scene
  35445. * @see http://doc.babylonjs.com/how_to/multi_materials
  35446. */
  35447. multiMaterials: MultiMaterial[];
  35448. /**
  35449. * All of the materials added to this scene
  35450. * In the context of a Scene, it is not supposed to be modified manually.
  35451. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35452. * Note also that the order of the Material wihin the array is not significant and might change.
  35453. * @see http://doc.babylonjs.com/babylon101/materials
  35454. */
  35455. materials: Material[];
  35456. /**
  35457. * The list of morph target managers added to the scene
  35458. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35459. */
  35460. morphTargetManagers: MorphTargetManager[];
  35461. /**
  35462. * The list of geometries used in the scene.
  35463. */
  35464. geometries: Geometry[];
  35465. /**
  35466. * All of the tranform nodes added to this scene
  35467. * In the context of a Scene, it is not supposed to be modified manually.
  35468. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35469. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35470. * @see http://doc.babylonjs.com/how_to/transformnode
  35471. */
  35472. transformNodes: TransformNode[];
  35473. /**
  35474. * ActionManagers available on the scene.
  35475. */
  35476. actionManagers: AbstractActionManager[];
  35477. /**
  35478. * Textures to keep.
  35479. */
  35480. textures: BaseTexture[];
  35481. /**
  35482. * Environment texture for the scene
  35483. */
  35484. environmentTexture: Nullable<BaseTexture>;
  35485. }
  35486. }
  35487. declare module "babylonjs/Audio/sound" {
  35488. import { Observable } from "babylonjs/Misc/observable";
  35489. import { Vector3 } from "babylonjs/Maths/math.vector";
  35490. import { Nullable } from "babylonjs/types";
  35491. import { Scene } from "babylonjs/scene";
  35492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35493. /**
  35494. * Interface used to define options for Sound class
  35495. */
  35496. export interface ISoundOptions {
  35497. /**
  35498. * Does the sound autoplay once loaded.
  35499. */
  35500. autoplay?: boolean;
  35501. /**
  35502. * Does the sound loop after it finishes playing once.
  35503. */
  35504. loop?: boolean;
  35505. /**
  35506. * Sound's volume
  35507. */
  35508. volume?: number;
  35509. /**
  35510. * Is it a spatial sound?
  35511. */
  35512. spatialSound?: boolean;
  35513. /**
  35514. * Maximum distance to hear that sound
  35515. */
  35516. maxDistance?: number;
  35517. /**
  35518. * Uses user defined attenuation function
  35519. */
  35520. useCustomAttenuation?: boolean;
  35521. /**
  35522. * Define the roll off factor of spatial sounds.
  35523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35524. */
  35525. rolloffFactor?: number;
  35526. /**
  35527. * Define the reference distance the sound should be heard perfectly.
  35528. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35529. */
  35530. refDistance?: number;
  35531. /**
  35532. * Define the distance attenuation model the sound will follow.
  35533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35534. */
  35535. distanceModel?: string;
  35536. /**
  35537. * Defines the playback speed (1 by default)
  35538. */
  35539. playbackRate?: number;
  35540. /**
  35541. * Defines if the sound is from a streaming source
  35542. */
  35543. streaming?: boolean;
  35544. /**
  35545. * Defines an optional length (in seconds) inside the sound file
  35546. */
  35547. length?: number;
  35548. /**
  35549. * Defines an optional offset (in seconds) inside the sound file
  35550. */
  35551. offset?: number;
  35552. /**
  35553. * If true, URLs will not be required to state the audio file codec to use.
  35554. */
  35555. skipCodecCheck?: boolean;
  35556. }
  35557. /**
  35558. * Defines a sound that can be played in the application.
  35559. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35561. */
  35562. export class Sound {
  35563. /**
  35564. * The name of the sound in the scene.
  35565. */
  35566. name: string;
  35567. /**
  35568. * Does the sound autoplay once loaded.
  35569. */
  35570. autoplay: boolean;
  35571. /**
  35572. * Does the sound loop after it finishes playing once.
  35573. */
  35574. loop: boolean;
  35575. /**
  35576. * Does the sound use a custom attenuation curve to simulate the falloff
  35577. * happening when the source gets further away from the camera.
  35578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35579. */
  35580. useCustomAttenuation: boolean;
  35581. /**
  35582. * The sound track id this sound belongs to.
  35583. */
  35584. soundTrackId: number;
  35585. /**
  35586. * Is this sound currently played.
  35587. */
  35588. isPlaying: boolean;
  35589. /**
  35590. * Is this sound currently paused.
  35591. */
  35592. isPaused: boolean;
  35593. /**
  35594. * Does this sound enables spatial sound.
  35595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35596. */
  35597. spatialSound: boolean;
  35598. /**
  35599. * Define the reference distance the sound should be heard perfectly.
  35600. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35601. */
  35602. refDistance: number;
  35603. /**
  35604. * Define the roll off factor of spatial sounds.
  35605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35606. */
  35607. rolloffFactor: number;
  35608. /**
  35609. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35610. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35611. */
  35612. maxDistance: number;
  35613. /**
  35614. * Define the distance attenuation model the sound will follow.
  35615. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35616. */
  35617. distanceModel: string;
  35618. /**
  35619. * @hidden
  35620. * Back Compat
  35621. **/
  35622. onended: () => any;
  35623. /**
  35624. * Observable event when the current playing sound finishes.
  35625. */
  35626. onEndedObservable: Observable<Sound>;
  35627. private _panningModel;
  35628. private _playbackRate;
  35629. private _streaming;
  35630. private _startTime;
  35631. private _startOffset;
  35632. private _position;
  35633. /** @hidden */
  35634. _positionInEmitterSpace: boolean;
  35635. private _localDirection;
  35636. private _volume;
  35637. private _isReadyToPlay;
  35638. private _isDirectional;
  35639. private _readyToPlayCallback;
  35640. private _audioBuffer;
  35641. private _soundSource;
  35642. private _streamingSource;
  35643. private _soundPanner;
  35644. private _soundGain;
  35645. private _inputAudioNode;
  35646. private _outputAudioNode;
  35647. private _coneInnerAngle;
  35648. private _coneOuterAngle;
  35649. private _coneOuterGain;
  35650. private _scene;
  35651. private _connectedTransformNode;
  35652. private _customAttenuationFunction;
  35653. private _registerFunc;
  35654. private _isOutputConnected;
  35655. private _htmlAudioElement;
  35656. private _urlType;
  35657. private _length?;
  35658. private _offset?;
  35659. /** @hidden */
  35660. static _SceneComponentInitialization: (scene: Scene) => void;
  35661. /**
  35662. * Create a sound and attach it to a scene
  35663. * @param name Name of your sound
  35664. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35665. * @param scene defines the scene the sound belongs to
  35666. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35667. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35668. */
  35669. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35670. /**
  35671. * Release the sound and its associated resources
  35672. */
  35673. dispose(): void;
  35674. /**
  35675. * Gets if the sounds is ready to be played or not.
  35676. * @returns true if ready, otherwise false
  35677. */
  35678. isReady(): boolean;
  35679. private _soundLoaded;
  35680. /**
  35681. * Sets the data of the sound from an audiobuffer
  35682. * @param audioBuffer The audioBuffer containing the data
  35683. */
  35684. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35685. /**
  35686. * Updates the current sounds options such as maxdistance, loop...
  35687. * @param options A JSON object containing values named as the object properties
  35688. */
  35689. updateOptions(options: ISoundOptions): void;
  35690. private _createSpatialParameters;
  35691. private _updateSpatialParameters;
  35692. /**
  35693. * Switch the panning model to HRTF:
  35694. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35696. */
  35697. switchPanningModelToHRTF(): void;
  35698. /**
  35699. * Switch the panning model to Equal Power:
  35700. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35702. */
  35703. switchPanningModelToEqualPower(): void;
  35704. private _switchPanningModel;
  35705. /**
  35706. * Connect this sound to a sound track audio node like gain...
  35707. * @param soundTrackAudioNode the sound track audio node to connect to
  35708. */
  35709. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35710. /**
  35711. * Transform this sound into a directional source
  35712. * @param coneInnerAngle Size of the inner cone in degree
  35713. * @param coneOuterAngle Size of the outer cone in degree
  35714. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35715. */
  35716. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35717. /**
  35718. * Gets or sets the inner angle for the directional cone.
  35719. */
  35720. /**
  35721. * Gets or sets the inner angle for the directional cone.
  35722. */
  35723. directionalConeInnerAngle: number;
  35724. /**
  35725. * Gets or sets the outer angle for the directional cone.
  35726. */
  35727. /**
  35728. * Gets or sets the outer angle for the directional cone.
  35729. */
  35730. directionalConeOuterAngle: number;
  35731. /**
  35732. * Sets the position of the emitter if spatial sound is enabled
  35733. * @param newPosition Defines the new posisiton
  35734. */
  35735. setPosition(newPosition: Vector3): void;
  35736. /**
  35737. * Sets the local direction of the emitter if spatial sound is enabled
  35738. * @param newLocalDirection Defines the new local direction
  35739. */
  35740. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35741. private _updateDirection;
  35742. /** @hidden */
  35743. updateDistanceFromListener(): void;
  35744. /**
  35745. * Sets a new custom attenuation function for the sound.
  35746. * @param callback Defines the function used for the attenuation
  35747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35748. */
  35749. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35750. /**
  35751. * Play the sound
  35752. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35753. * @param offset (optional) Start the sound at a specific time in seconds
  35754. * @param length (optional) Sound duration (in seconds)
  35755. */
  35756. play(time?: number, offset?: number, length?: number): void;
  35757. private _onended;
  35758. /**
  35759. * Stop the sound
  35760. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35761. */
  35762. stop(time?: number): void;
  35763. /**
  35764. * Put the sound in pause
  35765. */
  35766. pause(): void;
  35767. /**
  35768. * Sets a dedicated volume for this sounds
  35769. * @param newVolume Define the new volume of the sound
  35770. * @param time Define time for gradual change to new volume
  35771. */
  35772. setVolume(newVolume: number, time?: number): void;
  35773. /**
  35774. * Set the sound play back rate
  35775. * @param newPlaybackRate Define the playback rate the sound should be played at
  35776. */
  35777. setPlaybackRate(newPlaybackRate: number): void;
  35778. /**
  35779. * Gets the volume of the sound.
  35780. * @returns the volume of the sound
  35781. */
  35782. getVolume(): number;
  35783. /**
  35784. * Attach the sound to a dedicated mesh
  35785. * @param transformNode The transform node to connect the sound with
  35786. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35787. */
  35788. attachToMesh(transformNode: TransformNode): void;
  35789. /**
  35790. * Detach the sound from the previously attached mesh
  35791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35792. */
  35793. detachFromMesh(): void;
  35794. private _onRegisterAfterWorldMatrixUpdate;
  35795. /**
  35796. * Clone the current sound in the scene.
  35797. * @returns the new sound clone
  35798. */
  35799. clone(): Nullable<Sound>;
  35800. /**
  35801. * Gets the current underlying audio buffer containing the data
  35802. * @returns the audio buffer
  35803. */
  35804. getAudioBuffer(): Nullable<AudioBuffer>;
  35805. /**
  35806. * Serializes the Sound in a JSON representation
  35807. * @returns the JSON representation of the sound
  35808. */
  35809. serialize(): any;
  35810. /**
  35811. * Parse a JSON representation of a sound to innstantiate in a given scene
  35812. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35813. * @param scene Define the scene the new parsed sound should be created in
  35814. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35815. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35816. * @returns the newly parsed sound
  35817. */
  35818. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35819. }
  35820. }
  35821. declare module "babylonjs/Actions/directAudioActions" {
  35822. import { Action } from "babylonjs/Actions/action";
  35823. import { Condition } from "babylonjs/Actions/condition";
  35824. import { Sound } from "babylonjs/Audio/sound";
  35825. /**
  35826. * This defines an action helpful to play a defined sound on a triggered action.
  35827. */
  35828. export class PlaySoundAction extends Action {
  35829. private _sound;
  35830. /**
  35831. * Instantiate the action
  35832. * @param triggerOptions defines the trigger options
  35833. * @param sound defines the sound to play
  35834. * @param condition defines the trigger related conditions
  35835. */
  35836. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35837. /** @hidden */
  35838. _prepare(): void;
  35839. /**
  35840. * Execute the action and play the sound.
  35841. */
  35842. execute(): void;
  35843. /**
  35844. * Serializes the actions and its related information.
  35845. * @param parent defines the object to serialize in
  35846. * @returns the serialized object
  35847. */
  35848. serialize(parent: any): any;
  35849. }
  35850. /**
  35851. * This defines an action helpful to stop a defined sound on a triggered action.
  35852. */
  35853. export class StopSoundAction extends Action {
  35854. private _sound;
  35855. /**
  35856. * Instantiate the action
  35857. * @param triggerOptions defines the trigger options
  35858. * @param sound defines the sound to stop
  35859. * @param condition defines the trigger related conditions
  35860. */
  35861. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35862. /** @hidden */
  35863. _prepare(): void;
  35864. /**
  35865. * Execute the action and stop the sound.
  35866. */
  35867. execute(): void;
  35868. /**
  35869. * Serializes the actions and its related information.
  35870. * @param parent defines the object to serialize in
  35871. * @returns the serialized object
  35872. */
  35873. serialize(parent: any): any;
  35874. }
  35875. }
  35876. declare module "babylonjs/Actions/interpolateValueAction" {
  35877. import { Action } from "babylonjs/Actions/action";
  35878. import { Condition } from "babylonjs/Actions/condition";
  35879. import { Observable } from "babylonjs/Misc/observable";
  35880. /**
  35881. * This defines an action responsible to change the value of a property
  35882. * by interpolating between its current value and the newly set one once triggered.
  35883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35884. */
  35885. export class InterpolateValueAction extends Action {
  35886. /**
  35887. * Defines the path of the property where the value should be interpolated
  35888. */
  35889. propertyPath: string;
  35890. /**
  35891. * Defines the target value at the end of the interpolation.
  35892. */
  35893. value: any;
  35894. /**
  35895. * Defines the time it will take for the property to interpolate to the value.
  35896. */
  35897. duration: number;
  35898. /**
  35899. * Defines if the other scene animations should be stopped when the action has been triggered
  35900. */
  35901. stopOtherAnimations?: boolean;
  35902. /**
  35903. * Defines a callback raised once the interpolation animation has been done.
  35904. */
  35905. onInterpolationDone?: () => void;
  35906. /**
  35907. * Observable triggered once the interpolation animation has been done.
  35908. */
  35909. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35910. private _target;
  35911. private _effectiveTarget;
  35912. private _property;
  35913. /**
  35914. * Instantiate the action
  35915. * @param triggerOptions defines the trigger options
  35916. * @param target defines the object containing the value to interpolate
  35917. * @param propertyPath defines the path to the property in the target object
  35918. * @param value defines the target value at the end of the interpolation
  35919. * @param duration deines the time it will take for the property to interpolate to the value.
  35920. * @param condition defines the trigger related conditions
  35921. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35922. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35923. */
  35924. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35925. /** @hidden */
  35926. _prepare(): void;
  35927. /**
  35928. * Execute the action starts the value interpolation.
  35929. */
  35930. execute(): void;
  35931. /**
  35932. * Serializes the actions and its related information.
  35933. * @param parent defines the object to serialize in
  35934. * @returns the serialized object
  35935. */
  35936. serialize(parent: any): any;
  35937. }
  35938. }
  35939. declare module "babylonjs/Actions/index" {
  35940. export * from "babylonjs/Actions/action";
  35941. export * from "babylonjs/Actions/actionEvent";
  35942. export * from "babylonjs/Actions/actionManager";
  35943. export * from "babylonjs/Actions/condition";
  35944. export * from "babylonjs/Actions/directActions";
  35945. export * from "babylonjs/Actions/directAudioActions";
  35946. export * from "babylonjs/Actions/interpolateValueAction";
  35947. }
  35948. declare module "babylonjs/Animations/index" {
  35949. export * from "babylonjs/Animations/animatable";
  35950. export * from "babylonjs/Animations/animation";
  35951. export * from "babylonjs/Animations/animationGroup";
  35952. export * from "babylonjs/Animations/animationPropertiesOverride";
  35953. export * from "babylonjs/Animations/easing";
  35954. export * from "babylonjs/Animations/runtimeAnimation";
  35955. export * from "babylonjs/Animations/animationEvent";
  35956. export * from "babylonjs/Animations/animationGroup";
  35957. export * from "babylonjs/Animations/animationKey";
  35958. export * from "babylonjs/Animations/animationRange";
  35959. export * from "babylonjs/Animations/animatable.interface";
  35960. }
  35961. declare module "babylonjs/Audio/soundTrack" {
  35962. import { Sound } from "babylonjs/Audio/sound";
  35963. import { Analyser } from "babylonjs/Audio/analyser";
  35964. import { Scene } from "babylonjs/scene";
  35965. /**
  35966. * Options allowed during the creation of a sound track.
  35967. */
  35968. export interface ISoundTrackOptions {
  35969. /**
  35970. * The volume the sound track should take during creation
  35971. */
  35972. volume?: number;
  35973. /**
  35974. * Define if the sound track is the main sound track of the scene
  35975. */
  35976. mainTrack?: boolean;
  35977. }
  35978. /**
  35979. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35980. * It will be also used in a future release to apply effects on a specific track.
  35981. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35982. */
  35983. export class SoundTrack {
  35984. /**
  35985. * The unique identifier of the sound track in the scene.
  35986. */
  35987. id: number;
  35988. /**
  35989. * The list of sounds included in the sound track.
  35990. */
  35991. soundCollection: Array<Sound>;
  35992. private _outputAudioNode;
  35993. private _scene;
  35994. private _isMainTrack;
  35995. private _connectedAnalyser;
  35996. private _options;
  35997. private _isInitialized;
  35998. /**
  35999. * Creates a new sound track.
  36000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36001. * @param scene Define the scene the sound track belongs to
  36002. * @param options
  36003. */
  36004. constructor(scene: Scene, options?: ISoundTrackOptions);
  36005. private _initializeSoundTrackAudioGraph;
  36006. /**
  36007. * Release the sound track and its associated resources
  36008. */
  36009. dispose(): void;
  36010. /**
  36011. * Adds a sound to this sound track
  36012. * @param sound define the cound to add
  36013. * @ignoreNaming
  36014. */
  36015. AddSound(sound: Sound): void;
  36016. /**
  36017. * Removes a sound to this sound track
  36018. * @param sound define the cound to remove
  36019. * @ignoreNaming
  36020. */
  36021. RemoveSound(sound: Sound): void;
  36022. /**
  36023. * Set a global volume for the full sound track.
  36024. * @param newVolume Define the new volume of the sound track
  36025. */
  36026. setVolume(newVolume: number): void;
  36027. /**
  36028. * Switch the panning model to HRTF:
  36029. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36031. */
  36032. switchPanningModelToHRTF(): void;
  36033. /**
  36034. * Switch the panning model to Equal Power:
  36035. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. switchPanningModelToEqualPower(): void;
  36039. /**
  36040. * Connect the sound track to an audio analyser allowing some amazing
  36041. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36043. * @param analyser The analyser to connect to the engine
  36044. */
  36045. connectToAnalyser(analyser: Analyser): void;
  36046. }
  36047. }
  36048. declare module "babylonjs/Audio/audioSceneComponent" {
  36049. import { Sound } from "babylonjs/Audio/sound";
  36050. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36051. import { Nullable } from "babylonjs/types";
  36052. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36053. import { Scene } from "babylonjs/scene";
  36054. import { AbstractScene } from "babylonjs/abstractScene";
  36055. module "babylonjs/abstractScene" {
  36056. interface AbstractScene {
  36057. /**
  36058. * The list of sounds used in the scene.
  36059. */
  36060. sounds: Nullable<Array<Sound>>;
  36061. }
  36062. }
  36063. module "babylonjs/scene" {
  36064. interface Scene {
  36065. /**
  36066. * @hidden
  36067. * Backing field
  36068. */
  36069. _mainSoundTrack: SoundTrack;
  36070. /**
  36071. * The main sound track played by the scene.
  36072. * It cotains your primary collection of sounds.
  36073. */
  36074. mainSoundTrack: SoundTrack;
  36075. /**
  36076. * The list of sound tracks added to the scene
  36077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36078. */
  36079. soundTracks: Nullable<Array<SoundTrack>>;
  36080. /**
  36081. * Gets a sound using a given name
  36082. * @param name defines the name to search for
  36083. * @return the found sound or null if not found at all.
  36084. */
  36085. getSoundByName(name: string): Nullable<Sound>;
  36086. /**
  36087. * Gets or sets if audio support is enabled
  36088. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36089. */
  36090. audioEnabled: boolean;
  36091. /**
  36092. * Gets or sets if audio will be output to headphones
  36093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36094. */
  36095. headphone: boolean;
  36096. }
  36097. }
  36098. /**
  36099. * Defines the sound scene component responsible to manage any sounds
  36100. * in a given scene.
  36101. */
  36102. export class AudioSceneComponent implements ISceneSerializableComponent {
  36103. /**
  36104. * The component name helpfull to identify the component in the list of scene components.
  36105. */
  36106. readonly name: string;
  36107. /**
  36108. * The scene the component belongs to.
  36109. */
  36110. scene: Scene;
  36111. private _audioEnabled;
  36112. /**
  36113. * Gets whether audio is enabled or not.
  36114. * Please use related enable/disable method to switch state.
  36115. */
  36116. readonly audioEnabled: boolean;
  36117. private _headphone;
  36118. /**
  36119. * Gets whether audio is outputing to headphone or not.
  36120. * Please use the according Switch methods to change output.
  36121. */
  36122. readonly headphone: boolean;
  36123. /**
  36124. * Creates a new instance of the component for the given scene
  36125. * @param scene Defines the scene to register the component in
  36126. */
  36127. constructor(scene: Scene);
  36128. /**
  36129. * Registers the component in a given scene
  36130. */
  36131. register(): void;
  36132. /**
  36133. * Rebuilds the elements related to this component in case of
  36134. * context lost for instance.
  36135. */
  36136. rebuild(): void;
  36137. /**
  36138. * Serializes the component data to the specified json object
  36139. * @param serializationObject The object to serialize to
  36140. */
  36141. serialize(serializationObject: any): void;
  36142. /**
  36143. * Adds all the elements from the container to the scene
  36144. * @param container the container holding the elements
  36145. */
  36146. addFromContainer(container: AbstractScene): void;
  36147. /**
  36148. * Removes all the elements in the container from the scene
  36149. * @param container contains the elements to remove
  36150. * @param dispose if the removed element should be disposed (default: false)
  36151. */
  36152. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36153. /**
  36154. * Disposes the component and the associated ressources.
  36155. */
  36156. dispose(): void;
  36157. /**
  36158. * Disables audio in the associated scene.
  36159. */
  36160. disableAudio(): void;
  36161. /**
  36162. * Enables audio in the associated scene.
  36163. */
  36164. enableAudio(): void;
  36165. /**
  36166. * Switch audio to headphone output.
  36167. */
  36168. switchAudioModeForHeadphones(): void;
  36169. /**
  36170. * Switch audio to normal speakers.
  36171. */
  36172. switchAudioModeForNormalSpeakers(): void;
  36173. private _afterRender;
  36174. }
  36175. }
  36176. declare module "babylonjs/Audio/weightedsound" {
  36177. import { Sound } from "babylonjs/Audio/sound";
  36178. /**
  36179. * Wraps one or more Sound objects and selects one with random weight for playback.
  36180. */
  36181. export class WeightedSound {
  36182. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36183. loop: boolean;
  36184. private _coneInnerAngle;
  36185. private _coneOuterAngle;
  36186. private _volume;
  36187. /** A Sound is currently playing. */
  36188. isPlaying: boolean;
  36189. /** A Sound is currently paused. */
  36190. isPaused: boolean;
  36191. private _sounds;
  36192. private _weights;
  36193. private _currentIndex?;
  36194. /**
  36195. * Creates a new WeightedSound from the list of sounds given.
  36196. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36197. * @param sounds Array of Sounds that will be selected from.
  36198. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36199. */
  36200. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36201. /**
  36202. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36203. */
  36204. /**
  36205. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36206. */
  36207. directionalConeInnerAngle: number;
  36208. /**
  36209. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36210. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36211. */
  36212. /**
  36213. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36214. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36215. */
  36216. directionalConeOuterAngle: number;
  36217. /**
  36218. * Playback volume.
  36219. */
  36220. /**
  36221. * Playback volume.
  36222. */
  36223. volume: number;
  36224. private _onended;
  36225. /**
  36226. * Suspend playback
  36227. */
  36228. pause(): void;
  36229. /**
  36230. * Stop playback
  36231. */
  36232. stop(): void;
  36233. /**
  36234. * Start playback.
  36235. * @param startOffset Position the clip head at a specific time in seconds.
  36236. */
  36237. play(startOffset?: number): void;
  36238. }
  36239. }
  36240. declare module "babylonjs/Audio/index" {
  36241. export * from "babylonjs/Audio/analyser";
  36242. export * from "babylonjs/Audio/audioEngine";
  36243. export * from "babylonjs/Audio/audioSceneComponent";
  36244. export * from "babylonjs/Audio/sound";
  36245. export * from "babylonjs/Audio/soundTrack";
  36246. export * from "babylonjs/Audio/weightedsound";
  36247. }
  36248. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36249. import { Behavior } from "babylonjs/Behaviors/behavior";
  36250. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36251. import { BackEase } from "babylonjs/Animations/easing";
  36252. /**
  36253. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36254. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36255. */
  36256. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36257. /**
  36258. * Gets the name of the behavior.
  36259. */
  36260. readonly name: string;
  36261. /**
  36262. * The easing function used by animations
  36263. */
  36264. static EasingFunction: BackEase;
  36265. /**
  36266. * The easing mode used by animations
  36267. */
  36268. static EasingMode: number;
  36269. /**
  36270. * The duration of the animation, in milliseconds
  36271. */
  36272. transitionDuration: number;
  36273. /**
  36274. * Length of the distance animated by the transition when lower radius is reached
  36275. */
  36276. lowerRadiusTransitionRange: number;
  36277. /**
  36278. * Length of the distance animated by the transition when upper radius is reached
  36279. */
  36280. upperRadiusTransitionRange: number;
  36281. private _autoTransitionRange;
  36282. /**
  36283. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36284. */
  36285. /**
  36286. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36287. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36288. */
  36289. autoTransitionRange: boolean;
  36290. private _attachedCamera;
  36291. private _onAfterCheckInputsObserver;
  36292. private _onMeshTargetChangedObserver;
  36293. /**
  36294. * Initializes the behavior.
  36295. */
  36296. init(): void;
  36297. /**
  36298. * Attaches the behavior to its arc rotate camera.
  36299. * @param camera Defines the camera to attach the behavior to
  36300. */
  36301. attach(camera: ArcRotateCamera): void;
  36302. /**
  36303. * Detaches the behavior from its current arc rotate camera.
  36304. */
  36305. detach(): void;
  36306. private _radiusIsAnimating;
  36307. private _radiusBounceTransition;
  36308. private _animatables;
  36309. private _cachedWheelPrecision;
  36310. /**
  36311. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36312. * @param radiusLimit The limit to check against.
  36313. * @return Bool to indicate if at limit.
  36314. */
  36315. private _isRadiusAtLimit;
  36316. /**
  36317. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36318. * @param radiusDelta The delta by which to animate to. Can be negative.
  36319. */
  36320. private _applyBoundRadiusAnimation;
  36321. /**
  36322. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36323. */
  36324. protected _clearAnimationLocks(): void;
  36325. /**
  36326. * Stops and removes all animations that have been applied to the camera
  36327. */
  36328. stopAllAnimations(): void;
  36329. }
  36330. }
  36331. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36332. import { Behavior } from "babylonjs/Behaviors/behavior";
  36333. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36334. import { ExponentialEase } from "babylonjs/Animations/easing";
  36335. import { Nullable } from "babylonjs/types";
  36336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36337. import { Vector3 } from "babylonjs/Maths/math.vector";
  36338. /**
  36339. * 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.
  36340. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36341. */
  36342. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36343. /**
  36344. * Gets the name of the behavior.
  36345. */
  36346. readonly name: string;
  36347. private _mode;
  36348. private _radiusScale;
  36349. private _positionScale;
  36350. private _defaultElevation;
  36351. private _elevationReturnTime;
  36352. private _elevationReturnWaitTime;
  36353. private _zoomStopsAnimation;
  36354. private _framingTime;
  36355. /**
  36356. * The easing function used by animations
  36357. */
  36358. static EasingFunction: ExponentialEase;
  36359. /**
  36360. * The easing mode used by animations
  36361. */
  36362. static EasingMode: number;
  36363. /**
  36364. * Sets the current mode used by the behavior
  36365. */
  36366. /**
  36367. * Gets current mode used by the behavior.
  36368. */
  36369. mode: number;
  36370. /**
  36371. * Sets the scale applied to the radius (1 by default)
  36372. */
  36373. /**
  36374. * Gets the scale applied to the radius
  36375. */
  36376. radiusScale: number;
  36377. /**
  36378. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36379. */
  36380. /**
  36381. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36382. */
  36383. positionScale: number;
  36384. /**
  36385. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36386. * behaviour is triggered, in radians.
  36387. */
  36388. /**
  36389. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36390. * behaviour is triggered, in radians.
  36391. */
  36392. defaultElevation: number;
  36393. /**
  36394. * Sets the time (in milliseconds) taken to return to the default beta position.
  36395. * Negative value indicates camera should not return to default.
  36396. */
  36397. /**
  36398. * Gets the time (in milliseconds) taken to return to the default beta position.
  36399. * Negative value indicates camera should not return to default.
  36400. */
  36401. elevationReturnTime: number;
  36402. /**
  36403. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36404. */
  36405. /**
  36406. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36407. */
  36408. elevationReturnWaitTime: number;
  36409. /**
  36410. * Sets the flag that indicates if user zooming should stop animation.
  36411. */
  36412. /**
  36413. * Gets the flag that indicates if user zooming should stop animation.
  36414. */
  36415. zoomStopsAnimation: boolean;
  36416. /**
  36417. * Sets the transition time when framing the mesh, in milliseconds
  36418. */
  36419. /**
  36420. * Gets the transition time when framing the mesh, in milliseconds
  36421. */
  36422. framingTime: number;
  36423. /**
  36424. * Define if the behavior should automatically change the configured
  36425. * camera limits and sensibilities.
  36426. */
  36427. autoCorrectCameraLimitsAndSensibility: boolean;
  36428. private _onPrePointerObservableObserver;
  36429. private _onAfterCheckInputsObserver;
  36430. private _onMeshTargetChangedObserver;
  36431. private _attachedCamera;
  36432. private _isPointerDown;
  36433. private _lastInteractionTime;
  36434. /**
  36435. * Initializes the behavior.
  36436. */
  36437. init(): void;
  36438. /**
  36439. * Attaches the behavior to its arc rotate camera.
  36440. * @param camera Defines the camera to attach the behavior to
  36441. */
  36442. attach(camera: ArcRotateCamera): void;
  36443. /**
  36444. * Detaches the behavior from its current arc rotate camera.
  36445. */
  36446. detach(): void;
  36447. private _animatables;
  36448. private _betaIsAnimating;
  36449. private _betaTransition;
  36450. private _radiusTransition;
  36451. private _vectorTransition;
  36452. /**
  36453. * Targets the given mesh and updates zoom level accordingly.
  36454. * @param mesh The mesh to target.
  36455. * @param radius Optional. If a cached radius position already exists, overrides default.
  36456. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36457. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36458. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36459. */
  36460. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36461. /**
  36462. * Targets the given mesh with its children and updates zoom level accordingly.
  36463. * @param mesh The mesh to target.
  36464. * @param radius Optional. If a cached radius position already exists, overrides default.
  36465. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36466. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36467. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36468. */
  36469. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36470. /**
  36471. * Targets the given meshes with their children and updates zoom level accordingly.
  36472. * @param meshes The mesh to target.
  36473. * @param radius Optional. If a cached radius position already exists, overrides default.
  36474. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36477. */
  36478. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36479. /**
  36480. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36481. * @param minimumWorld Determines the smaller position of the bounding box extend
  36482. * @param maximumWorld Determines the bigger position of the bounding box extend
  36483. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36484. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36485. */
  36486. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36487. /**
  36488. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36489. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36490. * frustum width.
  36491. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36492. * to fully enclose the mesh in the viewing frustum.
  36493. */
  36494. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36495. /**
  36496. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36497. * is automatically returned to its default position (expected to be above ground plane).
  36498. */
  36499. private _maintainCameraAboveGround;
  36500. /**
  36501. * Returns the frustum slope based on the canvas ratio and camera FOV
  36502. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36503. */
  36504. private _getFrustumSlope;
  36505. /**
  36506. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36507. */
  36508. private _clearAnimationLocks;
  36509. /**
  36510. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36511. */
  36512. private _applyUserInteraction;
  36513. /**
  36514. * Stops and removes all animations that have been applied to the camera
  36515. */
  36516. stopAllAnimations(): void;
  36517. /**
  36518. * Gets a value indicating if the user is moving the camera
  36519. */
  36520. readonly isUserIsMoving: boolean;
  36521. /**
  36522. * The camera can move all the way towards the mesh.
  36523. */
  36524. static IgnoreBoundsSizeMode: number;
  36525. /**
  36526. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36527. */
  36528. static FitFrustumSidesMode: number;
  36529. }
  36530. }
  36531. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36532. import { Nullable } from "babylonjs/types";
  36533. import { Camera } from "babylonjs/Cameras/camera";
  36534. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36535. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36536. /**
  36537. * Base class for Camera Pointer Inputs.
  36538. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36539. * for example usage.
  36540. */
  36541. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36542. /**
  36543. * Defines the camera the input is attached to.
  36544. */
  36545. abstract camera: Camera;
  36546. /**
  36547. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36548. */
  36549. protected _altKey: boolean;
  36550. protected _ctrlKey: boolean;
  36551. protected _metaKey: boolean;
  36552. protected _shiftKey: boolean;
  36553. /**
  36554. * Which mouse buttons were pressed at time of last mouse event.
  36555. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36556. */
  36557. protected _buttonsPressed: number;
  36558. /**
  36559. * Defines the buttons associated with the input to handle camera move.
  36560. */
  36561. buttons: number[];
  36562. /**
  36563. * Attach the input controls to a specific dom element to get the input from.
  36564. * @param element Defines the element the controls should be listened from
  36565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36566. */
  36567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36568. /**
  36569. * Detach the current controls from the specified dom element.
  36570. * @param element Defines the element to stop listening the inputs from
  36571. */
  36572. detachControl(element: Nullable<HTMLElement>): void;
  36573. /**
  36574. * Gets the class name of the current input.
  36575. * @returns the class name
  36576. */
  36577. getClassName(): string;
  36578. /**
  36579. * Get the friendly name associated with the input class.
  36580. * @returns the input friendly name
  36581. */
  36582. getSimpleName(): string;
  36583. /**
  36584. * Called on pointer POINTERDOUBLETAP event.
  36585. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36586. */
  36587. protected onDoubleTap(type: string): void;
  36588. /**
  36589. * Called on pointer POINTERMOVE event if only a single touch is active.
  36590. * Override this method to provide functionality.
  36591. */
  36592. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36593. /**
  36594. * Called on pointer POINTERMOVE event if multiple touches are active.
  36595. * Override this method to provide functionality.
  36596. */
  36597. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36598. /**
  36599. * Called on JS contextmenu event.
  36600. * Override this method to provide functionality.
  36601. */
  36602. protected onContextMenu(evt: PointerEvent): void;
  36603. /**
  36604. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36605. * press.
  36606. * Override this method to provide functionality.
  36607. */
  36608. protected onButtonDown(evt: PointerEvent): void;
  36609. /**
  36610. * Called each time a new POINTERUP event occurs. Ie, for each button
  36611. * release.
  36612. * Override this method to provide functionality.
  36613. */
  36614. protected onButtonUp(evt: PointerEvent): void;
  36615. /**
  36616. * Called when window becomes inactive.
  36617. * Override this method to provide functionality.
  36618. */
  36619. protected onLostFocus(): void;
  36620. private _pointerInput;
  36621. private _observer;
  36622. private _onLostFocus;
  36623. private pointA;
  36624. private pointB;
  36625. }
  36626. }
  36627. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36628. import { Nullable } from "babylonjs/types";
  36629. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36630. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36631. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36632. /**
  36633. * Manage the pointers inputs to control an arc rotate camera.
  36634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36635. */
  36636. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36637. /**
  36638. * Defines the camera the input is attached to.
  36639. */
  36640. camera: ArcRotateCamera;
  36641. /**
  36642. * Gets the class name of the current input.
  36643. * @returns the class name
  36644. */
  36645. getClassName(): string;
  36646. /**
  36647. * Defines the buttons associated with the input to handle camera move.
  36648. */
  36649. buttons: number[];
  36650. /**
  36651. * Defines the pointer angular sensibility along the X axis or how fast is
  36652. * the camera rotating.
  36653. */
  36654. angularSensibilityX: number;
  36655. /**
  36656. * Defines the pointer angular sensibility along the Y axis or how fast is
  36657. * the camera rotating.
  36658. */
  36659. angularSensibilityY: number;
  36660. /**
  36661. * Defines the pointer pinch precision or how fast is the camera zooming.
  36662. */
  36663. pinchPrecision: number;
  36664. /**
  36665. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36666. * from 0.
  36667. * It defines the percentage of current camera.radius to use as delta when
  36668. * pinch zoom is used.
  36669. */
  36670. pinchDeltaPercentage: number;
  36671. /**
  36672. * Defines the pointer panning sensibility or how fast is the camera moving.
  36673. */
  36674. panningSensibility: number;
  36675. /**
  36676. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36677. */
  36678. multiTouchPanning: boolean;
  36679. /**
  36680. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36681. * zoom (pinch) through multitouch.
  36682. */
  36683. multiTouchPanAndZoom: boolean;
  36684. /**
  36685. * Revers pinch action direction.
  36686. */
  36687. pinchInwards: boolean;
  36688. private _isPanClick;
  36689. private _twoFingerActivityCount;
  36690. private _isPinching;
  36691. /**
  36692. * Called on pointer POINTERMOVE event if only a single touch is active.
  36693. */
  36694. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36695. /**
  36696. * Called on pointer POINTERDOUBLETAP event.
  36697. */
  36698. protected onDoubleTap(type: string): void;
  36699. /**
  36700. * Called on pointer POINTERMOVE event if multiple touches are active.
  36701. */
  36702. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36703. /**
  36704. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36705. * press.
  36706. */
  36707. protected onButtonDown(evt: PointerEvent): void;
  36708. /**
  36709. * Called each time a new POINTERUP event occurs. Ie, for each button
  36710. * release.
  36711. */
  36712. protected onButtonUp(evt: PointerEvent): void;
  36713. /**
  36714. * Called when window becomes inactive.
  36715. */
  36716. protected onLostFocus(): void;
  36717. }
  36718. }
  36719. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36720. import { Nullable } from "babylonjs/types";
  36721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36722. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36723. /**
  36724. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36726. */
  36727. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36728. /**
  36729. * Defines the camera the input is attached to.
  36730. */
  36731. camera: ArcRotateCamera;
  36732. /**
  36733. * Defines the list of key codes associated with the up action (increase alpha)
  36734. */
  36735. keysUp: number[];
  36736. /**
  36737. * Defines the list of key codes associated with the down action (decrease alpha)
  36738. */
  36739. keysDown: number[];
  36740. /**
  36741. * Defines the list of key codes associated with the left action (increase beta)
  36742. */
  36743. keysLeft: number[];
  36744. /**
  36745. * Defines the list of key codes associated with the right action (decrease beta)
  36746. */
  36747. keysRight: number[];
  36748. /**
  36749. * Defines the list of key codes associated with the reset action.
  36750. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36751. */
  36752. keysReset: number[];
  36753. /**
  36754. * Defines the panning sensibility of the inputs.
  36755. * (How fast is the camera paning)
  36756. */
  36757. panningSensibility: number;
  36758. /**
  36759. * Defines the zooming sensibility of the inputs.
  36760. * (How fast is the camera zooming)
  36761. */
  36762. zoomingSensibility: number;
  36763. /**
  36764. * Defines wether maintaining the alt key down switch the movement mode from
  36765. * orientation to zoom.
  36766. */
  36767. useAltToZoom: boolean;
  36768. /**
  36769. * Rotation speed of the camera
  36770. */
  36771. angularSpeed: number;
  36772. private _keys;
  36773. private _ctrlPressed;
  36774. private _altPressed;
  36775. private _onCanvasBlurObserver;
  36776. private _onKeyboardObserver;
  36777. private _engine;
  36778. private _scene;
  36779. /**
  36780. * Attach the input controls to a specific dom element to get the input from.
  36781. * @param element Defines the element the controls should be listened from
  36782. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36783. */
  36784. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36785. /**
  36786. * Detach the current controls from the specified dom element.
  36787. * @param element Defines the element to stop listening the inputs from
  36788. */
  36789. detachControl(element: Nullable<HTMLElement>): void;
  36790. /**
  36791. * Update the current camera state depending on the inputs that have been used this frame.
  36792. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36793. */
  36794. checkInputs(): void;
  36795. /**
  36796. * Gets the class name of the current intput.
  36797. * @returns the class name
  36798. */
  36799. getClassName(): string;
  36800. /**
  36801. * Get the friendly name associated with the input class.
  36802. * @returns the input friendly name
  36803. */
  36804. getSimpleName(): string;
  36805. }
  36806. }
  36807. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36808. import { Nullable } from "babylonjs/types";
  36809. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36810. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36811. /**
  36812. * Manage the mouse wheel inputs to control an arc rotate camera.
  36813. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36814. */
  36815. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36816. /**
  36817. * Defines the camera the input is attached to.
  36818. */
  36819. camera: ArcRotateCamera;
  36820. /**
  36821. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36822. */
  36823. wheelPrecision: number;
  36824. /**
  36825. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36826. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36827. */
  36828. wheelDeltaPercentage: number;
  36829. private _wheel;
  36830. private _observer;
  36831. private computeDeltaFromMouseWheelLegacyEvent;
  36832. /**
  36833. * Attach the input controls to a specific dom element to get the input from.
  36834. * @param element Defines the element the controls should be listened from
  36835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36836. */
  36837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36838. /**
  36839. * Detach the current controls from the specified dom element.
  36840. * @param element Defines the element to stop listening the inputs from
  36841. */
  36842. detachControl(element: Nullable<HTMLElement>): void;
  36843. /**
  36844. * Gets the class name of the current intput.
  36845. * @returns the class name
  36846. */
  36847. getClassName(): string;
  36848. /**
  36849. * Get the friendly name associated with the input class.
  36850. * @returns the input friendly name
  36851. */
  36852. getSimpleName(): string;
  36853. }
  36854. }
  36855. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36856. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36857. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36858. /**
  36859. * Default Inputs manager for the ArcRotateCamera.
  36860. * It groups all the default supported inputs for ease of use.
  36861. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36862. */
  36863. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36864. /**
  36865. * Instantiates a new ArcRotateCameraInputsManager.
  36866. * @param camera Defines the camera the inputs belong to
  36867. */
  36868. constructor(camera: ArcRotateCamera);
  36869. /**
  36870. * Add mouse wheel input support to the input manager.
  36871. * @returns the current input manager
  36872. */
  36873. addMouseWheel(): ArcRotateCameraInputsManager;
  36874. /**
  36875. * Add pointers input support to the input manager.
  36876. * @returns the current input manager
  36877. */
  36878. addPointers(): ArcRotateCameraInputsManager;
  36879. /**
  36880. * Add keyboard input support to the input manager.
  36881. * @returns the current input manager
  36882. */
  36883. addKeyboard(): ArcRotateCameraInputsManager;
  36884. }
  36885. }
  36886. declare module "babylonjs/Cameras/arcRotateCamera" {
  36887. import { Observable } from "babylonjs/Misc/observable";
  36888. import { Nullable } from "babylonjs/types";
  36889. import { Scene } from "babylonjs/scene";
  36890. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36892. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36893. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36894. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36895. import { Camera } from "babylonjs/Cameras/camera";
  36896. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36897. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36898. import { Collider } from "babylonjs/Collisions/collider";
  36899. /**
  36900. * This represents an orbital type of camera.
  36901. *
  36902. * 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.
  36903. * 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.
  36904. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36905. */
  36906. export class ArcRotateCamera extends TargetCamera {
  36907. /**
  36908. * Defines the rotation angle of the camera along the longitudinal axis.
  36909. */
  36910. alpha: number;
  36911. /**
  36912. * Defines the rotation angle of the camera along the latitudinal axis.
  36913. */
  36914. beta: number;
  36915. /**
  36916. * Defines the radius of the camera from it s target point.
  36917. */
  36918. radius: number;
  36919. protected _target: Vector3;
  36920. protected _targetHost: Nullable<AbstractMesh>;
  36921. /**
  36922. * Defines the target point of the camera.
  36923. * The camera looks towards it form the radius distance.
  36924. */
  36925. target: Vector3;
  36926. /**
  36927. * Define the current local position of the camera in the scene
  36928. */
  36929. position: Vector3;
  36930. protected _upVector: Vector3;
  36931. protected _upToYMatrix: Matrix;
  36932. protected _YToUpMatrix: Matrix;
  36933. /**
  36934. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36935. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36936. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36937. */
  36938. upVector: Vector3;
  36939. /**
  36940. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36941. */
  36942. setMatUp(): void;
  36943. /**
  36944. * Current inertia value on the longitudinal axis.
  36945. * The bigger this number the longer it will take for the camera to stop.
  36946. */
  36947. inertialAlphaOffset: number;
  36948. /**
  36949. * Current inertia value on the latitudinal axis.
  36950. * The bigger this number the longer it will take for the camera to stop.
  36951. */
  36952. inertialBetaOffset: number;
  36953. /**
  36954. * Current inertia value on the radius axis.
  36955. * The bigger this number the longer it will take for the camera to stop.
  36956. */
  36957. inertialRadiusOffset: number;
  36958. /**
  36959. * Minimum allowed angle on the longitudinal axis.
  36960. * This can help limiting how the Camera is able to move in the scene.
  36961. */
  36962. lowerAlphaLimit: Nullable<number>;
  36963. /**
  36964. * Maximum allowed angle on the longitudinal axis.
  36965. * This can help limiting how the Camera is able to move in the scene.
  36966. */
  36967. upperAlphaLimit: Nullable<number>;
  36968. /**
  36969. * Minimum allowed angle on the latitudinal axis.
  36970. * This can help limiting how the Camera is able to move in the scene.
  36971. */
  36972. lowerBetaLimit: number;
  36973. /**
  36974. * Maximum allowed angle on the latitudinal axis.
  36975. * This can help limiting how the Camera is able to move in the scene.
  36976. */
  36977. upperBetaLimit: number;
  36978. /**
  36979. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36980. * This can help limiting how the Camera is able to move in the scene.
  36981. */
  36982. lowerRadiusLimit: Nullable<number>;
  36983. /**
  36984. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36985. * This can help limiting how the Camera is able to move in the scene.
  36986. */
  36987. upperRadiusLimit: Nullable<number>;
  36988. /**
  36989. * Defines the current inertia value used during panning of the camera along the X axis.
  36990. */
  36991. inertialPanningX: number;
  36992. /**
  36993. * Defines the current inertia value used during panning of the camera along the Y axis.
  36994. */
  36995. inertialPanningY: number;
  36996. /**
  36997. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36998. * Basically if your fingers moves away from more than this distance you will be considered
  36999. * in pinch mode.
  37000. */
  37001. pinchToPanMaxDistance: number;
  37002. /**
  37003. * Defines the maximum distance the camera can pan.
  37004. * This could help keeping the cammera always in your scene.
  37005. */
  37006. panningDistanceLimit: Nullable<number>;
  37007. /**
  37008. * Defines the target of the camera before paning.
  37009. */
  37010. panningOriginTarget: Vector3;
  37011. /**
  37012. * Defines the value of the inertia used during panning.
  37013. * 0 would mean stop inertia and one would mean no decelleration at all.
  37014. */
  37015. panningInertia: number;
  37016. /**
  37017. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37018. */
  37019. angularSensibilityX: number;
  37020. /**
  37021. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37022. */
  37023. angularSensibilityY: number;
  37024. /**
  37025. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37026. */
  37027. pinchPrecision: number;
  37028. /**
  37029. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37030. * It will be used instead of pinchDeltaPrecision if different from 0.
  37031. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37032. */
  37033. pinchDeltaPercentage: number;
  37034. /**
  37035. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37036. */
  37037. panningSensibility: number;
  37038. /**
  37039. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37040. */
  37041. keysUp: number[];
  37042. /**
  37043. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37044. */
  37045. keysDown: number[];
  37046. /**
  37047. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37048. */
  37049. keysLeft: number[];
  37050. /**
  37051. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37052. */
  37053. keysRight: number[];
  37054. /**
  37055. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37056. */
  37057. wheelPrecision: number;
  37058. /**
  37059. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37060. * It will be used instead of pinchDeltaPrecision if different from 0.
  37061. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37062. */
  37063. wheelDeltaPercentage: number;
  37064. /**
  37065. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37066. */
  37067. zoomOnFactor: number;
  37068. /**
  37069. * Defines a screen offset for the camera position.
  37070. */
  37071. targetScreenOffset: Vector2;
  37072. /**
  37073. * Allows the camera to be completely reversed.
  37074. * If false the camera can not arrive upside down.
  37075. */
  37076. allowUpsideDown: boolean;
  37077. /**
  37078. * Define if double tap/click is used to restore the previously saved state of the camera.
  37079. */
  37080. useInputToRestoreState: boolean;
  37081. /** @hidden */
  37082. _viewMatrix: Matrix;
  37083. /** @hidden */
  37084. _useCtrlForPanning: boolean;
  37085. /** @hidden */
  37086. _panningMouseButton: number;
  37087. /**
  37088. * Defines the input associated to the camera.
  37089. */
  37090. inputs: ArcRotateCameraInputsManager;
  37091. /** @hidden */
  37092. _reset: () => void;
  37093. /**
  37094. * Defines the allowed panning axis.
  37095. */
  37096. panningAxis: Vector3;
  37097. protected _localDirection: Vector3;
  37098. protected _transformedDirection: Vector3;
  37099. private _bouncingBehavior;
  37100. /**
  37101. * Gets the bouncing behavior of the camera if it has been enabled.
  37102. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37103. */
  37104. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37105. /**
  37106. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37107. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37108. */
  37109. useBouncingBehavior: boolean;
  37110. private _framingBehavior;
  37111. /**
  37112. * Gets the framing behavior of the camera if it has been enabled.
  37113. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37114. */
  37115. readonly framingBehavior: Nullable<FramingBehavior>;
  37116. /**
  37117. * Defines if the framing behavior of the camera is enabled on the camera.
  37118. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37119. */
  37120. useFramingBehavior: boolean;
  37121. private _autoRotationBehavior;
  37122. /**
  37123. * Gets the auto rotation behavior of the camera if it has been enabled.
  37124. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37125. */
  37126. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37127. /**
  37128. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37129. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37130. */
  37131. useAutoRotationBehavior: boolean;
  37132. /**
  37133. * Observable triggered when the mesh target has been changed on the camera.
  37134. */
  37135. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37136. /**
  37137. * Event raised when the camera is colliding with a mesh.
  37138. */
  37139. onCollide: (collidedMesh: AbstractMesh) => void;
  37140. /**
  37141. * Defines whether the camera should check collision with the objects oh the scene.
  37142. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37143. */
  37144. checkCollisions: boolean;
  37145. /**
  37146. * Defines the collision radius of the camera.
  37147. * This simulates a sphere around the camera.
  37148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37149. */
  37150. collisionRadius: Vector3;
  37151. protected _collider: Collider;
  37152. protected _previousPosition: Vector3;
  37153. protected _collisionVelocity: Vector3;
  37154. protected _newPosition: Vector3;
  37155. protected _previousAlpha: number;
  37156. protected _previousBeta: number;
  37157. protected _previousRadius: number;
  37158. protected _collisionTriggered: boolean;
  37159. protected _targetBoundingCenter: Nullable<Vector3>;
  37160. private _computationVector;
  37161. /**
  37162. * Instantiates a new ArcRotateCamera in a given scene
  37163. * @param name Defines the name of the camera
  37164. * @param alpha Defines the camera rotation along the logitudinal axis
  37165. * @param beta Defines the camera rotation along the latitudinal axis
  37166. * @param radius Defines the camera distance from its target
  37167. * @param target Defines the camera target
  37168. * @param scene Defines the scene the camera belongs to
  37169. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37170. */
  37171. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37172. /** @hidden */
  37173. _initCache(): void;
  37174. /** @hidden */
  37175. _updateCache(ignoreParentClass?: boolean): void;
  37176. protected _getTargetPosition(): Vector3;
  37177. private _storedAlpha;
  37178. private _storedBeta;
  37179. private _storedRadius;
  37180. private _storedTarget;
  37181. /**
  37182. * Stores the current state of the camera (alpha, beta, radius and target)
  37183. * @returns the camera itself
  37184. */
  37185. storeState(): Camera;
  37186. /**
  37187. * @hidden
  37188. * Restored camera state. You must call storeState() first
  37189. */
  37190. _restoreStateValues(): boolean;
  37191. /** @hidden */
  37192. _isSynchronizedViewMatrix(): boolean;
  37193. /**
  37194. * Attached controls to the current camera.
  37195. * @param element Defines the element the controls should be listened from
  37196. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37197. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37198. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37199. */
  37200. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37201. /**
  37202. * Detach the current controls from the camera.
  37203. * The camera will stop reacting to inputs.
  37204. * @param element Defines the element to stop listening the inputs from
  37205. */
  37206. detachControl(element: HTMLElement): void;
  37207. /** @hidden */
  37208. _checkInputs(): void;
  37209. protected _checkLimits(): void;
  37210. /**
  37211. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37212. */
  37213. rebuildAnglesAndRadius(): void;
  37214. /**
  37215. * Use a position to define the current camera related information like aplha, beta and radius
  37216. * @param position Defines the position to set the camera at
  37217. */
  37218. setPosition(position: Vector3): void;
  37219. /**
  37220. * Defines the target the camera should look at.
  37221. * This will automatically adapt alpha beta and radius to fit within the new target.
  37222. * @param target Defines the new target as a Vector or a mesh
  37223. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37224. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37225. */
  37226. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37227. /** @hidden */
  37228. _getViewMatrix(): Matrix;
  37229. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37230. /**
  37231. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37232. * @param meshes Defines the mesh to zoom on
  37233. * @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)
  37234. */
  37235. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37236. /**
  37237. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37238. * The target will be changed but the radius
  37239. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37240. * @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)
  37241. */
  37242. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37243. min: Vector3;
  37244. max: Vector3;
  37245. distance: number;
  37246. }, doNotUpdateMaxZ?: boolean): void;
  37247. /**
  37248. * @override
  37249. * Override Camera.createRigCamera
  37250. */
  37251. createRigCamera(name: string, cameraIndex: number): Camera;
  37252. /**
  37253. * @hidden
  37254. * @override
  37255. * Override Camera._updateRigCameras
  37256. */
  37257. _updateRigCameras(): void;
  37258. /**
  37259. * Destroy the camera and release the current resources hold by it.
  37260. */
  37261. dispose(): void;
  37262. /**
  37263. * Gets the current object class name.
  37264. * @return the class name
  37265. */
  37266. getClassName(): string;
  37267. }
  37268. }
  37269. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37270. import { Behavior } from "babylonjs/Behaviors/behavior";
  37271. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37272. /**
  37273. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37274. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37275. */
  37276. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37277. /**
  37278. * Gets the name of the behavior.
  37279. */
  37280. readonly name: string;
  37281. private _zoomStopsAnimation;
  37282. private _idleRotationSpeed;
  37283. private _idleRotationWaitTime;
  37284. private _idleRotationSpinupTime;
  37285. /**
  37286. * Sets the flag that indicates if user zooming should stop animation.
  37287. */
  37288. /**
  37289. * Gets the flag that indicates if user zooming should stop animation.
  37290. */
  37291. zoomStopsAnimation: boolean;
  37292. /**
  37293. * Sets the default speed at which the camera rotates around the model.
  37294. */
  37295. /**
  37296. * Gets the default speed at which the camera rotates around the model.
  37297. */
  37298. idleRotationSpeed: number;
  37299. /**
  37300. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37301. */
  37302. /**
  37303. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37304. */
  37305. idleRotationWaitTime: number;
  37306. /**
  37307. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37308. */
  37309. /**
  37310. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37311. */
  37312. idleRotationSpinupTime: number;
  37313. /**
  37314. * Gets a value indicating if the camera is currently rotating because of this behavior
  37315. */
  37316. readonly rotationInProgress: boolean;
  37317. private _onPrePointerObservableObserver;
  37318. private _onAfterCheckInputsObserver;
  37319. private _attachedCamera;
  37320. private _isPointerDown;
  37321. private _lastFrameTime;
  37322. private _lastInteractionTime;
  37323. private _cameraRotationSpeed;
  37324. /**
  37325. * Initializes the behavior.
  37326. */
  37327. init(): void;
  37328. /**
  37329. * Attaches the behavior to its arc rotate camera.
  37330. * @param camera Defines the camera to attach the behavior to
  37331. */
  37332. attach(camera: ArcRotateCamera): void;
  37333. /**
  37334. * Detaches the behavior from its current arc rotate camera.
  37335. */
  37336. detach(): void;
  37337. /**
  37338. * Returns true if user is scrolling.
  37339. * @return true if user is scrolling.
  37340. */
  37341. private _userIsZooming;
  37342. private _lastFrameRadius;
  37343. private _shouldAnimationStopForInteraction;
  37344. /**
  37345. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37346. */
  37347. private _applyUserInteraction;
  37348. private _userIsMoving;
  37349. }
  37350. }
  37351. declare module "babylonjs/Behaviors/Cameras/index" {
  37352. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37353. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37354. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37355. }
  37356. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37357. import { Mesh } from "babylonjs/Meshes/mesh";
  37358. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37359. import { Behavior } from "babylonjs/Behaviors/behavior";
  37360. /**
  37361. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37362. */
  37363. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37364. private ui;
  37365. /**
  37366. * The name of the behavior
  37367. */
  37368. name: string;
  37369. /**
  37370. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37371. */
  37372. distanceAwayFromFace: number;
  37373. /**
  37374. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37375. */
  37376. distanceAwayFromBottomOfFace: number;
  37377. private _faceVectors;
  37378. private _target;
  37379. private _scene;
  37380. private _onRenderObserver;
  37381. private _tmpMatrix;
  37382. private _tmpVector;
  37383. /**
  37384. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37385. * @param ui The transform node that should be attched to the mesh
  37386. */
  37387. constructor(ui: TransformNode);
  37388. /**
  37389. * Initializes the behavior
  37390. */
  37391. init(): void;
  37392. private _closestFace;
  37393. private _zeroVector;
  37394. private _lookAtTmpMatrix;
  37395. private _lookAtToRef;
  37396. /**
  37397. * Attaches the AttachToBoxBehavior to the passed in mesh
  37398. * @param target The mesh that the specified node will be attached to
  37399. */
  37400. attach(target: Mesh): void;
  37401. /**
  37402. * Detaches the behavior from the mesh
  37403. */
  37404. detach(): void;
  37405. }
  37406. }
  37407. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37408. import { Behavior } from "babylonjs/Behaviors/behavior";
  37409. import { Mesh } from "babylonjs/Meshes/mesh";
  37410. /**
  37411. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37412. */
  37413. export class FadeInOutBehavior implements Behavior<Mesh> {
  37414. /**
  37415. * Time in milliseconds to delay before fading in (Default: 0)
  37416. */
  37417. delay: number;
  37418. /**
  37419. * Time in milliseconds for the mesh to fade in (Default: 300)
  37420. */
  37421. fadeInTime: number;
  37422. private _millisecondsPerFrame;
  37423. private _hovered;
  37424. private _hoverValue;
  37425. private _ownerNode;
  37426. /**
  37427. * Instatiates the FadeInOutBehavior
  37428. */
  37429. constructor();
  37430. /**
  37431. * The name of the behavior
  37432. */
  37433. readonly name: string;
  37434. /**
  37435. * Initializes the behavior
  37436. */
  37437. init(): void;
  37438. /**
  37439. * Attaches the fade behavior on the passed in mesh
  37440. * @param ownerNode The mesh that will be faded in/out once attached
  37441. */
  37442. attach(ownerNode: Mesh): void;
  37443. /**
  37444. * Detaches the behavior from the mesh
  37445. */
  37446. detach(): void;
  37447. /**
  37448. * Triggers the mesh to begin fading in or out
  37449. * @param value if the object should fade in or out (true to fade in)
  37450. */
  37451. fadeIn(value: boolean): void;
  37452. private _update;
  37453. private _setAllVisibility;
  37454. }
  37455. }
  37456. declare module "babylonjs/Misc/pivotTools" {
  37457. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37458. /**
  37459. * Class containing a set of static utilities functions for managing Pivots
  37460. * @hidden
  37461. */
  37462. export class PivotTools {
  37463. private static _PivotCached;
  37464. private static _OldPivotPoint;
  37465. private static _PivotTranslation;
  37466. private static _PivotTmpVector;
  37467. /** @hidden */
  37468. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37469. /** @hidden */
  37470. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37471. }
  37472. }
  37473. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37474. import { Scene } from "babylonjs/scene";
  37475. import { Vector4 } from "babylonjs/Maths/math.vector";
  37476. import { Mesh } from "babylonjs/Meshes/mesh";
  37477. import { Nullable } from "babylonjs/types";
  37478. import { Plane } from "babylonjs/Maths/math.plane";
  37479. /**
  37480. * Class containing static functions to help procedurally build meshes
  37481. */
  37482. export class PlaneBuilder {
  37483. /**
  37484. * Creates a plane mesh
  37485. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37486. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37487. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37489. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37491. * @param name defines the name of the mesh
  37492. * @param options defines the options used to create the mesh
  37493. * @param scene defines the hosting scene
  37494. * @returns the plane mesh
  37495. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37496. */
  37497. static CreatePlane(name: string, options: {
  37498. size?: number;
  37499. width?: number;
  37500. height?: number;
  37501. sideOrientation?: number;
  37502. frontUVs?: Vector4;
  37503. backUVs?: Vector4;
  37504. updatable?: boolean;
  37505. sourcePlane?: Plane;
  37506. }, scene?: Nullable<Scene>): Mesh;
  37507. }
  37508. }
  37509. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37510. import { Behavior } from "babylonjs/Behaviors/behavior";
  37511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37512. import { Observable } from "babylonjs/Misc/observable";
  37513. import { Vector3 } from "babylonjs/Maths/math.vector";
  37514. import { Ray } from "babylonjs/Culling/ray";
  37515. import "babylonjs/Meshes/Builders/planeBuilder";
  37516. /**
  37517. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37518. */
  37519. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37520. private static _AnyMouseID;
  37521. /**
  37522. * Abstract mesh the behavior is set on
  37523. */
  37524. attachedNode: AbstractMesh;
  37525. private _dragPlane;
  37526. private _scene;
  37527. private _pointerObserver;
  37528. private _beforeRenderObserver;
  37529. private static _planeScene;
  37530. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37531. /**
  37532. * 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)
  37533. */
  37534. maxDragAngle: number;
  37535. /**
  37536. * @hidden
  37537. */
  37538. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37539. /**
  37540. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37541. */
  37542. currentDraggingPointerID: number;
  37543. /**
  37544. * The last position where the pointer hit the drag plane in world space
  37545. */
  37546. lastDragPosition: Vector3;
  37547. /**
  37548. * If the behavior is currently in a dragging state
  37549. */
  37550. dragging: boolean;
  37551. /**
  37552. * 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)
  37553. */
  37554. dragDeltaRatio: number;
  37555. /**
  37556. * If the drag plane orientation should be updated during the dragging (Default: true)
  37557. */
  37558. updateDragPlane: boolean;
  37559. private _debugMode;
  37560. private _moving;
  37561. /**
  37562. * Fires each time the attached mesh is dragged with the pointer
  37563. * * delta between last drag position and current drag position in world space
  37564. * * dragDistance along the drag axis
  37565. * * dragPlaneNormal normal of the current drag plane used during the drag
  37566. * * dragPlanePoint in world space where the drag intersects the drag plane
  37567. */
  37568. onDragObservable: Observable<{
  37569. delta: Vector3;
  37570. dragPlanePoint: Vector3;
  37571. dragPlaneNormal: Vector3;
  37572. dragDistance: number;
  37573. pointerId: number;
  37574. }>;
  37575. /**
  37576. * Fires each time a drag begins (eg. mouse down on mesh)
  37577. */
  37578. onDragStartObservable: Observable<{
  37579. dragPlanePoint: Vector3;
  37580. pointerId: number;
  37581. }>;
  37582. /**
  37583. * Fires each time a drag ends (eg. mouse release after drag)
  37584. */
  37585. onDragEndObservable: Observable<{
  37586. dragPlanePoint: Vector3;
  37587. pointerId: number;
  37588. }>;
  37589. /**
  37590. * If the attached mesh should be moved when dragged
  37591. */
  37592. moveAttached: boolean;
  37593. /**
  37594. * If the drag behavior will react to drag events (Default: true)
  37595. */
  37596. enabled: boolean;
  37597. /**
  37598. * If pointer events should start and release the drag (Default: true)
  37599. */
  37600. startAndReleaseDragOnPointerEvents: boolean;
  37601. /**
  37602. * If camera controls should be detached during the drag
  37603. */
  37604. detachCameraControls: boolean;
  37605. /**
  37606. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37607. */
  37608. useObjectOrienationForDragging: boolean;
  37609. private _options;
  37610. /**
  37611. * Creates a pointer drag behavior that can be attached to a mesh
  37612. * @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)
  37613. */
  37614. constructor(options?: {
  37615. dragAxis?: Vector3;
  37616. dragPlaneNormal?: Vector3;
  37617. });
  37618. /**
  37619. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37620. */
  37621. validateDrag: (targetPosition: Vector3) => boolean;
  37622. /**
  37623. * The name of the behavior
  37624. */
  37625. readonly name: string;
  37626. /**
  37627. * Initializes the behavior
  37628. */
  37629. init(): void;
  37630. private _tmpVector;
  37631. private _alternatePickedPoint;
  37632. private _worldDragAxis;
  37633. private _targetPosition;
  37634. private _attachedElement;
  37635. /**
  37636. * Attaches the drag behavior the passed in mesh
  37637. * @param ownerNode The mesh that will be dragged around once attached
  37638. */
  37639. attach(ownerNode: AbstractMesh): void;
  37640. /**
  37641. * Force relase the drag action by code.
  37642. */
  37643. releaseDrag(): void;
  37644. private _startDragRay;
  37645. private _lastPointerRay;
  37646. /**
  37647. * Simulates the start of a pointer drag event on the behavior
  37648. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37649. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37650. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37651. */
  37652. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37653. private _startDrag;
  37654. private _dragDelta;
  37655. private _moveDrag;
  37656. private _pickWithRayOnDragPlane;
  37657. private _pointA;
  37658. private _pointB;
  37659. private _pointC;
  37660. private _lineA;
  37661. private _lineB;
  37662. private _localAxis;
  37663. private _lookAt;
  37664. private _updateDragPlanePosition;
  37665. /**
  37666. * Detaches the behavior from the mesh
  37667. */
  37668. detach(): void;
  37669. }
  37670. }
  37671. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37672. import { Mesh } from "babylonjs/Meshes/mesh";
  37673. import { Behavior } from "babylonjs/Behaviors/behavior";
  37674. /**
  37675. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37676. */
  37677. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37678. private _dragBehaviorA;
  37679. private _dragBehaviorB;
  37680. private _startDistance;
  37681. private _initialScale;
  37682. private _targetScale;
  37683. private _ownerNode;
  37684. private _sceneRenderObserver;
  37685. /**
  37686. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37687. */
  37688. constructor();
  37689. /**
  37690. * The name of the behavior
  37691. */
  37692. readonly name: string;
  37693. /**
  37694. * Initializes the behavior
  37695. */
  37696. init(): void;
  37697. private _getCurrentDistance;
  37698. /**
  37699. * Attaches the scale behavior the passed in mesh
  37700. * @param ownerNode The mesh that will be scaled around once attached
  37701. */
  37702. attach(ownerNode: Mesh): void;
  37703. /**
  37704. * Detaches the behavior from the mesh
  37705. */
  37706. detach(): void;
  37707. }
  37708. }
  37709. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37710. import { Behavior } from "babylonjs/Behaviors/behavior";
  37711. import { Mesh } from "babylonjs/Meshes/mesh";
  37712. import { Observable } from "babylonjs/Misc/observable";
  37713. /**
  37714. * 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
  37715. */
  37716. export class SixDofDragBehavior implements Behavior<Mesh> {
  37717. private static _virtualScene;
  37718. private _ownerNode;
  37719. private _sceneRenderObserver;
  37720. private _scene;
  37721. private _targetPosition;
  37722. private _virtualOriginMesh;
  37723. private _virtualDragMesh;
  37724. private _pointerObserver;
  37725. private _moving;
  37726. private _startingOrientation;
  37727. /**
  37728. * 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)
  37729. */
  37730. private zDragFactor;
  37731. /**
  37732. * If the object should rotate to face the drag origin
  37733. */
  37734. rotateDraggedObject: boolean;
  37735. /**
  37736. * If the behavior is currently in a dragging state
  37737. */
  37738. dragging: boolean;
  37739. /**
  37740. * 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)
  37741. */
  37742. dragDeltaRatio: number;
  37743. /**
  37744. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37745. */
  37746. currentDraggingPointerID: number;
  37747. /**
  37748. * If camera controls should be detached during the drag
  37749. */
  37750. detachCameraControls: boolean;
  37751. /**
  37752. * Fires each time a drag starts
  37753. */
  37754. onDragStartObservable: Observable<{}>;
  37755. /**
  37756. * Fires each time a drag ends (eg. mouse release after drag)
  37757. */
  37758. onDragEndObservable: Observable<{}>;
  37759. /**
  37760. * 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
  37761. */
  37762. constructor();
  37763. /**
  37764. * The name of the behavior
  37765. */
  37766. readonly name: string;
  37767. /**
  37768. * Initializes the behavior
  37769. */
  37770. init(): void;
  37771. /**
  37772. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37773. */
  37774. private readonly _pointerCamera;
  37775. /**
  37776. * Attaches the scale behavior the passed in mesh
  37777. * @param ownerNode The mesh that will be scaled around once attached
  37778. */
  37779. attach(ownerNode: Mesh): void;
  37780. /**
  37781. * Detaches the behavior from the mesh
  37782. */
  37783. detach(): void;
  37784. }
  37785. }
  37786. declare module "babylonjs/Behaviors/Meshes/index" {
  37787. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37788. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37789. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37790. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37791. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37792. }
  37793. declare module "babylonjs/Behaviors/index" {
  37794. export * from "babylonjs/Behaviors/behavior";
  37795. export * from "babylonjs/Behaviors/Cameras/index";
  37796. export * from "babylonjs/Behaviors/Meshes/index";
  37797. }
  37798. declare module "babylonjs/Bones/boneIKController" {
  37799. import { Bone } from "babylonjs/Bones/bone";
  37800. import { Vector3 } from "babylonjs/Maths/math.vector";
  37801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37802. import { Nullable } from "babylonjs/types";
  37803. /**
  37804. * Class used to apply inverse kinematics to bones
  37805. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37806. */
  37807. export class BoneIKController {
  37808. private static _tmpVecs;
  37809. private static _tmpQuat;
  37810. private static _tmpMats;
  37811. /**
  37812. * Gets or sets the target mesh
  37813. */
  37814. targetMesh: AbstractMesh;
  37815. /** Gets or sets the mesh used as pole */
  37816. poleTargetMesh: AbstractMesh;
  37817. /**
  37818. * Gets or sets the bone used as pole
  37819. */
  37820. poleTargetBone: Nullable<Bone>;
  37821. /**
  37822. * Gets or sets the target position
  37823. */
  37824. targetPosition: Vector3;
  37825. /**
  37826. * Gets or sets the pole target position
  37827. */
  37828. poleTargetPosition: Vector3;
  37829. /**
  37830. * Gets or sets the pole target local offset
  37831. */
  37832. poleTargetLocalOffset: Vector3;
  37833. /**
  37834. * Gets or sets the pole angle
  37835. */
  37836. poleAngle: number;
  37837. /**
  37838. * Gets or sets the mesh associated with the controller
  37839. */
  37840. mesh: AbstractMesh;
  37841. /**
  37842. * 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)
  37843. */
  37844. slerpAmount: number;
  37845. private _bone1Quat;
  37846. private _bone1Mat;
  37847. private _bone2Ang;
  37848. private _bone1;
  37849. private _bone2;
  37850. private _bone1Length;
  37851. private _bone2Length;
  37852. private _maxAngle;
  37853. private _maxReach;
  37854. private _rightHandedSystem;
  37855. private _bendAxis;
  37856. private _slerping;
  37857. private _adjustRoll;
  37858. /**
  37859. * Gets or sets maximum allowed angle
  37860. */
  37861. maxAngle: number;
  37862. /**
  37863. * Creates a new BoneIKController
  37864. * @param mesh defines the mesh to control
  37865. * @param bone defines the bone to control
  37866. * @param options defines options to set up the controller
  37867. */
  37868. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37869. targetMesh?: AbstractMesh;
  37870. poleTargetMesh?: AbstractMesh;
  37871. poleTargetBone?: Bone;
  37872. poleTargetLocalOffset?: Vector3;
  37873. poleAngle?: number;
  37874. bendAxis?: Vector3;
  37875. maxAngle?: number;
  37876. slerpAmount?: number;
  37877. });
  37878. private _setMaxAngle;
  37879. /**
  37880. * Force the controller to update the bones
  37881. */
  37882. update(): void;
  37883. }
  37884. }
  37885. declare module "babylonjs/Bones/boneLookController" {
  37886. import { Vector3 } from "babylonjs/Maths/math.vector";
  37887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37888. import { Bone } from "babylonjs/Bones/bone";
  37889. import { Space } from "babylonjs/Maths/math.axis";
  37890. /**
  37891. * Class used to make a bone look toward a point in space
  37892. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37893. */
  37894. export class BoneLookController {
  37895. private static _tmpVecs;
  37896. private static _tmpQuat;
  37897. private static _tmpMats;
  37898. /**
  37899. * The target Vector3 that the bone will look at
  37900. */
  37901. target: Vector3;
  37902. /**
  37903. * The mesh that the bone is attached to
  37904. */
  37905. mesh: AbstractMesh;
  37906. /**
  37907. * The bone that will be looking to the target
  37908. */
  37909. bone: Bone;
  37910. /**
  37911. * The up axis of the coordinate system that is used when the bone is rotated
  37912. */
  37913. upAxis: Vector3;
  37914. /**
  37915. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37916. */
  37917. upAxisSpace: Space;
  37918. /**
  37919. * Used to make an adjustment to the yaw of the bone
  37920. */
  37921. adjustYaw: number;
  37922. /**
  37923. * Used to make an adjustment to the pitch of the bone
  37924. */
  37925. adjustPitch: number;
  37926. /**
  37927. * Used to make an adjustment to the roll of the bone
  37928. */
  37929. adjustRoll: number;
  37930. /**
  37931. * 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)
  37932. */
  37933. slerpAmount: number;
  37934. private _minYaw;
  37935. private _maxYaw;
  37936. private _minPitch;
  37937. private _maxPitch;
  37938. private _minYawSin;
  37939. private _minYawCos;
  37940. private _maxYawSin;
  37941. private _maxYawCos;
  37942. private _midYawConstraint;
  37943. private _minPitchTan;
  37944. private _maxPitchTan;
  37945. private _boneQuat;
  37946. private _slerping;
  37947. private _transformYawPitch;
  37948. private _transformYawPitchInv;
  37949. private _firstFrameSkipped;
  37950. private _yawRange;
  37951. private _fowardAxis;
  37952. /**
  37953. * Gets or sets the minimum yaw angle that the bone can look to
  37954. */
  37955. minYaw: number;
  37956. /**
  37957. * Gets or sets the maximum yaw angle that the bone can look to
  37958. */
  37959. maxYaw: number;
  37960. /**
  37961. * Gets or sets the minimum pitch angle that the bone can look to
  37962. */
  37963. minPitch: number;
  37964. /**
  37965. * Gets or sets the maximum pitch angle that the bone can look to
  37966. */
  37967. maxPitch: number;
  37968. /**
  37969. * Create a BoneLookController
  37970. * @param mesh the mesh that the bone belongs to
  37971. * @param bone the bone that will be looking to the target
  37972. * @param target the target Vector3 to look at
  37973. * @param options optional settings:
  37974. * * maxYaw: the maximum angle the bone will yaw to
  37975. * * minYaw: the minimum angle the bone will yaw to
  37976. * * maxPitch: the maximum angle the bone will pitch to
  37977. * * minPitch: the minimum angle the bone will yaw to
  37978. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37979. * * upAxis: the up axis of the coordinate system
  37980. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37981. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37982. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37983. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37984. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37985. * * adjustRoll: used to make an adjustment to the roll of the bone
  37986. **/
  37987. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37988. maxYaw?: number;
  37989. minYaw?: number;
  37990. maxPitch?: number;
  37991. minPitch?: number;
  37992. slerpAmount?: number;
  37993. upAxis?: Vector3;
  37994. upAxisSpace?: Space;
  37995. yawAxis?: Vector3;
  37996. pitchAxis?: Vector3;
  37997. adjustYaw?: number;
  37998. adjustPitch?: number;
  37999. adjustRoll?: number;
  38000. });
  38001. /**
  38002. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38003. */
  38004. update(): void;
  38005. private _getAngleDiff;
  38006. private _getAngleBetween;
  38007. private _isAngleBetween;
  38008. }
  38009. }
  38010. declare module "babylonjs/Bones/index" {
  38011. export * from "babylonjs/Bones/bone";
  38012. export * from "babylonjs/Bones/boneIKController";
  38013. export * from "babylonjs/Bones/boneLookController";
  38014. export * from "babylonjs/Bones/skeleton";
  38015. }
  38016. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38017. import { Nullable } from "babylonjs/types";
  38018. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38019. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38020. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38021. /**
  38022. * Manage the gamepad inputs to control an arc rotate camera.
  38023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38024. */
  38025. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38026. /**
  38027. * Defines the camera the input is attached to.
  38028. */
  38029. camera: ArcRotateCamera;
  38030. /**
  38031. * Defines the gamepad the input is gathering event from.
  38032. */
  38033. gamepad: Nullable<Gamepad>;
  38034. /**
  38035. * Defines the gamepad rotation sensiblity.
  38036. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38037. */
  38038. gamepadRotationSensibility: number;
  38039. /**
  38040. * Defines the gamepad move sensiblity.
  38041. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38042. */
  38043. gamepadMoveSensibility: number;
  38044. private _onGamepadConnectedObserver;
  38045. private _onGamepadDisconnectedObserver;
  38046. /**
  38047. * Attach the input controls to a specific dom element to get the input from.
  38048. * @param element Defines the element the controls should be listened from
  38049. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38050. */
  38051. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38052. /**
  38053. * Detach the current controls from the specified dom element.
  38054. * @param element Defines the element to stop listening the inputs from
  38055. */
  38056. detachControl(element: Nullable<HTMLElement>): void;
  38057. /**
  38058. * Update the current camera state depending on the inputs that have been used this frame.
  38059. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38060. */
  38061. checkInputs(): void;
  38062. /**
  38063. * Gets the class name of the current intput.
  38064. * @returns the class name
  38065. */
  38066. getClassName(): string;
  38067. /**
  38068. * Get the friendly name associated with the input class.
  38069. * @returns the input friendly name
  38070. */
  38071. getSimpleName(): string;
  38072. }
  38073. }
  38074. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38075. import { Nullable } from "babylonjs/types";
  38076. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38077. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38078. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38079. interface ArcRotateCameraInputsManager {
  38080. /**
  38081. * Add orientation input support to the input manager.
  38082. * @returns the current input manager
  38083. */
  38084. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38085. }
  38086. }
  38087. /**
  38088. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38090. */
  38091. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38092. /**
  38093. * Defines the camera the input is attached to.
  38094. */
  38095. camera: ArcRotateCamera;
  38096. /**
  38097. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38098. */
  38099. alphaCorrection: number;
  38100. /**
  38101. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38102. */
  38103. gammaCorrection: number;
  38104. private _alpha;
  38105. private _gamma;
  38106. private _dirty;
  38107. private _deviceOrientationHandler;
  38108. /**
  38109. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38110. */
  38111. constructor();
  38112. /**
  38113. * Attach the input controls to a specific dom element to get the input from.
  38114. * @param element Defines the element the controls should be listened from
  38115. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38116. */
  38117. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38118. /** @hidden */
  38119. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38120. /**
  38121. * Update the current camera state depending on the inputs that have been used this frame.
  38122. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38123. */
  38124. checkInputs(): void;
  38125. /**
  38126. * Detach the current controls from the specified dom element.
  38127. * @param element Defines the element to stop listening the inputs from
  38128. */
  38129. detachControl(element: Nullable<HTMLElement>): void;
  38130. /**
  38131. * Gets the class name of the current intput.
  38132. * @returns the class name
  38133. */
  38134. getClassName(): string;
  38135. /**
  38136. * Get the friendly name associated with the input class.
  38137. * @returns the input friendly name
  38138. */
  38139. getSimpleName(): string;
  38140. }
  38141. }
  38142. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38143. import { Nullable } from "babylonjs/types";
  38144. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38145. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38146. /**
  38147. * Listen to mouse events to control the camera.
  38148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38149. */
  38150. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38151. /**
  38152. * Defines the camera the input is attached to.
  38153. */
  38154. camera: FlyCamera;
  38155. /**
  38156. * Defines if touch is enabled. (Default is true.)
  38157. */
  38158. touchEnabled: boolean;
  38159. /**
  38160. * Defines the buttons associated with the input to handle camera rotation.
  38161. */
  38162. buttons: number[];
  38163. /**
  38164. * Assign buttons for Yaw control.
  38165. */
  38166. buttonsYaw: number[];
  38167. /**
  38168. * Assign buttons for Pitch control.
  38169. */
  38170. buttonsPitch: number[];
  38171. /**
  38172. * Assign buttons for Roll control.
  38173. */
  38174. buttonsRoll: number[];
  38175. /**
  38176. * Detect if any button is being pressed while mouse is moved.
  38177. * -1 = Mouse locked.
  38178. * 0 = Left button.
  38179. * 1 = Middle Button.
  38180. * 2 = Right Button.
  38181. */
  38182. activeButton: number;
  38183. /**
  38184. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38185. * Higher values reduce its sensitivity.
  38186. */
  38187. angularSensibility: number;
  38188. private _mousemoveCallback;
  38189. private _observer;
  38190. private _rollObserver;
  38191. private previousPosition;
  38192. private noPreventDefault;
  38193. private element;
  38194. /**
  38195. * Listen to mouse events to control the camera.
  38196. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38198. */
  38199. constructor(touchEnabled?: boolean);
  38200. /**
  38201. * Attach the mouse control to the HTML DOM element.
  38202. * @param element Defines the element that listens to the input events.
  38203. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38204. */
  38205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38206. /**
  38207. * Detach the current controls from the specified dom element.
  38208. * @param element Defines the element to stop listening the inputs from
  38209. */
  38210. detachControl(element: Nullable<HTMLElement>): void;
  38211. /**
  38212. * Gets the class name of the current input.
  38213. * @returns the class name.
  38214. */
  38215. getClassName(): string;
  38216. /**
  38217. * Get the friendly name associated with the input class.
  38218. * @returns the input's friendly name.
  38219. */
  38220. getSimpleName(): string;
  38221. private _pointerInput;
  38222. private _onMouseMove;
  38223. /**
  38224. * Rotate camera by mouse offset.
  38225. */
  38226. private rotateCamera;
  38227. }
  38228. }
  38229. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38230. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38231. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38232. /**
  38233. * Default Inputs manager for the FlyCamera.
  38234. * It groups all the default supported inputs for ease of use.
  38235. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38236. */
  38237. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38238. /**
  38239. * Instantiates a new FlyCameraInputsManager.
  38240. * @param camera Defines the camera the inputs belong to.
  38241. */
  38242. constructor(camera: FlyCamera);
  38243. /**
  38244. * Add keyboard input support to the input manager.
  38245. * @returns the new FlyCameraKeyboardMoveInput().
  38246. */
  38247. addKeyboard(): FlyCameraInputsManager;
  38248. /**
  38249. * Add mouse input support to the input manager.
  38250. * @param touchEnabled Enable touch screen support.
  38251. * @returns the new FlyCameraMouseInput().
  38252. */
  38253. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38254. }
  38255. }
  38256. declare module "babylonjs/Cameras/flyCamera" {
  38257. import { Scene } from "babylonjs/scene";
  38258. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38260. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38261. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38262. /**
  38263. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38264. * such as in a 3D Space Shooter or a Flight Simulator.
  38265. */
  38266. export class FlyCamera extends TargetCamera {
  38267. /**
  38268. * Define the collision ellipsoid of the camera.
  38269. * This is helpful for simulating a camera body, like a player's body.
  38270. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38271. */
  38272. ellipsoid: Vector3;
  38273. /**
  38274. * Define an offset for the position of the ellipsoid around the camera.
  38275. * This can be helpful if the camera is attached away from the player's body center,
  38276. * such as at its head.
  38277. */
  38278. ellipsoidOffset: Vector3;
  38279. /**
  38280. * Enable or disable collisions of the camera with the rest of the scene objects.
  38281. */
  38282. checkCollisions: boolean;
  38283. /**
  38284. * Enable or disable gravity on the camera.
  38285. */
  38286. applyGravity: boolean;
  38287. /**
  38288. * Define the current direction the camera is moving to.
  38289. */
  38290. cameraDirection: Vector3;
  38291. /**
  38292. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38293. * This overrides and empties cameraRotation.
  38294. */
  38295. rotationQuaternion: Quaternion;
  38296. /**
  38297. * Track Roll to maintain the wanted Rolling when looking around.
  38298. */
  38299. _trackRoll: number;
  38300. /**
  38301. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38302. */
  38303. rollCorrect: number;
  38304. /**
  38305. * Mimic a banked turn, Rolling the camera when Yawing.
  38306. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38307. */
  38308. bankedTurn: boolean;
  38309. /**
  38310. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38311. */
  38312. bankedTurnLimit: number;
  38313. /**
  38314. * Value of 0 disables the banked Roll.
  38315. * Value of 1 is equal to the Yaw angle in radians.
  38316. */
  38317. bankedTurnMultiplier: number;
  38318. /**
  38319. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38320. */
  38321. inputs: FlyCameraInputsManager;
  38322. /**
  38323. * Gets the input sensibility for mouse input.
  38324. * Higher values reduce sensitivity.
  38325. */
  38326. /**
  38327. * Sets the input sensibility for a mouse input.
  38328. * Higher values reduce sensitivity.
  38329. */
  38330. angularSensibility: number;
  38331. /**
  38332. * Get the keys for camera movement forward.
  38333. */
  38334. /**
  38335. * Set the keys for camera movement forward.
  38336. */
  38337. keysForward: number[];
  38338. /**
  38339. * Get the keys for camera movement backward.
  38340. */
  38341. keysBackward: number[];
  38342. /**
  38343. * Get the keys for camera movement up.
  38344. */
  38345. /**
  38346. * Set the keys for camera movement up.
  38347. */
  38348. keysUp: number[];
  38349. /**
  38350. * Get the keys for camera movement down.
  38351. */
  38352. /**
  38353. * Set the keys for camera movement down.
  38354. */
  38355. keysDown: number[];
  38356. /**
  38357. * Get the keys for camera movement left.
  38358. */
  38359. /**
  38360. * Set the keys for camera movement left.
  38361. */
  38362. keysLeft: number[];
  38363. /**
  38364. * Set the keys for camera movement right.
  38365. */
  38366. /**
  38367. * Set the keys for camera movement right.
  38368. */
  38369. keysRight: number[];
  38370. /**
  38371. * Event raised when the camera collides with a mesh in the scene.
  38372. */
  38373. onCollide: (collidedMesh: AbstractMesh) => void;
  38374. private _collider;
  38375. private _needMoveForGravity;
  38376. private _oldPosition;
  38377. private _diffPosition;
  38378. private _newPosition;
  38379. /** @hidden */
  38380. _localDirection: Vector3;
  38381. /** @hidden */
  38382. _transformedDirection: Vector3;
  38383. /**
  38384. * Instantiates a FlyCamera.
  38385. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38386. * such as in a 3D Space Shooter or a Flight Simulator.
  38387. * @param name Define the name of the camera in the scene.
  38388. * @param position Define the starting position of the camera in the scene.
  38389. * @param scene Define the scene the camera belongs to.
  38390. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38391. */
  38392. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38393. /**
  38394. * Attach a control to the HTML DOM element.
  38395. * @param element Defines the element that listens to the input events.
  38396. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38397. */
  38398. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38399. /**
  38400. * Detach a control from the HTML DOM element.
  38401. * The camera will stop reacting to that input.
  38402. * @param element Defines the element that listens to the input events.
  38403. */
  38404. detachControl(element: HTMLElement): void;
  38405. private _collisionMask;
  38406. /**
  38407. * Get the mask that the camera ignores in collision events.
  38408. */
  38409. /**
  38410. * Set the mask that the camera ignores in collision events.
  38411. */
  38412. collisionMask: number;
  38413. /** @hidden */
  38414. _collideWithWorld(displacement: Vector3): void;
  38415. /** @hidden */
  38416. private _onCollisionPositionChange;
  38417. /** @hidden */
  38418. _checkInputs(): void;
  38419. /** @hidden */
  38420. _decideIfNeedsToMove(): boolean;
  38421. /** @hidden */
  38422. _updatePosition(): void;
  38423. /**
  38424. * Restore the Roll to its target value at the rate specified.
  38425. * @param rate - Higher means slower restoring.
  38426. * @hidden
  38427. */
  38428. restoreRoll(rate: number): void;
  38429. /**
  38430. * Destroy the camera and release the current resources held by it.
  38431. */
  38432. dispose(): void;
  38433. /**
  38434. * Get the current object class name.
  38435. * @returns the class name.
  38436. */
  38437. getClassName(): string;
  38438. }
  38439. }
  38440. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38441. import { Nullable } from "babylonjs/types";
  38442. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38443. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38444. /**
  38445. * Listen to keyboard events to control the camera.
  38446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38447. */
  38448. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38449. /**
  38450. * Defines the camera the input is attached to.
  38451. */
  38452. camera: FlyCamera;
  38453. /**
  38454. * The list of keyboard keys used to control the forward move of the camera.
  38455. */
  38456. keysForward: number[];
  38457. /**
  38458. * The list of keyboard keys used to control the backward move of the camera.
  38459. */
  38460. keysBackward: number[];
  38461. /**
  38462. * The list of keyboard keys used to control the forward move of the camera.
  38463. */
  38464. keysUp: number[];
  38465. /**
  38466. * The list of keyboard keys used to control the backward move of the camera.
  38467. */
  38468. keysDown: number[];
  38469. /**
  38470. * The list of keyboard keys used to control the right strafe move of the camera.
  38471. */
  38472. keysRight: number[];
  38473. /**
  38474. * The list of keyboard keys used to control the left strafe move of the camera.
  38475. */
  38476. keysLeft: number[];
  38477. private _keys;
  38478. private _onCanvasBlurObserver;
  38479. private _onKeyboardObserver;
  38480. private _engine;
  38481. private _scene;
  38482. /**
  38483. * Attach the input controls to a specific dom element to get the input from.
  38484. * @param element Defines the element the controls should be listened from
  38485. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38486. */
  38487. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38488. /**
  38489. * Detach the current controls from the specified dom element.
  38490. * @param element Defines the element to stop listening the inputs from
  38491. */
  38492. detachControl(element: Nullable<HTMLElement>): void;
  38493. /**
  38494. * Gets the class name of the current intput.
  38495. * @returns the class name
  38496. */
  38497. getClassName(): string;
  38498. /** @hidden */
  38499. _onLostFocus(e: FocusEvent): void;
  38500. /**
  38501. * Get the friendly name associated with the input class.
  38502. * @returns the input friendly name
  38503. */
  38504. getSimpleName(): string;
  38505. /**
  38506. * Update the current camera state depending on the inputs that have been used this frame.
  38507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38508. */
  38509. checkInputs(): void;
  38510. }
  38511. }
  38512. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38513. import { Nullable } from "babylonjs/types";
  38514. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38515. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38516. /**
  38517. * Manage the mouse wheel inputs to control a follow camera.
  38518. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38519. */
  38520. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38521. /**
  38522. * Defines the camera the input is attached to.
  38523. */
  38524. camera: FollowCamera;
  38525. /**
  38526. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38527. */
  38528. axisControlRadius: boolean;
  38529. /**
  38530. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38531. */
  38532. axisControlHeight: boolean;
  38533. /**
  38534. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38535. */
  38536. axisControlRotation: boolean;
  38537. /**
  38538. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38539. * relation to mouseWheel events.
  38540. */
  38541. wheelPrecision: number;
  38542. /**
  38543. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38544. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38545. */
  38546. wheelDeltaPercentage: number;
  38547. private _wheel;
  38548. private _observer;
  38549. /**
  38550. * Attach the input controls to a specific dom element to get the input from.
  38551. * @param element Defines the element the controls should be listened from
  38552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38553. */
  38554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38555. /**
  38556. * Detach the current controls from the specified dom element.
  38557. * @param element Defines the element to stop listening the inputs from
  38558. */
  38559. detachControl(element: Nullable<HTMLElement>): void;
  38560. /**
  38561. * Gets the class name of the current intput.
  38562. * @returns the class name
  38563. */
  38564. getClassName(): string;
  38565. /**
  38566. * Get the friendly name associated with the input class.
  38567. * @returns the input friendly name
  38568. */
  38569. getSimpleName(): string;
  38570. }
  38571. }
  38572. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38573. import { Nullable } from "babylonjs/types";
  38574. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38575. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38576. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38577. /**
  38578. * Manage the pointers inputs to control an follow camera.
  38579. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38580. */
  38581. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38582. /**
  38583. * Defines the camera the input is attached to.
  38584. */
  38585. camera: FollowCamera;
  38586. /**
  38587. * Gets the class name of the current input.
  38588. * @returns the class name
  38589. */
  38590. getClassName(): string;
  38591. /**
  38592. * Defines the pointer angular sensibility along the X axis or how fast is
  38593. * the camera rotating.
  38594. * A negative number will reverse the axis direction.
  38595. */
  38596. angularSensibilityX: number;
  38597. /**
  38598. * Defines the pointer angular sensibility along the Y axis or how fast is
  38599. * the camera rotating.
  38600. * A negative number will reverse the axis direction.
  38601. */
  38602. angularSensibilityY: number;
  38603. /**
  38604. * Defines the pointer pinch precision or how fast is the camera zooming.
  38605. * A negative number will reverse the axis direction.
  38606. */
  38607. pinchPrecision: number;
  38608. /**
  38609. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38610. * from 0.
  38611. * It defines the percentage of current camera.radius to use as delta when
  38612. * pinch zoom is used.
  38613. */
  38614. pinchDeltaPercentage: number;
  38615. /**
  38616. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38617. */
  38618. axisXControlRadius: boolean;
  38619. /**
  38620. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38621. */
  38622. axisXControlHeight: boolean;
  38623. /**
  38624. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38625. */
  38626. axisXControlRotation: boolean;
  38627. /**
  38628. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38629. */
  38630. axisYControlRadius: boolean;
  38631. /**
  38632. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38633. */
  38634. axisYControlHeight: boolean;
  38635. /**
  38636. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38637. */
  38638. axisYControlRotation: boolean;
  38639. /**
  38640. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38641. */
  38642. axisPinchControlRadius: boolean;
  38643. /**
  38644. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38645. */
  38646. axisPinchControlHeight: boolean;
  38647. /**
  38648. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38649. */
  38650. axisPinchControlRotation: boolean;
  38651. /**
  38652. * Log error messages if basic misconfiguration has occurred.
  38653. */
  38654. warningEnable: boolean;
  38655. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38656. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38657. private _warningCounter;
  38658. private _warning;
  38659. }
  38660. }
  38661. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38662. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38663. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38664. /**
  38665. * Default Inputs manager for the FollowCamera.
  38666. * It groups all the default supported inputs for ease of use.
  38667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38668. */
  38669. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38670. /**
  38671. * Instantiates a new FollowCameraInputsManager.
  38672. * @param camera Defines the camera the inputs belong to
  38673. */
  38674. constructor(camera: FollowCamera);
  38675. /**
  38676. * Add keyboard input support to the input manager.
  38677. * @returns the current input manager
  38678. */
  38679. addKeyboard(): FollowCameraInputsManager;
  38680. /**
  38681. * Add mouse wheel input support to the input manager.
  38682. * @returns the current input manager
  38683. */
  38684. addMouseWheel(): FollowCameraInputsManager;
  38685. /**
  38686. * Add pointers input support to the input manager.
  38687. * @returns the current input manager
  38688. */
  38689. addPointers(): FollowCameraInputsManager;
  38690. /**
  38691. * Add orientation input support to the input manager.
  38692. * @returns the current input manager
  38693. */
  38694. addVRDeviceOrientation(): FollowCameraInputsManager;
  38695. }
  38696. }
  38697. declare module "babylonjs/Cameras/followCamera" {
  38698. import { Nullable } from "babylonjs/types";
  38699. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38700. import { Scene } from "babylonjs/scene";
  38701. import { Vector3 } from "babylonjs/Maths/math.vector";
  38702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38703. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38704. /**
  38705. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38706. * an arc rotate version arcFollowCamera are available.
  38707. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38708. */
  38709. export class FollowCamera extends TargetCamera {
  38710. /**
  38711. * Distance the follow camera should follow an object at
  38712. */
  38713. radius: number;
  38714. /**
  38715. * Minimum allowed distance of the camera to the axis of rotation
  38716. * (The camera can not get closer).
  38717. * This can help limiting how the Camera is able to move in the scene.
  38718. */
  38719. lowerRadiusLimit: Nullable<number>;
  38720. /**
  38721. * Maximum allowed distance of the camera to the axis of rotation
  38722. * (The camera can not get further).
  38723. * This can help limiting how the Camera is able to move in the scene.
  38724. */
  38725. upperRadiusLimit: Nullable<number>;
  38726. /**
  38727. * Define a rotation offset between the camera and the object it follows
  38728. */
  38729. rotationOffset: number;
  38730. /**
  38731. * Minimum allowed angle to camera position relative to target object.
  38732. * This can help limiting how the Camera is able to move in the scene.
  38733. */
  38734. lowerRotationOffsetLimit: Nullable<number>;
  38735. /**
  38736. * Maximum allowed angle to camera position relative to target object.
  38737. * This can help limiting how the Camera is able to move in the scene.
  38738. */
  38739. upperRotationOffsetLimit: Nullable<number>;
  38740. /**
  38741. * Define a height offset between the camera and the object it follows.
  38742. * It can help following an object from the top (like a car chaing a plane)
  38743. */
  38744. heightOffset: number;
  38745. /**
  38746. * Minimum allowed height of camera position relative to target object.
  38747. * This can help limiting how the Camera is able to move in the scene.
  38748. */
  38749. lowerHeightOffsetLimit: Nullable<number>;
  38750. /**
  38751. * Maximum allowed height of camera position relative to target object.
  38752. * This can help limiting how the Camera is able to move in the scene.
  38753. */
  38754. upperHeightOffsetLimit: Nullable<number>;
  38755. /**
  38756. * Define how fast the camera can accelerate to follow it s target.
  38757. */
  38758. cameraAcceleration: number;
  38759. /**
  38760. * Define the speed limit of the camera following an object.
  38761. */
  38762. maxCameraSpeed: number;
  38763. /**
  38764. * Define the target of the camera.
  38765. */
  38766. lockedTarget: Nullable<AbstractMesh>;
  38767. /**
  38768. * Defines the input associated with the camera.
  38769. */
  38770. inputs: FollowCameraInputsManager;
  38771. /**
  38772. * Instantiates the follow camera.
  38773. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38774. * @param name Define the name of the camera in the scene
  38775. * @param position Define the position of the camera
  38776. * @param scene Define the scene the camera belong to
  38777. * @param lockedTarget Define the target of the camera
  38778. */
  38779. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38780. private _follow;
  38781. /**
  38782. * Attached controls to the current camera.
  38783. * @param element Defines the element the controls should be listened from
  38784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38785. */
  38786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38787. /**
  38788. * Detach the current controls from the camera.
  38789. * The camera will stop reacting to inputs.
  38790. * @param element Defines the element to stop listening the inputs from
  38791. */
  38792. detachControl(element: HTMLElement): void;
  38793. /** @hidden */
  38794. _checkInputs(): void;
  38795. private _checkLimits;
  38796. /**
  38797. * Gets the camera class name.
  38798. * @returns the class name
  38799. */
  38800. getClassName(): string;
  38801. }
  38802. /**
  38803. * Arc Rotate version of the follow camera.
  38804. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38805. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38806. */
  38807. export class ArcFollowCamera extends TargetCamera {
  38808. /** The longitudinal angle of the camera */
  38809. alpha: number;
  38810. /** The latitudinal angle of the camera */
  38811. beta: number;
  38812. /** The radius of the camera from its target */
  38813. radius: number;
  38814. /** Define the camera target (the messh it should follow) */
  38815. target: Nullable<AbstractMesh>;
  38816. private _cartesianCoordinates;
  38817. /**
  38818. * Instantiates a new ArcFollowCamera
  38819. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38820. * @param name Define the name of the camera
  38821. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38822. * @param beta Define the rotation angle of the camera around the elevation axis
  38823. * @param radius Define the radius of the camera from its target point
  38824. * @param target Define the target of the camera
  38825. * @param scene Define the scene the camera belongs to
  38826. */
  38827. constructor(name: string,
  38828. /** The longitudinal angle of the camera */
  38829. alpha: number,
  38830. /** The latitudinal angle of the camera */
  38831. beta: number,
  38832. /** The radius of the camera from its target */
  38833. radius: number,
  38834. /** Define the camera target (the messh it should follow) */
  38835. target: Nullable<AbstractMesh>, scene: Scene);
  38836. private _follow;
  38837. /** @hidden */
  38838. _checkInputs(): void;
  38839. /**
  38840. * Returns the class name of the object.
  38841. * It is mostly used internally for serialization purposes.
  38842. */
  38843. getClassName(): string;
  38844. }
  38845. }
  38846. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38847. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38848. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38849. import { Nullable } from "babylonjs/types";
  38850. /**
  38851. * Manage the keyboard inputs to control the movement of a follow camera.
  38852. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38853. */
  38854. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38855. /**
  38856. * Defines the camera the input is attached to.
  38857. */
  38858. camera: FollowCamera;
  38859. /**
  38860. * Defines the list of key codes associated with the up action (increase heightOffset)
  38861. */
  38862. keysHeightOffsetIncr: number[];
  38863. /**
  38864. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38865. */
  38866. keysHeightOffsetDecr: number[];
  38867. /**
  38868. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38869. */
  38870. keysHeightOffsetModifierAlt: boolean;
  38871. /**
  38872. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38873. */
  38874. keysHeightOffsetModifierCtrl: boolean;
  38875. /**
  38876. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38877. */
  38878. keysHeightOffsetModifierShift: boolean;
  38879. /**
  38880. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38881. */
  38882. keysRotationOffsetIncr: number[];
  38883. /**
  38884. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38885. */
  38886. keysRotationOffsetDecr: number[];
  38887. /**
  38888. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38889. */
  38890. keysRotationOffsetModifierAlt: boolean;
  38891. /**
  38892. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38893. */
  38894. keysRotationOffsetModifierCtrl: boolean;
  38895. /**
  38896. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38897. */
  38898. keysRotationOffsetModifierShift: boolean;
  38899. /**
  38900. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38901. */
  38902. keysRadiusIncr: number[];
  38903. /**
  38904. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38905. */
  38906. keysRadiusDecr: number[];
  38907. /**
  38908. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38909. */
  38910. keysRadiusModifierAlt: boolean;
  38911. /**
  38912. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38913. */
  38914. keysRadiusModifierCtrl: boolean;
  38915. /**
  38916. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38917. */
  38918. keysRadiusModifierShift: boolean;
  38919. /**
  38920. * Defines the rate of change of heightOffset.
  38921. */
  38922. heightSensibility: number;
  38923. /**
  38924. * Defines the rate of change of rotationOffset.
  38925. */
  38926. rotationSensibility: number;
  38927. /**
  38928. * Defines the rate of change of radius.
  38929. */
  38930. radiusSensibility: number;
  38931. private _keys;
  38932. private _ctrlPressed;
  38933. private _altPressed;
  38934. private _shiftPressed;
  38935. private _onCanvasBlurObserver;
  38936. private _onKeyboardObserver;
  38937. private _engine;
  38938. private _scene;
  38939. /**
  38940. * Attach the input controls to a specific dom element to get the input from.
  38941. * @param element Defines the element the controls should be listened from
  38942. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38943. */
  38944. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38945. /**
  38946. * Detach the current controls from the specified dom element.
  38947. * @param element Defines the element to stop listening the inputs from
  38948. */
  38949. detachControl(element: Nullable<HTMLElement>): void;
  38950. /**
  38951. * Update the current camera state depending on the inputs that have been used this frame.
  38952. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38953. */
  38954. checkInputs(): void;
  38955. /**
  38956. * Gets the class name of the current input.
  38957. * @returns the class name
  38958. */
  38959. getClassName(): string;
  38960. /**
  38961. * Get the friendly name associated with the input class.
  38962. * @returns the input friendly name
  38963. */
  38964. getSimpleName(): string;
  38965. /**
  38966. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38967. * allow modification of the heightOffset value.
  38968. */
  38969. private _modifierHeightOffset;
  38970. /**
  38971. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38972. * allow modification of the rotationOffset value.
  38973. */
  38974. private _modifierRotationOffset;
  38975. /**
  38976. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38977. * allow modification of the radius value.
  38978. */
  38979. private _modifierRadius;
  38980. }
  38981. }
  38982. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38983. import { Nullable } from "babylonjs/types";
  38984. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38985. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38986. import { Observable } from "babylonjs/Misc/observable";
  38987. module "babylonjs/Cameras/freeCameraInputsManager" {
  38988. interface FreeCameraInputsManager {
  38989. /**
  38990. * @hidden
  38991. */
  38992. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38993. /**
  38994. * Add orientation input support to the input manager.
  38995. * @returns the current input manager
  38996. */
  38997. addDeviceOrientation(): FreeCameraInputsManager;
  38998. }
  38999. }
  39000. /**
  39001. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39002. * Screen rotation is taken into account.
  39003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39004. */
  39005. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39006. private _camera;
  39007. private _screenOrientationAngle;
  39008. private _constantTranform;
  39009. private _screenQuaternion;
  39010. private _alpha;
  39011. private _beta;
  39012. private _gamma;
  39013. /**
  39014. * Can be used to detect if a device orientation sensor is availible on a device
  39015. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39016. * @returns a promise that will resolve on orientation change
  39017. */
  39018. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39019. /**
  39020. * @hidden
  39021. */
  39022. _onDeviceOrientationChangedObservable: Observable<void>;
  39023. /**
  39024. * Instantiates a new input
  39025. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39026. */
  39027. constructor();
  39028. /**
  39029. * Define the camera controlled by the input.
  39030. */
  39031. camera: FreeCamera;
  39032. /**
  39033. * Attach the input controls to a specific dom element to get the input from.
  39034. * @param element Defines the element the controls should be listened from
  39035. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39036. */
  39037. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39038. private _orientationChanged;
  39039. private _deviceOrientation;
  39040. /**
  39041. * Detach the current controls from the specified dom element.
  39042. * @param element Defines the element to stop listening the inputs from
  39043. */
  39044. detachControl(element: Nullable<HTMLElement>): void;
  39045. /**
  39046. * Update the current camera state depending on the inputs that have been used this frame.
  39047. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39048. */
  39049. checkInputs(): void;
  39050. /**
  39051. * Gets the class name of the current intput.
  39052. * @returns the class name
  39053. */
  39054. getClassName(): string;
  39055. /**
  39056. * Get the friendly name associated with the input class.
  39057. * @returns the input friendly name
  39058. */
  39059. getSimpleName(): string;
  39060. }
  39061. }
  39062. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39063. import { Nullable } from "babylonjs/types";
  39064. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39065. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39066. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39067. /**
  39068. * Manage the gamepad inputs to control a free camera.
  39069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39070. */
  39071. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39072. /**
  39073. * Define the camera the input is attached to.
  39074. */
  39075. camera: FreeCamera;
  39076. /**
  39077. * Define the Gamepad controlling the input
  39078. */
  39079. gamepad: Nullable<Gamepad>;
  39080. /**
  39081. * Defines the gamepad rotation sensiblity.
  39082. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39083. */
  39084. gamepadAngularSensibility: number;
  39085. /**
  39086. * Defines the gamepad move sensiblity.
  39087. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39088. */
  39089. gamepadMoveSensibility: number;
  39090. private _onGamepadConnectedObserver;
  39091. private _onGamepadDisconnectedObserver;
  39092. private _cameraTransform;
  39093. private _deltaTransform;
  39094. private _vector3;
  39095. private _vector2;
  39096. /**
  39097. * Attach the input controls to a specific dom element to get the input from.
  39098. * @param element Defines the element the controls should be listened from
  39099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39100. */
  39101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39102. /**
  39103. * Detach the current controls from the specified dom element.
  39104. * @param element Defines the element to stop listening the inputs from
  39105. */
  39106. detachControl(element: Nullable<HTMLElement>): void;
  39107. /**
  39108. * Update the current camera state depending on the inputs that have been used this frame.
  39109. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39110. */
  39111. checkInputs(): void;
  39112. /**
  39113. * Gets the class name of the current intput.
  39114. * @returns the class name
  39115. */
  39116. getClassName(): string;
  39117. /**
  39118. * Get the friendly name associated with the input class.
  39119. * @returns the input friendly name
  39120. */
  39121. getSimpleName(): string;
  39122. }
  39123. }
  39124. declare module "babylonjs/Misc/virtualJoystick" {
  39125. import { Nullable } from "babylonjs/types";
  39126. import { Vector3 } from "babylonjs/Maths/math.vector";
  39127. /**
  39128. * Defines the potential axis of a Joystick
  39129. */
  39130. export enum JoystickAxis {
  39131. /** X axis */
  39132. X = 0,
  39133. /** Y axis */
  39134. Y = 1,
  39135. /** Z axis */
  39136. Z = 2
  39137. }
  39138. /**
  39139. * Class used to define virtual joystick (used in touch mode)
  39140. */
  39141. export class VirtualJoystick {
  39142. /**
  39143. * Gets or sets a boolean indicating that left and right values must be inverted
  39144. */
  39145. reverseLeftRight: boolean;
  39146. /**
  39147. * Gets or sets a boolean indicating that up and down values must be inverted
  39148. */
  39149. reverseUpDown: boolean;
  39150. /**
  39151. * Gets the offset value for the position (ie. the change of the position value)
  39152. */
  39153. deltaPosition: Vector3;
  39154. /**
  39155. * Gets a boolean indicating if the virtual joystick was pressed
  39156. */
  39157. pressed: boolean;
  39158. /**
  39159. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39160. */
  39161. static Canvas: Nullable<HTMLCanvasElement>;
  39162. private static _globalJoystickIndex;
  39163. private static vjCanvasContext;
  39164. private static vjCanvasWidth;
  39165. private static vjCanvasHeight;
  39166. private static halfWidth;
  39167. private _action;
  39168. private _axisTargetedByLeftAndRight;
  39169. private _axisTargetedByUpAndDown;
  39170. private _joystickSensibility;
  39171. private _inversedSensibility;
  39172. private _joystickPointerID;
  39173. private _joystickColor;
  39174. private _joystickPointerPos;
  39175. private _joystickPreviousPointerPos;
  39176. private _joystickPointerStartPos;
  39177. private _deltaJoystickVector;
  39178. private _leftJoystick;
  39179. private _touches;
  39180. private _onPointerDownHandlerRef;
  39181. private _onPointerMoveHandlerRef;
  39182. private _onPointerUpHandlerRef;
  39183. private _onResize;
  39184. /**
  39185. * Creates a new virtual joystick
  39186. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39187. */
  39188. constructor(leftJoystick?: boolean);
  39189. /**
  39190. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39191. * @param newJoystickSensibility defines the new sensibility
  39192. */
  39193. setJoystickSensibility(newJoystickSensibility: number): void;
  39194. private _onPointerDown;
  39195. private _onPointerMove;
  39196. private _onPointerUp;
  39197. /**
  39198. * Change the color of the virtual joystick
  39199. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39200. */
  39201. setJoystickColor(newColor: string): void;
  39202. /**
  39203. * Defines a callback to call when the joystick is touched
  39204. * @param action defines the callback
  39205. */
  39206. setActionOnTouch(action: () => any): void;
  39207. /**
  39208. * Defines which axis you'd like to control for left & right
  39209. * @param axis defines the axis to use
  39210. */
  39211. setAxisForLeftRight(axis: JoystickAxis): void;
  39212. /**
  39213. * Defines which axis you'd like to control for up & down
  39214. * @param axis defines the axis to use
  39215. */
  39216. setAxisForUpDown(axis: JoystickAxis): void;
  39217. private _drawVirtualJoystick;
  39218. /**
  39219. * Release internal HTML canvas
  39220. */
  39221. releaseCanvas(): void;
  39222. }
  39223. }
  39224. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39225. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39226. import { Nullable } from "babylonjs/types";
  39227. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39228. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39229. module "babylonjs/Cameras/freeCameraInputsManager" {
  39230. interface FreeCameraInputsManager {
  39231. /**
  39232. * Add virtual joystick input support to the input manager.
  39233. * @returns the current input manager
  39234. */
  39235. addVirtualJoystick(): FreeCameraInputsManager;
  39236. }
  39237. }
  39238. /**
  39239. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39240. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39241. */
  39242. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39243. /**
  39244. * Defines the camera the input is attached to.
  39245. */
  39246. camera: FreeCamera;
  39247. private _leftjoystick;
  39248. private _rightjoystick;
  39249. /**
  39250. * Gets the left stick of the virtual joystick.
  39251. * @returns The virtual Joystick
  39252. */
  39253. getLeftJoystick(): VirtualJoystick;
  39254. /**
  39255. * Gets the right stick of the virtual joystick.
  39256. * @returns The virtual Joystick
  39257. */
  39258. getRightJoystick(): VirtualJoystick;
  39259. /**
  39260. * Update the current camera state depending on the inputs that have been used this frame.
  39261. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39262. */
  39263. checkInputs(): void;
  39264. /**
  39265. * Attach the input controls to a specific dom element to get the input from.
  39266. * @param element Defines the element the controls should be listened from
  39267. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39268. */
  39269. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39270. /**
  39271. * Detach the current controls from the specified dom element.
  39272. * @param element Defines the element to stop listening the inputs from
  39273. */
  39274. detachControl(element: Nullable<HTMLElement>): void;
  39275. /**
  39276. * Gets the class name of the current intput.
  39277. * @returns the class name
  39278. */
  39279. getClassName(): string;
  39280. /**
  39281. * Get the friendly name associated with the input class.
  39282. * @returns the input friendly name
  39283. */
  39284. getSimpleName(): string;
  39285. }
  39286. }
  39287. declare module "babylonjs/Cameras/Inputs/index" {
  39288. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39289. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39290. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39291. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39292. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39293. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39294. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39295. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39296. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39297. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39298. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39299. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39300. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39301. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39302. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39303. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39304. }
  39305. declare module "babylonjs/Cameras/touchCamera" {
  39306. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39307. import { Scene } from "babylonjs/scene";
  39308. import { Vector3 } from "babylonjs/Maths/math.vector";
  39309. /**
  39310. * This represents a FPS type of camera controlled by touch.
  39311. * This is like a universal camera minus the Gamepad controls.
  39312. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39313. */
  39314. export class TouchCamera extends FreeCamera {
  39315. /**
  39316. * Defines the touch sensibility for rotation.
  39317. * The higher the faster.
  39318. */
  39319. touchAngularSensibility: number;
  39320. /**
  39321. * Defines the touch sensibility for move.
  39322. * The higher the faster.
  39323. */
  39324. touchMoveSensibility: number;
  39325. /**
  39326. * Instantiates a new touch camera.
  39327. * This represents a FPS type of camera controlled by touch.
  39328. * This is like a universal camera minus the Gamepad controls.
  39329. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39330. * @param name Define the name of the camera in the scene
  39331. * @param position Define the start position of the camera in the scene
  39332. * @param scene Define the scene the camera belongs to
  39333. */
  39334. constructor(name: string, position: Vector3, scene: Scene);
  39335. /**
  39336. * Gets the current object class name.
  39337. * @return the class name
  39338. */
  39339. getClassName(): string;
  39340. /** @hidden */
  39341. _setupInputs(): void;
  39342. }
  39343. }
  39344. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39345. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39346. import { Scene } from "babylonjs/scene";
  39347. import { Vector3 } from "babylonjs/Maths/math.vector";
  39348. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39349. import { Axis } from "babylonjs/Maths/math.axis";
  39350. /**
  39351. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39352. * being tilted forward or back and left or right.
  39353. */
  39354. export class DeviceOrientationCamera extends FreeCamera {
  39355. private _initialQuaternion;
  39356. private _quaternionCache;
  39357. private _tmpDragQuaternion;
  39358. /**
  39359. * Creates a new device orientation camera
  39360. * @param name The name of the camera
  39361. * @param position The start position camera
  39362. * @param scene The scene the camera belongs to
  39363. */
  39364. constructor(name: string, position: Vector3, scene: Scene);
  39365. /**
  39366. * @hidden
  39367. * Disabled pointer input on first orientation sensor update (Default: true)
  39368. */
  39369. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39370. private _dragFactor;
  39371. /**
  39372. * Enabled turning on the y axis when the orientation sensor is active
  39373. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39374. */
  39375. enableHorizontalDragging(dragFactor?: number): void;
  39376. /**
  39377. * Gets the current instance class name ("DeviceOrientationCamera").
  39378. * This helps avoiding instanceof at run time.
  39379. * @returns the class name
  39380. */
  39381. getClassName(): string;
  39382. /**
  39383. * @hidden
  39384. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39385. */
  39386. _checkInputs(): void;
  39387. /**
  39388. * Reset the camera to its default orientation on the specified axis only.
  39389. * @param axis The axis to reset
  39390. */
  39391. resetToCurrentRotation(axis?: Axis): void;
  39392. }
  39393. }
  39394. declare module "babylonjs/Gamepads/xboxGamepad" {
  39395. import { Observable } from "babylonjs/Misc/observable";
  39396. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39397. /**
  39398. * Defines supported buttons for XBox360 compatible gamepads
  39399. */
  39400. export enum Xbox360Button {
  39401. /** A */
  39402. A = 0,
  39403. /** B */
  39404. B = 1,
  39405. /** X */
  39406. X = 2,
  39407. /** Y */
  39408. Y = 3,
  39409. /** Start */
  39410. Start = 4,
  39411. /** Back */
  39412. Back = 5,
  39413. /** Left button */
  39414. LB = 6,
  39415. /** Right button */
  39416. RB = 7,
  39417. /** Left stick */
  39418. LeftStick = 8,
  39419. /** Right stick */
  39420. RightStick = 9
  39421. }
  39422. /** Defines values for XBox360 DPad */
  39423. export enum Xbox360Dpad {
  39424. /** Up */
  39425. Up = 0,
  39426. /** Down */
  39427. Down = 1,
  39428. /** Left */
  39429. Left = 2,
  39430. /** Right */
  39431. Right = 3
  39432. }
  39433. /**
  39434. * Defines a XBox360 gamepad
  39435. */
  39436. export class Xbox360Pad extends Gamepad {
  39437. private _leftTrigger;
  39438. private _rightTrigger;
  39439. private _onlefttriggerchanged;
  39440. private _onrighttriggerchanged;
  39441. private _onbuttondown;
  39442. private _onbuttonup;
  39443. private _ondpaddown;
  39444. private _ondpadup;
  39445. /** Observable raised when a button is pressed */
  39446. onButtonDownObservable: Observable<Xbox360Button>;
  39447. /** Observable raised when a button is released */
  39448. onButtonUpObservable: Observable<Xbox360Button>;
  39449. /** Observable raised when a pad is pressed */
  39450. onPadDownObservable: Observable<Xbox360Dpad>;
  39451. /** Observable raised when a pad is released */
  39452. onPadUpObservable: Observable<Xbox360Dpad>;
  39453. private _buttonA;
  39454. private _buttonB;
  39455. private _buttonX;
  39456. private _buttonY;
  39457. private _buttonBack;
  39458. private _buttonStart;
  39459. private _buttonLB;
  39460. private _buttonRB;
  39461. private _buttonLeftStick;
  39462. private _buttonRightStick;
  39463. private _dPadUp;
  39464. private _dPadDown;
  39465. private _dPadLeft;
  39466. private _dPadRight;
  39467. private _isXboxOnePad;
  39468. /**
  39469. * Creates a new XBox360 gamepad object
  39470. * @param id defines the id of this gamepad
  39471. * @param index defines its index
  39472. * @param gamepad defines the internal HTML gamepad object
  39473. * @param xboxOne defines if it is a XBox One gamepad
  39474. */
  39475. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39476. /**
  39477. * Defines the callback to call when left trigger is pressed
  39478. * @param callback defines the callback to use
  39479. */
  39480. onlefttriggerchanged(callback: (value: number) => void): void;
  39481. /**
  39482. * Defines the callback to call when right trigger is pressed
  39483. * @param callback defines the callback to use
  39484. */
  39485. onrighttriggerchanged(callback: (value: number) => void): void;
  39486. /**
  39487. * Gets the left trigger value
  39488. */
  39489. /**
  39490. * Sets the left trigger value
  39491. */
  39492. leftTrigger: number;
  39493. /**
  39494. * Gets the right trigger value
  39495. */
  39496. /**
  39497. * Sets the right trigger value
  39498. */
  39499. rightTrigger: number;
  39500. /**
  39501. * Defines the callback to call when a button is pressed
  39502. * @param callback defines the callback to use
  39503. */
  39504. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39505. /**
  39506. * Defines the callback to call when a button is released
  39507. * @param callback defines the callback to use
  39508. */
  39509. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39510. /**
  39511. * Defines the callback to call when a pad is pressed
  39512. * @param callback defines the callback to use
  39513. */
  39514. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39515. /**
  39516. * Defines the callback to call when a pad is released
  39517. * @param callback defines the callback to use
  39518. */
  39519. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39520. private _setButtonValue;
  39521. private _setDPadValue;
  39522. /**
  39523. * Gets the value of the `A` button
  39524. */
  39525. /**
  39526. * Sets the value of the `A` button
  39527. */
  39528. buttonA: number;
  39529. /**
  39530. * Gets the value of the `B` button
  39531. */
  39532. /**
  39533. * Sets the value of the `B` button
  39534. */
  39535. buttonB: number;
  39536. /**
  39537. * Gets the value of the `X` button
  39538. */
  39539. /**
  39540. * Sets the value of the `X` button
  39541. */
  39542. buttonX: number;
  39543. /**
  39544. * Gets the value of the `Y` button
  39545. */
  39546. /**
  39547. * Sets the value of the `Y` button
  39548. */
  39549. buttonY: number;
  39550. /**
  39551. * Gets the value of the `Start` button
  39552. */
  39553. /**
  39554. * Sets the value of the `Start` button
  39555. */
  39556. buttonStart: number;
  39557. /**
  39558. * Gets the value of the `Back` button
  39559. */
  39560. /**
  39561. * Sets the value of the `Back` button
  39562. */
  39563. buttonBack: number;
  39564. /**
  39565. * Gets the value of the `Left` button
  39566. */
  39567. /**
  39568. * Sets the value of the `Left` button
  39569. */
  39570. buttonLB: number;
  39571. /**
  39572. * Gets the value of the `Right` button
  39573. */
  39574. /**
  39575. * Sets the value of the `Right` button
  39576. */
  39577. buttonRB: number;
  39578. /**
  39579. * Gets the value of the Left joystick
  39580. */
  39581. /**
  39582. * Sets the value of the Left joystick
  39583. */
  39584. buttonLeftStick: number;
  39585. /**
  39586. * Gets the value of the Right joystick
  39587. */
  39588. /**
  39589. * Sets the value of the Right joystick
  39590. */
  39591. buttonRightStick: number;
  39592. /**
  39593. * Gets the value of D-pad up
  39594. */
  39595. /**
  39596. * Sets the value of D-pad up
  39597. */
  39598. dPadUp: number;
  39599. /**
  39600. * Gets the value of D-pad down
  39601. */
  39602. /**
  39603. * Sets the value of D-pad down
  39604. */
  39605. dPadDown: number;
  39606. /**
  39607. * Gets the value of D-pad left
  39608. */
  39609. /**
  39610. * Sets the value of D-pad left
  39611. */
  39612. dPadLeft: number;
  39613. /**
  39614. * Gets the value of D-pad right
  39615. */
  39616. /**
  39617. * Sets the value of D-pad right
  39618. */
  39619. dPadRight: number;
  39620. /**
  39621. * Force the gamepad to synchronize with device values
  39622. */
  39623. update(): void;
  39624. /**
  39625. * Disposes the gamepad
  39626. */
  39627. dispose(): void;
  39628. }
  39629. }
  39630. declare module "babylonjs/Gamepads/gamepadManager" {
  39631. import { Observable } from "babylonjs/Misc/observable";
  39632. import { Nullable } from "babylonjs/types";
  39633. import { Scene } from "babylonjs/scene";
  39634. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39635. /**
  39636. * Manager for handling gamepads
  39637. */
  39638. export class GamepadManager {
  39639. private _scene?;
  39640. private _babylonGamepads;
  39641. private _oneGamepadConnected;
  39642. /** @hidden */
  39643. _isMonitoring: boolean;
  39644. private _gamepadEventSupported;
  39645. private _gamepadSupport;
  39646. /**
  39647. * observable to be triggered when the gamepad controller has been connected
  39648. */
  39649. onGamepadConnectedObservable: Observable<Gamepad>;
  39650. /**
  39651. * observable to be triggered when the gamepad controller has been disconnected
  39652. */
  39653. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39654. private _onGamepadConnectedEvent;
  39655. private _onGamepadDisconnectedEvent;
  39656. /**
  39657. * Initializes the gamepad manager
  39658. * @param _scene BabylonJS scene
  39659. */
  39660. constructor(_scene?: Scene | undefined);
  39661. /**
  39662. * The gamepads in the game pad manager
  39663. */
  39664. readonly gamepads: Gamepad[];
  39665. /**
  39666. * Get the gamepad controllers based on type
  39667. * @param type The type of gamepad controller
  39668. * @returns Nullable gamepad
  39669. */
  39670. getGamepadByType(type?: number): Nullable<Gamepad>;
  39671. /**
  39672. * Disposes the gamepad manager
  39673. */
  39674. dispose(): void;
  39675. private _addNewGamepad;
  39676. private _startMonitoringGamepads;
  39677. private _stopMonitoringGamepads;
  39678. /** @hidden */
  39679. _checkGamepadsStatus(): void;
  39680. private _updateGamepadObjects;
  39681. }
  39682. }
  39683. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39684. import { Nullable } from "babylonjs/types";
  39685. import { Scene } from "babylonjs/scene";
  39686. import { ISceneComponent } from "babylonjs/sceneComponent";
  39687. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39688. module "babylonjs/scene" {
  39689. interface Scene {
  39690. /** @hidden */
  39691. _gamepadManager: Nullable<GamepadManager>;
  39692. /**
  39693. * Gets the gamepad manager associated with the scene
  39694. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39695. */
  39696. gamepadManager: GamepadManager;
  39697. }
  39698. }
  39699. module "babylonjs/Cameras/freeCameraInputsManager" {
  39700. /**
  39701. * Interface representing a free camera inputs manager
  39702. */
  39703. interface FreeCameraInputsManager {
  39704. /**
  39705. * Adds gamepad input support to the FreeCameraInputsManager.
  39706. * @returns the FreeCameraInputsManager
  39707. */
  39708. addGamepad(): FreeCameraInputsManager;
  39709. }
  39710. }
  39711. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39712. /**
  39713. * Interface representing an arc rotate camera inputs manager
  39714. */
  39715. interface ArcRotateCameraInputsManager {
  39716. /**
  39717. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39718. * @returns the camera inputs manager
  39719. */
  39720. addGamepad(): ArcRotateCameraInputsManager;
  39721. }
  39722. }
  39723. /**
  39724. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39725. */
  39726. export class GamepadSystemSceneComponent implements ISceneComponent {
  39727. /**
  39728. * The component name helpfull to identify the component in the list of scene components.
  39729. */
  39730. readonly name: string;
  39731. /**
  39732. * The scene the component belongs to.
  39733. */
  39734. scene: Scene;
  39735. /**
  39736. * Creates a new instance of the component for the given scene
  39737. * @param scene Defines the scene to register the component in
  39738. */
  39739. constructor(scene: Scene);
  39740. /**
  39741. * Registers the component in a given scene
  39742. */
  39743. register(): void;
  39744. /**
  39745. * Rebuilds the elements related to this component in case of
  39746. * context lost for instance.
  39747. */
  39748. rebuild(): void;
  39749. /**
  39750. * Disposes the component and the associated ressources
  39751. */
  39752. dispose(): void;
  39753. private _beforeCameraUpdate;
  39754. }
  39755. }
  39756. declare module "babylonjs/Cameras/universalCamera" {
  39757. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39758. import { Scene } from "babylonjs/scene";
  39759. import { Vector3 } from "babylonjs/Maths/math.vector";
  39760. import "babylonjs/Gamepads/gamepadSceneComponent";
  39761. /**
  39762. * 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,
  39763. * which still works and will still be found in many Playgrounds.
  39764. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39765. */
  39766. export class UniversalCamera extends TouchCamera {
  39767. /**
  39768. * Defines the gamepad rotation sensiblity.
  39769. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39770. */
  39771. gamepadAngularSensibility: number;
  39772. /**
  39773. * Defines the gamepad move sensiblity.
  39774. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39775. */
  39776. gamepadMoveSensibility: number;
  39777. /**
  39778. * 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,
  39779. * which still works and will still be found in many Playgrounds.
  39780. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39781. * @param name Define the name of the camera in the scene
  39782. * @param position Define the start position of the camera in the scene
  39783. * @param scene Define the scene the camera belongs to
  39784. */
  39785. constructor(name: string, position: Vector3, scene: Scene);
  39786. /**
  39787. * Gets the current object class name.
  39788. * @return the class name
  39789. */
  39790. getClassName(): string;
  39791. }
  39792. }
  39793. declare module "babylonjs/Cameras/gamepadCamera" {
  39794. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39795. import { Scene } from "babylonjs/scene";
  39796. import { Vector3 } from "babylonjs/Maths/math.vector";
  39797. /**
  39798. * This represents a FPS type of camera. This is only here for back compat purpose.
  39799. * Please use the UniversalCamera instead as both are identical.
  39800. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39801. */
  39802. export class GamepadCamera extends UniversalCamera {
  39803. /**
  39804. * Instantiates a new Gamepad Camera
  39805. * This represents a FPS type of camera. This is only here for back compat purpose.
  39806. * Please use the UniversalCamera instead as both are identical.
  39807. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39808. * @param name Define the name of the camera in the scene
  39809. * @param position Define the start position of the camera in the scene
  39810. * @param scene Define the scene the camera belongs to
  39811. */
  39812. constructor(name: string, position: Vector3, scene: Scene);
  39813. /**
  39814. * Gets the current object class name.
  39815. * @return the class name
  39816. */
  39817. getClassName(): string;
  39818. }
  39819. }
  39820. declare module "babylonjs/Shaders/pass.fragment" {
  39821. /** @hidden */
  39822. export var passPixelShader: {
  39823. name: string;
  39824. shader: string;
  39825. };
  39826. }
  39827. declare module "babylonjs/Shaders/passCube.fragment" {
  39828. /** @hidden */
  39829. export var passCubePixelShader: {
  39830. name: string;
  39831. shader: string;
  39832. };
  39833. }
  39834. declare module "babylonjs/PostProcesses/passPostProcess" {
  39835. import { Nullable } from "babylonjs/types";
  39836. import { Camera } from "babylonjs/Cameras/camera";
  39837. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39838. import { Engine } from "babylonjs/Engines/engine";
  39839. import "babylonjs/Shaders/pass.fragment";
  39840. import "babylonjs/Shaders/passCube.fragment";
  39841. /**
  39842. * PassPostProcess which produces an output the same as it's input
  39843. */
  39844. export class PassPostProcess extends PostProcess {
  39845. /**
  39846. * Creates the PassPostProcess
  39847. * @param name The name of the effect.
  39848. * @param options The required width/height ratio to downsize to before computing the render pass.
  39849. * @param camera The camera to apply the render pass to.
  39850. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39851. * @param engine The engine which the post process will be applied. (default: current engine)
  39852. * @param reusable If the post process can be reused on the same frame. (default: false)
  39853. * @param textureType The type of texture to be used when performing the post processing.
  39854. * @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)
  39855. */
  39856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39857. }
  39858. /**
  39859. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39860. */
  39861. export class PassCubePostProcess extends PostProcess {
  39862. private _face;
  39863. /**
  39864. * Gets or sets the cube face to display.
  39865. * * 0 is +X
  39866. * * 1 is -X
  39867. * * 2 is +Y
  39868. * * 3 is -Y
  39869. * * 4 is +Z
  39870. * * 5 is -Z
  39871. */
  39872. face: number;
  39873. /**
  39874. * Creates the PassCubePostProcess
  39875. * @param name The name of the effect.
  39876. * @param options The required width/height ratio to downsize to before computing the render pass.
  39877. * @param camera The camera to apply the render pass to.
  39878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39879. * @param engine The engine which the post process will be applied. (default: current engine)
  39880. * @param reusable If the post process can be reused on the same frame. (default: false)
  39881. * @param textureType The type of texture to be used when performing the post processing.
  39882. * @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)
  39883. */
  39884. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39885. }
  39886. }
  39887. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39888. /** @hidden */
  39889. export var anaglyphPixelShader: {
  39890. name: string;
  39891. shader: string;
  39892. };
  39893. }
  39894. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39895. import { Engine } from "babylonjs/Engines/engine";
  39896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39897. import { Camera } from "babylonjs/Cameras/camera";
  39898. import "babylonjs/Shaders/anaglyph.fragment";
  39899. /**
  39900. * Postprocess used to generate anaglyphic rendering
  39901. */
  39902. export class AnaglyphPostProcess extends PostProcess {
  39903. private _passedProcess;
  39904. /**
  39905. * Creates a new AnaglyphPostProcess
  39906. * @param name defines postprocess name
  39907. * @param options defines creation options or target ratio scale
  39908. * @param rigCameras defines cameras using this postprocess
  39909. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39910. * @param engine defines hosting engine
  39911. * @param reusable defines if the postprocess will be reused multiple times per frame
  39912. */
  39913. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39914. }
  39915. }
  39916. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39917. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39918. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39919. import { Scene } from "babylonjs/scene";
  39920. import { Vector3 } from "babylonjs/Maths/math.vector";
  39921. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39922. /**
  39923. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39924. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39925. */
  39926. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39927. /**
  39928. * Creates a new AnaglyphArcRotateCamera
  39929. * @param name defines camera name
  39930. * @param alpha defines alpha angle (in radians)
  39931. * @param beta defines beta angle (in radians)
  39932. * @param radius defines radius
  39933. * @param target defines camera target
  39934. * @param interaxialDistance defines distance between each color axis
  39935. * @param scene defines the hosting scene
  39936. */
  39937. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39938. /**
  39939. * Gets camera class name
  39940. * @returns AnaglyphArcRotateCamera
  39941. */
  39942. getClassName(): string;
  39943. }
  39944. }
  39945. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39946. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39947. import { Scene } from "babylonjs/scene";
  39948. import { Vector3 } from "babylonjs/Maths/math.vector";
  39949. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39950. /**
  39951. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39952. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39953. */
  39954. export class AnaglyphFreeCamera extends FreeCamera {
  39955. /**
  39956. * Creates a new AnaglyphFreeCamera
  39957. * @param name defines camera name
  39958. * @param position defines initial position
  39959. * @param interaxialDistance defines distance between each color axis
  39960. * @param scene defines the hosting scene
  39961. */
  39962. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39963. /**
  39964. * Gets camera class name
  39965. * @returns AnaglyphFreeCamera
  39966. */
  39967. getClassName(): string;
  39968. }
  39969. }
  39970. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39971. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39972. import { Scene } from "babylonjs/scene";
  39973. import { Vector3 } from "babylonjs/Maths/math.vector";
  39974. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39975. /**
  39976. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39977. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39978. */
  39979. export class AnaglyphGamepadCamera extends GamepadCamera {
  39980. /**
  39981. * Creates a new AnaglyphGamepadCamera
  39982. * @param name defines camera name
  39983. * @param position defines initial position
  39984. * @param interaxialDistance defines distance between each color axis
  39985. * @param scene defines the hosting scene
  39986. */
  39987. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39988. /**
  39989. * Gets camera class name
  39990. * @returns AnaglyphGamepadCamera
  39991. */
  39992. getClassName(): string;
  39993. }
  39994. }
  39995. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39996. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39997. import { Scene } from "babylonjs/scene";
  39998. import { Vector3 } from "babylonjs/Maths/math.vector";
  39999. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40000. /**
  40001. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40002. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40003. */
  40004. export class AnaglyphUniversalCamera extends UniversalCamera {
  40005. /**
  40006. * Creates a new AnaglyphUniversalCamera
  40007. * @param name defines camera name
  40008. * @param position defines initial position
  40009. * @param interaxialDistance defines distance between each color axis
  40010. * @param scene defines the hosting scene
  40011. */
  40012. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40013. /**
  40014. * Gets camera class name
  40015. * @returns AnaglyphUniversalCamera
  40016. */
  40017. getClassName(): string;
  40018. }
  40019. }
  40020. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40021. /** @hidden */
  40022. export var stereoscopicInterlacePixelShader: {
  40023. name: string;
  40024. shader: string;
  40025. };
  40026. }
  40027. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40028. import { Camera } from "babylonjs/Cameras/camera";
  40029. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40030. import { Engine } from "babylonjs/Engines/engine";
  40031. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40032. /**
  40033. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40034. */
  40035. export class StereoscopicInterlacePostProcess extends PostProcess {
  40036. private _stepSize;
  40037. private _passedProcess;
  40038. /**
  40039. * Initializes a StereoscopicInterlacePostProcess
  40040. * @param name The name of the effect.
  40041. * @param rigCameras The rig cameras to be appled to the post process
  40042. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40043. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40044. * @param engine The engine which the post process will be applied. (default: current engine)
  40045. * @param reusable If the post process can be reused on the same frame. (default: false)
  40046. */
  40047. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40048. }
  40049. }
  40050. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40051. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40052. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40053. import { Scene } from "babylonjs/scene";
  40054. import { Vector3 } from "babylonjs/Maths/math.vector";
  40055. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40056. /**
  40057. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40058. * @see http://doc.babylonjs.com/features/cameras
  40059. */
  40060. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40061. /**
  40062. * Creates a new StereoscopicArcRotateCamera
  40063. * @param name defines camera name
  40064. * @param alpha defines alpha angle (in radians)
  40065. * @param beta defines beta angle (in radians)
  40066. * @param radius defines radius
  40067. * @param target defines camera target
  40068. * @param interaxialDistance defines distance between each color axis
  40069. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40070. * @param scene defines the hosting scene
  40071. */
  40072. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40073. /**
  40074. * Gets camera class name
  40075. * @returns StereoscopicArcRotateCamera
  40076. */
  40077. getClassName(): string;
  40078. }
  40079. }
  40080. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40081. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40082. import { Scene } from "babylonjs/scene";
  40083. import { Vector3 } from "babylonjs/Maths/math.vector";
  40084. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40085. /**
  40086. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40087. * @see http://doc.babylonjs.com/features/cameras
  40088. */
  40089. export class StereoscopicFreeCamera extends FreeCamera {
  40090. /**
  40091. * Creates a new StereoscopicFreeCamera
  40092. * @param name defines camera name
  40093. * @param position defines initial position
  40094. * @param interaxialDistance defines distance between each color axis
  40095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40096. * @param scene defines the hosting scene
  40097. */
  40098. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40099. /**
  40100. * Gets camera class name
  40101. * @returns StereoscopicFreeCamera
  40102. */
  40103. getClassName(): string;
  40104. }
  40105. }
  40106. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40107. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40108. import { Scene } from "babylonjs/scene";
  40109. import { Vector3 } from "babylonjs/Maths/math.vector";
  40110. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40111. /**
  40112. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40113. * @see http://doc.babylonjs.com/features/cameras
  40114. */
  40115. export class StereoscopicGamepadCamera extends GamepadCamera {
  40116. /**
  40117. * Creates a new StereoscopicGamepadCamera
  40118. * @param name defines camera name
  40119. * @param position defines initial position
  40120. * @param interaxialDistance defines distance between each color axis
  40121. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40122. * @param scene defines the hosting scene
  40123. */
  40124. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40125. /**
  40126. * Gets camera class name
  40127. * @returns StereoscopicGamepadCamera
  40128. */
  40129. getClassName(): string;
  40130. }
  40131. }
  40132. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40133. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40134. import { Scene } from "babylonjs/scene";
  40135. import { Vector3 } from "babylonjs/Maths/math.vector";
  40136. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40137. /**
  40138. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40139. * @see http://doc.babylonjs.com/features/cameras
  40140. */
  40141. export class StereoscopicUniversalCamera extends UniversalCamera {
  40142. /**
  40143. * Creates a new StereoscopicUniversalCamera
  40144. * @param name defines camera name
  40145. * @param position defines initial position
  40146. * @param interaxialDistance defines distance between each color axis
  40147. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40148. * @param scene defines the hosting scene
  40149. */
  40150. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40151. /**
  40152. * Gets camera class name
  40153. * @returns StereoscopicUniversalCamera
  40154. */
  40155. getClassName(): string;
  40156. }
  40157. }
  40158. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40159. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40160. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40161. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40162. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40163. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40164. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40165. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40166. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40167. }
  40168. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40169. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40170. import { Scene } from "babylonjs/scene";
  40171. import { Vector3 } from "babylonjs/Maths/math.vector";
  40172. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40173. /**
  40174. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40175. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40176. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40177. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40178. */
  40179. export class VirtualJoysticksCamera extends FreeCamera {
  40180. /**
  40181. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40182. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40183. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40184. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40185. * @param name Define the name of the camera in the scene
  40186. * @param position Define the start position of the camera in the scene
  40187. * @param scene Define the scene the camera belongs to
  40188. */
  40189. constructor(name: string, position: Vector3, scene: Scene);
  40190. /**
  40191. * Gets the current object class name.
  40192. * @return the class name
  40193. */
  40194. getClassName(): string;
  40195. }
  40196. }
  40197. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40198. import { Matrix } from "babylonjs/Maths/math.vector";
  40199. /**
  40200. * This represents all the required metrics to create a VR camera.
  40201. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40202. */
  40203. export class VRCameraMetrics {
  40204. /**
  40205. * Define the horizontal resolution off the screen.
  40206. */
  40207. hResolution: number;
  40208. /**
  40209. * Define the vertical resolution off the screen.
  40210. */
  40211. vResolution: number;
  40212. /**
  40213. * Define the horizontal screen size.
  40214. */
  40215. hScreenSize: number;
  40216. /**
  40217. * Define the vertical screen size.
  40218. */
  40219. vScreenSize: number;
  40220. /**
  40221. * Define the vertical screen center position.
  40222. */
  40223. vScreenCenter: number;
  40224. /**
  40225. * Define the distance of the eyes to the screen.
  40226. */
  40227. eyeToScreenDistance: number;
  40228. /**
  40229. * Define the distance between both lenses
  40230. */
  40231. lensSeparationDistance: number;
  40232. /**
  40233. * Define the distance between both viewer's eyes.
  40234. */
  40235. interpupillaryDistance: number;
  40236. /**
  40237. * Define the distortion factor of the VR postprocess.
  40238. * Please, touch with care.
  40239. */
  40240. distortionK: number[];
  40241. /**
  40242. * Define the chromatic aberration correction factors for the VR post process.
  40243. */
  40244. chromaAbCorrection: number[];
  40245. /**
  40246. * Define the scale factor of the post process.
  40247. * The smaller the better but the slower.
  40248. */
  40249. postProcessScaleFactor: number;
  40250. /**
  40251. * Define an offset for the lens center.
  40252. */
  40253. lensCenterOffset: number;
  40254. /**
  40255. * Define if the current vr camera should compensate the distortion of the lense or not.
  40256. */
  40257. compensateDistortion: boolean;
  40258. /**
  40259. * Defines if multiview should be enabled when rendering (Default: false)
  40260. */
  40261. multiviewEnabled: boolean;
  40262. /**
  40263. * Gets the rendering aspect ratio based on the provided resolutions.
  40264. */
  40265. readonly aspectRatio: number;
  40266. /**
  40267. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40268. */
  40269. readonly aspectRatioFov: number;
  40270. /**
  40271. * @hidden
  40272. */
  40273. readonly leftHMatrix: Matrix;
  40274. /**
  40275. * @hidden
  40276. */
  40277. readonly rightHMatrix: Matrix;
  40278. /**
  40279. * @hidden
  40280. */
  40281. readonly leftPreViewMatrix: Matrix;
  40282. /**
  40283. * @hidden
  40284. */
  40285. readonly rightPreViewMatrix: Matrix;
  40286. /**
  40287. * Get the default VRMetrics based on the most generic setup.
  40288. * @returns the default vr metrics
  40289. */
  40290. static GetDefault(): VRCameraMetrics;
  40291. }
  40292. }
  40293. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40294. /** @hidden */
  40295. export var vrDistortionCorrectionPixelShader: {
  40296. name: string;
  40297. shader: string;
  40298. };
  40299. }
  40300. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40301. import { Camera } from "babylonjs/Cameras/camera";
  40302. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40303. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40304. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40305. /**
  40306. * VRDistortionCorrectionPostProcess used for mobile VR
  40307. */
  40308. export class VRDistortionCorrectionPostProcess extends PostProcess {
  40309. private _isRightEye;
  40310. private _distortionFactors;
  40311. private _postProcessScaleFactor;
  40312. private _lensCenterOffset;
  40313. private _scaleIn;
  40314. private _scaleFactor;
  40315. private _lensCenter;
  40316. /**
  40317. * Initializes the VRDistortionCorrectionPostProcess
  40318. * @param name The name of the effect.
  40319. * @param camera The camera to apply the render pass to.
  40320. * @param isRightEye If this is for the right eye distortion
  40321. * @param vrMetrics All the required metrics for the VR camera
  40322. */
  40323. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  40324. }
  40325. }
  40326. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  40327. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  40328. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40329. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40330. import { Scene } from "babylonjs/scene";
  40331. import { Vector3 } from "babylonjs/Maths/math.vector";
  40332. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40333. import "babylonjs/Cameras/RigModes/vrRigMode";
  40334. /**
  40335. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40336. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40337. */
  40338. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40339. /**
  40340. * Creates a new VRDeviceOrientationArcRotateCamera
  40341. * @param name defines camera name
  40342. * @param alpha defines the camera rotation along the logitudinal axis
  40343. * @param beta defines the camera rotation along the latitudinal axis
  40344. * @param radius defines the camera distance from its target
  40345. * @param target defines the camera target
  40346. * @param scene defines the scene the camera belongs to
  40347. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40348. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40349. */
  40350. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40351. /**
  40352. * Gets camera class name
  40353. * @returns VRDeviceOrientationArcRotateCamera
  40354. */
  40355. getClassName(): string;
  40356. }
  40357. }
  40358. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40359. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40360. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40361. import { Scene } from "babylonjs/scene";
  40362. import { Vector3 } from "babylonjs/Maths/math.vector";
  40363. import "babylonjs/Cameras/RigModes/vrRigMode";
  40364. /**
  40365. * Camera used to simulate VR rendering (based on FreeCamera)
  40366. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40367. */
  40368. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40369. /**
  40370. * Creates a new VRDeviceOrientationFreeCamera
  40371. * @param name defines camera name
  40372. * @param position defines the start position of the camera
  40373. * @param scene defines the scene the camera belongs to
  40374. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40375. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40376. */
  40377. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40378. /**
  40379. * Gets camera class name
  40380. * @returns VRDeviceOrientationFreeCamera
  40381. */
  40382. getClassName(): string;
  40383. }
  40384. }
  40385. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40386. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40387. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40388. import { Scene } from "babylonjs/scene";
  40389. import { Vector3 } from "babylonjs/Maths/math.vector";
  40390. import "babylonjs/Gamepads/gamepadSceneComponent";
  40391. /**
  40392. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40393. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40394. */
  40395. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40396. /**
  40397. * Creates a new VRDeviceOrientationGamepadCamera
  40398. * @param name defines camera name
  40399. * @param position defines the start position of the camera
  40400. * @param scene defines the scene the camera belongs to
  40401. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40402. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40403. */
  40404. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40405. /**
  40406. * Gets camera class name
  40407. * @returns VRDeviceOrientationGamepadCamera
  40408. */
  40409. getClassName(): string;
  40410. }
  40411. }
  40412. declare module "babylonjs/Materials/pushMaterial" {
  40413. import { Nullable } from "babylonjs/types";
  40414. import { Scene } from "babylonjs/scene";
  40415. import { Matrix } from "babylonjs/Maths/math.vector";
  40416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40417. import { Mesh } from "babylonjs/Meshes/mesh";
  40418. import { Material } from "babylonjs/Materials/material";
  40419. import { Effect } from "babylonjs/Materials/effect";
  40420. /**
  40421. * Base class of materials working in push mode in babylon JS
  40422. * @hidden
  40423. */
  40424. export class PushMaterial extends Material {
  40425. protected _activeEffect: Effect;
  40426. protected _normalMatrix: Matrix;
  40427. /**
  40428. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40429. * This means that the material can keep using a previous shader while a new one is being compiled.
  40430. * This is mostly used when shader parallel compilation is supported (true by default)
  40431. */
  40432. allowShaderHotSwapping: boolean;
  40433. constructor(name: string, scene: Scene);
  40434. getEffect(): Effect;
  40435. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40436. /**
  40437. * Binds the given world matrix to the active effect
  40438. *
  40439. * @param world the matrix to bind
  40440. */
  40441. bindOnlyWorldMatrix(world: Matrix): void;
  40442. /**
  40443. * Binds the given normal matrix to the active effect
  40444. *
  40445. * @param normalMatrix the matrix to bind
  40446. */
  40447. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40448. bind(world: Matrix, mesh?: Mesh): void;
  40449. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40450. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40451. }
  40452. }
  40453. declare module "babylonjs/Materials/materialFlags" {
  40454. /**
  40455. * This groups all the flags used to control the materials channel.
  40456. */
  40457. export class MaterialFlags {
  40458. private static _DiffuseTextureEnabled;
  40459. /**
  40460. * Are diffuse textures enabled in the application.
  40461. */
  40462. static DiffuseTextureEnabled: boolean;
  40463. private static _AmbientTextureEnabled;
  40464. /**
  40465. * Are ambient textures enabled in the application.
  40466. */
  40467. static AmbientTextureEnabled: boolean;
  40468. private static _OpacityTextureEnabled;
  40469. /**
  40470. * Are opacity textures enabled in the application.
  40471. */
  40472. static OpacityTextureEnabled: boolean;
  40473. private static _ReflectionTextureEnabled;
  40474. /**
  40475. * Are reflection textures enabled in the application.
  40476. */
  40477. static ReflectionTextureEnabled: boolean;
  40478. private static _EmissiveTextureEnabled;
  40479. /**
  40480. * Are emissive textures enabled in the application.
  40481. */
  40482. static EmissiveTextureEnabled: boolean;
  40483. private static _SpecularTextureEnabled;
  40484. /**
  40485. * Are specular textures enabled in the application.
  40486. */
  40487. static SpecularTextureEnabled: boolean;
  40488. private static _BumpTextureEnabled;
  40489. /**
  40490. * Are bump textures enabled in the application.
  40491. */
  40492. static BumpTextureEnabled: boolean;
  40493. private static _LightmapTextureEnabled;
  40494. /**
  40495. * Are lightmap textures enabled in the application.
  40496. */
  40497. static LightmapTextureEnabled: boolean;
  40498. private static _RefractionTextureEnabled;
  40499. /**
  40500. * Are refraction textures enabled in the application.
  40501. */
  40502. static RefractionTextureEnabled: boolean;
  40503. private static _ColorGradingTextureEnabled;
  40504. /**
  40505. * Are color grading textures enabled in the application.
  40506. */
  40507. static ColorGradingTextureEnabled: boolean;
  40508. private static _FresnelEnabled;
  40509. /**
  40510. * Are fresnels enabled in the application.
  40511. */
  40512. static FresnelEnabled: boolean;
  40513. private static _ClearCoatTextureEnabled;
  40514. /**
  40515. * Are clear coat textures enabled in the application.
  40516. */
  40517. static ClearCoatTextureEnabled: boolean;
  40518. private static _ClearCoatBumpTextureEnabled;
  40519. /**
  40520. * Are clear coat bump textures enabled in the application.
  40521. */
  40522. static ClearCoatBumpTextureEnabled: boolean;
  40523. private static _ClearCoatTintTextureEnabled;
  40524. /**
  40525. * Are clear coat tint textures enabled in the application.
  40526. */
  40527. static ClearCoatTintTextureEnabled: boolean;
  40528. private static _SheenTextureEnabled;
  40529. /**
  40530. * Are sheen textures enabled in the application.
  40531. */
  40532. static SheenTextureEnabled: boolean;
  40533. private static _AnisotropicTextureEnabled;
  40534. /**
  40535. * Are anisotropic textures enabled in the application.
  40536. */
  40537. static AnisotropicTextureEnabled: boolean;
  40538. private static _ThicknessTextureEnabled;
  40539. /**
  40540. * Are thickness textures enabled in the application.
  40541. */
  40542. static ThicknessTextureEnabled: boolean;
  40543. }
  40544. }
  40545. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40546. /** @hidden */
  40547. export var defaultFragmentDeclaration: {
  40548. name: string;
  40549. shader: string;
  40550. };
  40551. }
  40552. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40553. /** @hidden */
  40554. export var defaultUboDeclaration: {
  40555. name: string;
  40556. shader: string;
  40557. };
  40558. }
  40559. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40560. /** @hidden */
  40561. export var lightFragmentDeclaration: {
  40562. name: string;
  40563. shader: string;
  40564. };
  40565. }
  40566. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40567. /** @hidden */
  40568. export var lightUboDeclaration: {
  40569. name: string;
  40570. shader: string;
  40571. };
  40572. }
  40573. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40574. /** @hidden */
  40575. export var lightsFragmentFunctions: {
  40576. name: string;
  40577. shader: string;
  40578. };
  40579. }
  40580. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40581. /** @hidden */
  40582. export var shadowsFragmentFunctions: {
  40583. name: string;
  40584. shader: string;
  40585. };
  40586. }
  40587. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40588. /** @hidden */
  40589. export var fresnelFunction: {
  40590. name: string;
  40591. shader: string;
  40592. };
  40593. }
  40594. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40595. /** @hidden */
  40596. export var reflectionFunction: {
  40597. name: string;
  40598. shader: string;
  40599. };
  40600. }
  40601. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40602. /** @hidden */
  40603. export var bumpFragmentFunctions: {
  40604. name: string;
  40605. shader: string;
  40606. };
  40607. }
  40608. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40609. /** @hidden */
  40610. export var logDepthDeclaration: {
  40611. name: string;
  40612. shader: string;
  40613. };
  40614. }
  40615. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40616. /** @hidden */
  40617. export var bumpFragment: {
  40618. name: string;
  40619. shader: string;
  40620. };
  40621. }
  40622. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40623. /** @hidden */
  40624. export var depthPrePass: {
  40625. name: string;
  40626. shader: string;
  40627. };
  40628. }
  40629. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40630. /** @hidden */
  40631. export var lightFragment: {
  40632. name: string;
  40633. shader: string;
  40634. };
  40635. }
  40636. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40637. /** @hidden */
  40638. export var logDepthFragment: {
  40639. name: string;
  40640. shader: string;
  40641. };
  40642. }
  40643. declare module "babylonjs/Shaders/default.fragment" {
  40644. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40645. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40646. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40647. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40648. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40649. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40650. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40651. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40652. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40653. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40654. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40655. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40656. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40657. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40658. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40659. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40660. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40661. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40662. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40663. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40664. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40665. /** @hidden */
  40666. export var defaultPixelShader: {
  40667. name: string;
  40668. shader: string;
  40669. };
  40670. }
  40671. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40672. /** @hidden */
  40673. export var defaultVertexDeclaration: {
  40674. name: string;
  40675. shader: string;
  40676. };
  40677. }
  40678. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40679. /** @hidden */
  40680. export var bumpVertexDeclaration: {
  40681. name: string;
  40682. shader: string;
  40683. };
  40684. }
  40685. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40686. /** @hidden */
  40687. export var bumpVertex: {
  40688. name: string;
  40689. shader: string;
  40690. };
  40691. }
  40692. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40693. /** @hidden */
  40694. export var fogVertex: {
  40695. name: string;
  40696. shader: string;
  40697. };
  40698. }
  40699. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40700. /** @hidden */
  40701. export var shadowsVertex: {
  40702. name: string;
  40703. shader: string;
  40704. };
  40705. }
  40706. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40707. /** @hidden */
  40708. export var pointCloudVertex: {
  40709. name: string;
  40710. shader: string;
  40711. };
  40712. }
  40713. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40714. /** @hidden */
  40715. export var logDepthVertex: {
  40716. name: string;
  40717. shader: string;
  40718. };
  40719. }
  40720. declare module "babylonjs/Shaders/default.vertex" {
  40721. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40722. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40723. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40724. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40725. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40726. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40727. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40728. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40729. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40730. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40731. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40732. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40733. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40734. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40735. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40736. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40737. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40738. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40739. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40740. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40741. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40742. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40743. /** @hidden */
  40744. export var defaultVertexShader: {
  40745. name: string;
  40746. shader: string;
  40747. };
  40748. }
  40749. declare module "babylonjs/Materials/standardMaterial" {
  40750. import { SmartArray } from "babylonjs/Misc/smartArray";
  40751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40752. import { Nullable } from "babylonjs/types";
  40753. import { Scene } from "babylonjs/scene";
  40754. import { Matrix } from "babylonjs/Maths/math.vector";
  40755. import { Color3 } from "babylonjs/Maths/math.color";
  40756. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40758. import { Mesh } from "babylonjs/Meshes/mesh";
  40759. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40760. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40761. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40762. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40763. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40766. import "babylonjs/Shaders/default.fragment";
  40767. import "babylonjs/Shaders/default.vertex";
  40768. /** @hidden */
  40769. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40770. MAINUV1: boolean;
  40771. MAINUV2: boolean;
  40772. DIFFUSE: boolean;
  40773. DIFFUSEDIRECTUV: number;
  40774. AMBIENT: boolean;
  40775. AMBIENTDIRECTUV: number;
  40776. OPACITY: boolean;
  40777. OPACITYDIRECTUV: number;
  40778. OPACITYRGB: boolean;
  40779. REFLECTION: boolean;
  40780. EMISSIVE: boolean;
  40781. EMISSIVEDIRECTUV: number;
  40782. SPECULAR: boolean;
  40783. SPECULARDIRECTUV: number;
  40784. BUMP: boolean;
  40785. BUMPDIRECTUV: number;
  40786. PARALLAX: boolean;
  40787. PARALLAXOCCLUSION: boolean;
  40788. SPECULAROVERALPHA: boolean;
  40789. CLIPPLANE: boolean;
  40790. CLIPPLANE2: boolean;
  40791. CLIPPLANE3: boolean;
  40792. CLIPPLANE4: boolean;
  40793. ALPHATEST: boolean;
  40794. DEPTHPREPASS: boolean;
  40795. ALPHAFROMDIFFUSE: boolean;
  40796. POINTSIZE: boolean;
  40797. FOG: boolean;
  40798. SPECULARTERM: boolean;
  40799. DIFFUSEFRESNEL: boolean;
  40800. OPACITYFRESNEL: boolean;
  40801. REFLECTIONFRESNEL: boolean;
  40802. REFRACTIONFRESNEL: boolean;
  40803. EMISSIVEFRESNEL: boolean;
  40804. FRESNEL: boolean;
  40805. NORMAL: boolean;
  40806. UV1: boolean;
  40807. UV2: boolean;
  40808. VERTEXCOLOR: boolean;
  40809. VERTEXALPHA: boolean;
  40810. NUM_BONE_INFLUENCERS: number;
  40811. BonesPerMesh: number;
  40812. BONETEXTURE: boolean;
  40813. INSTANCES: boolean;
  40814. GLOSSINESS: boolean;
  40815. ROUGHNESS: boolean;
  40816. EMISSIVEASILLUMINATION: boolean;
  40817. LINKEMISSIVEWITHDIFFUSE: boolean;
  40818. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40819. LIGHTMAP: boolean;
  40820. LIGHTMAPDIRECTUV: number;
  40821. OBJECTSPACE_NORMALMAP: boolean;
  40822. USELIGHTMAPASSHADOWMAP: boolean;
  40823. REFLECTIONMAP_3D: boolean;
  40824. REFLECTIONMAP_SPHERICAL: boolean;
  40825. REFLECTIONMAP_PLANAR: boolean;
  40826. REFLECTIONMAP_CUBIC: boolean;
  40827. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40828. REFLECTIONMAP_PROJECTION: boolean;
  40829. REFLECTIONMAP_SKYBOX: boolean;
  40830. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40831. REFLECTIONMAP_EXPLICIT: boolean;
  40832. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40833. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40834. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40835. INVERTCUBICMAP: boolean;
  40836. LOGARITHMICDEPTH: boolean;
  40837. REFRACTION: boolean;
  40838. REFRACTIONMAP_3D: boolean;
  40839. REFLECTIONOVERALPHA: boolean;
  40840. TWOSIDEDLIGHTING: boolean;
  40841. SHADOWFLOAT: boolean;
  40842. MORPHTARGETS: boolean;
  40843. MORPHTARGETS_NORMAL: boolean;
  40844. MORPHTARGETS_TANGENT: boolean;
  40845. MORPHTARGETS_UV: boolean;
  40846. NUM_MORPH_INFLUENCERS: number;
  40847. NONUNIFORMSCALING: boolean;
  40848. PREMULTIPLYALPHA: boolean;
  40849. IMAGEPROCESSING: boolean;
  40850. VIGNETTE: boolean;
  40851. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40852. VIGNETTEBLENDMODEOPAQUE: boolean;
  40853. TONEMAPPING: boolean;
  40854. TONEMAPPING_ACES: boolean;
  40855. CONTRAST: boolean;
  40856. COLORCURVES: boolean;
  40857. COLORGRADING: boolean;
  40858. COLORGRADING3D: boolean;
  40859. SAMPLER3DGREENDEPTH: boolean;
  40860. SAMPLER3DBGRMAP: boolean;
  40861. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40862. MULTIVIEW: boolean;
  40863. /**
  40864. * If the reflection texture on this material is in linear color space
  40865. * @hidden
  40866. */
  40867. IS_REFLECTION_LINEAR: boolean;
  40868. /**
  40869. * If the refraction texture on this material is in linear color space
  40870. * @hidden
  40871. */
  40872. IS_REFRACTION_LINEAR: boolean;
  40873. EXPOSURE: boolean;
  40874. constructor();
  40875. setReflectionMode(modeToEnable: string): void;
  40876. }
  40877. /**
  40878. * This is the default material used in Babylon. It is the best trade off between quality
  40879. * and performances.
  40880. * @see http://doc.babylonjs.com/babylon101/materials
  40881. */
  40882. export class StandardMaterial extends PushMaterial {
  40883. private _diffuseTexture;
  40884. /**
  40885. * The basic texture of the material as viewed under a light.
  40886. */
  40887. diffuseTexture: Nullable<BaseTexture>;
  40888. private _ambientTexture;
  40889. /**
  40890. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40891. */
  40892. ambientTexture: Nullable<BaseTexture>;
  40893. private _opacityTexture;
  40894. /**
  40895. * Define the transparency of the material from a texture.
  40896. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40897. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40898. */
  40899. opacityTexture: Nullable<BaseTexture>;
  40900. private _reflectionTexture;
  40901. /**
  40902. * Define the texture used to display the reflection.
  40903. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40904. */
  40905. reflectionTexture: Nullable<BaseTexture>;
  40906. private _emissiveTexture;
  40907. /**
  40908. * Define texture of the material as if self lit.
  40909. * This will be mixed in the final result even in the absence of light.
  40910. */
  40911. emissiveTexture: Nullable<BaseTexture>;
  40912. private _specularTexture;
  40913. /**
  40914. * Define how the color and intensity of the highlight given by the light in the material.
  40915. */
  40916. specularTexture: Nullable<BaseTexture>;
  40917. private _bumpTexture;
  40918. /**
  40919. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40920. * 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.
  40921. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40922. */
  40923. bumpTexture: Nullable<BaseTexture>;
  40924. private _lightmapTexture;
  40925. /**
  40926. * Complex lighting can be computationally expensive to compute at runtime.
  40927. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40928. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40929. */
  40930. lightmapTexture: Nullable<BaseTexture>;
  40931. private _refractionTexture;
  40932. /**
  40933. * Define the texture used to display the refraction.
  40934. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40935. */
  40936. refractionTexture: Nullable<BaseTexture>;
  40937. /**
  40938. * The color of the material lit by the environmental background lighting.
  40939. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40940. */
  40941. ambientColor: Color3;
  40942. /**
  40943. * The basic color of the material as viewed under a light.
  40944. */
  40945. diffuseColor: Color3;
  40946. /**
  40947. * Define how the color and intensity of the highlight given by the light in the material.
  40948. */
  40949. specularColor: Color3;
  40950. /**
  40951. * Define the color of the material as if self lit.
  40952. * This will be mixed in the final result even in the absence of light.
  40953. */
  40954. emissiveColor: Color3;
  40955. /**
  40956. * Defines how sharp are the highlights in the material.
  40957. * The bigger the value the sharper giving a more glossy feeling to the result.
  40958. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40959. */
  40960. specularPower: number;
  40961. private _useAlphaFromDiffuseTexture;
  40962. /**
  40963. * Does the transparency come from the diffuse texture alpha channel.
  40964. */
  40965. useAlphaFromDiffuseTexture: boolean;
  40966. private _useEmissiveAsIllumination;
  40967. /**
  40968. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40969. */
  40970. useEmissiveAsIllumination: boolean;
  40971. private _linkEmissiveWithDiffuse;
  40972. /**
  40973. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40974. * the emissive level when the final color is close to one.
  40975. */
  40976. linkEmissiveWithDiffuse: boolean;
  40977. private _useSpecularOverAlpha;
  40978. /**
  40979. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40980. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40981. */
  40982. useSpecularOverAlpha: boolean;
  40983. private _useReflectionOverAlpha;
  40984. /**
  40985. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40986. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40987. */
  40988. useReflectionOverAlpha: boolean;
  40989. private _disableLighting;
  40990. /**
  40991. * Does lights from the scene impacts this material.
  40992. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40993. */
  40994. disableLighting: boolean;
  40995. private _useObjectSpaceNormalMap;
  40996. /**
  40997. * Allows using an object space normal map (instead of tangent space).
  40998. */
  40999. useObjectSpaceNormalMap: boolean;
  41000. private _useParallax;
  41001. /**
  41002. * Is parallax enabled or not.
  41003. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41004. */
  41005. useParallax: boolean;
  41006. private _useParallaxOcclusion;
  41007. /**
  41008. * Is parallax occlusion enabled or not.
  41009. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41010. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41011. */
  41012. useParallaxOcclusion: boolean;
  41013. /**
  41014. * 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.
  41015. */
  41016. parallaxScaleBias: number;
  41017. private _roughness;
  41018. /**
  41019. * Helps to define how blurry the reflections should appears in the material.
  41020. */
  41021. roughness: number;
  41022. /**
  41023. * In case of refraction, define the value of the index of refraction.
  41024. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41025. */
  41026. indexOfRefraction: number;
  41027. /**
  41028. * Invert the refraction texture alongside the y axis.
  41029. * It can be useful with procedural textures or probe for instance.
  41030. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41031. */
  41032. invertRefractionY: boolean;
  41033. /**
  41034. * Defines the alpha limits in alpha test mode.
  41035. */
  41036. alphaCutOff: number;
  41037. private _useLightmapAsShadowmap;
  41038. /**
  41039. * In case of light mapping, define whether the map contains light or shadow informations.
  41040. */
  41041. useLightmapAsShadowmap: boolean;
  41042. private _diffuseFresnelParameters;
  41043. /**
  41044. * Define the diffuse fresnel parameters of the material.
  41045. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41046. */
  41047. diffuseFresnelParameters: FresnelParameters;
  41048. private _opacityFresnelParameters;
  41049. /**
  41050. * Define the opacity fresnel parameters of the material.
  41051. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41052. */
  41053. opacityFresnelParameters: FresnelParameters;
  41054. private _reflectionFresnelParameters;
  41055. /**
  41056. * Define the reflection fresnel parameters of the material.
  41057. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41058. */
  41059. reflectionFresnelParameters: FresnelParameters;
  41060. private _refractionFresnelParameters;
  41061. /**
  41062. * Define the refraction fresnel parameters of the material.
  41063. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41064. */
  41065. refractionFresnelParameters: FresnelParameters;
  41066. private _emissiveFresnelParameters;
  41067. /**
  41068. * Define the emissive fresnel parameters of the material.
  41069. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41070. */
  41071. emissiveFresnelParameters: FresnelParameters;
  41072. private _useReflectionFresnelFromSpecular;
  41073. /**
  41074. * If true automatically deducts the fresnels values from the material specularity.
  41075. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41076. */
  41077. useReflectionFresnelFromSpecular: boolean;
  41078. private _useGlossinessFromSpecularMapAlpha;
  41079. /**
  41080. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41081. */
  41082. useGlossinessFromSpecularMapAlpha: boolean;
  41083. private _maxSimultaneousLights;
  41084. /**
  41085. * Defines the maximum number of lights that can be used in the material
  41086. */
  41087. maxSimultaneousLights: number;
  41088. private _invertNormalMapX;
  41089. /**
  41090. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41091. */
  41092. invertNormalMapX: boolean;
  41093. private _invertNormalMapY;
  41094. /**
  41095. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41096. */
  41097. invertNormalMapY: boolean;
  41098. private _twoSidedLighting;
  41099. /**
  41100. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41101. */
  41102. twoSidedLighting: boolean;
  41103. /**
  41104. * Default configuration related to image processing available in the standard Material.
  41105. */
  41106. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41107. /**
  41108. * Gets the image processing configuration used either in this material.
  41109. */
  41110. /**
  41111. * Sets the Default image processing configuration used either in the this material.
  41112. *
  41113. * If sets to null, the scene one is in use.
  41114. */
  41115. imageProcessingConfiguration: ImageProcessingConfiguration;
  41116. /**
  41117. * Keep track of the image processing observer to allow dispose and replace.
  41118. */
  41119. private _imageProcessingObserver;
  41120. /**
  41121. * Attaches a new image processing configuration to the Standard Material.
  41122. * @param configuration
  41123. */
  41124. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41125. /**
  41126. * Gets wether the color curves effect is enabled.
  41127. */
  41128. /**
  41129. * Sets wether the color curves effect is enabled.
  41130. */
  41131. cameraColorCurvesEnabled: boolean;
  41132. /**
  41133. * Gets wether the color grading effect is enabled.
  41134. */
  41135. /**
  41136. * Gets wether the color grading effect is enabled.
  41137. */
  41138. cameraColorGradingEnabled: boolean;
  41139. /**
  41140. * Gets wether tonemapping is enabled or not.
  41141. */
  41142. /**
  41143. * Sets wether tonemapping is enabled or not
  41144. */
  41145. cameraToneMappingEnabled: boolean;
  41146. /**
  41147. * The camera exposure used on this material.
  41148. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41149. * This corresponds to a photographic exposure.
  41150. */
  41151. /**
  41152. * The camera exposure used on this material.
  41153. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41154. * This corresponds to a photographic exposure.
  41155. */
  41156. cameraExposure: number;
  41157. /**
  41158. * Gets The camera contrast used on this material.
  41159. */
  41160. /**
  41161. * Sets The camera contrast used on this material.
  41162. */
  41163. cameraContrast: number;
  41164. /**
  41165. * Gets the Color Grading 2D Lookup Texture.
  41166. */
  41167. /**
  41168. * Sets the Color Grading 2D Lookup Texture.
  41169. */
  41170. cameraColorGradingTexture: Nullable<BaseTexture>;
  41171. /**
  41172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41174. * 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;
  41175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41176. */
  41177. /**
  41178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41180. * 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;
  41181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41182. */
  41183. cameraColorCurves: Nullable<ColorCurves>;
  41184. /**
  41185. * Custom callback helping to override the default shader used in the material.
  41186. */
  41187. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41188. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41189. protected _worldViewProjectionMatrix: Matrix;
  41190. protected _globalAmbientColor: Color3;
  41191. protected _useLogarithmicDepth: boolean;
  41192. /**
  41193. * Instantiates a new standard material.
  41194. * This is the default material used in Babylon. It is the best trade off between quality
  41195. * and performances.
  41196. * @see http://doc.babylonjs.com/babylon101/materials
  41197. * @param name Define the name of the material in the scene
  41198. * @param scene Define the scene the material belong to
  41199. */
  41200. constructor(name: string, scene: Scene);
  41201. /**
  41202. * Gets a boolean indicating that current material needs to register RTT
  41203. */
  41204. readonly hasRenderTargetTextures: boolean;
  41205. /**
  41206. * Gets the current class name of the material e.g. "StandardMaterial"
  41207. * Mainly use in serialization.
  41208. * @returns the class name
  41209. */
  41210. getClassName(): string;
  41211. /**
  41212. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41213. * You can try switching to logarithmic depth.
  41214. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41215. */
  41216. useLogarithmicDepth: boolean;
  41217. /**
  41218. * Specifies if the material will require alpha blending
  41219. * @returns a boolean specifying if alpha blending is needed
  41220. */
  41221. needAlphaBlending(): boolean;
  41222. /**
  41223. * Specifies if this material should be rendered in alpha test mode
  41224. * @returns a boolean specifying if an alpha test is needed.
  41225. */
  41226. needAlphaTesting(): boolean;
  41227. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41228. /**
  41229. * Get the texture used for alpha test purpose.
  41230. * @returns the diffuse texture in case of the standard material.
  41231. */
  41232. getAlphaTestTexture(): Nullable<BaseTexture>;
  41233. /**
  41234. * Get if the submesh is ready to be used and all its information available.
  41235. * Child classes can use it to update shaders
  41236. * @param mesh defines the mesh to check
  41237. * @param subMesh defines which submesh to check
  41238. * @param useInstances specifies that instances should be used
  41239. * @returns a boolean indicating that the submesh is ready or not
  41240. */
  41241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41242. /**
  41243. * Builds the material UBO layouts.
  41244. * Used internally during the effect preparation.
  41245. */
  41246. buildUniformLayout(): void;
  41247. /**
  41248. * Unbinds the material from the mesh
  41249. */
  41250. unbind(): void;
  41251. /**
  41252. * Binds the submesh to this material by preparing the effect and shader to draw
  41253. * @param world defines the world transformation matrix
  41254. * @param mesh defines the mesh containing the submesh
  41255. * @param subMesh defines the submesh to bind the material to
  41256. */
  41257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41258. /**
  41259. * Get the list of animatables in the material.
  41260. * @returns the list of animatables object used in the material
  41261. */
  41262. getAnimatables(): IAnimatable[];
  41263. /**
  41264. * Gets the active textures from the material
  41265. * @returns an array of textures
  41266. */
  41267. getActiveTextures(): BaseTexture[];
  41268. /**
  41269. * Specifies if the material uses a texture
  41270. * @param texture defines the texture to check against the material
  41271. * @returns a boolean specifying if the material uses the texture
  41272. */
  41273. hasTexture(texture: BaseTexture): boolean;
  41274. /**
  41275. * Disposes the material
  41276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41277. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41278. */
  41279. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41280. /**
  41281. * Makes a duplicate of the material, and gives it a new name
  41282. * @param name defines the new name for the duplicated material
  41283. * @returns the cloned material
  41284. */
  41285. clone(name: string): StandardMaterial;
  41286. /**
  41287. * Serializes this material in a JSON representation
  41288. * @returns the serialized material object
  41289. */
  41290. serialize(): any;
  41291. /**
  41292. * Creates a standard material from parsed material data
  41293. * @param source defines the JSON representation of the material
  41294. * @param scene defines the hosting scene
  41295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41296. * @returns a new standard material
  41297. */
  41298. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41299. /**
  41300. * Are diffuse textures enabled in the application.
  41301. */
  41302. static DiffuseTextureEnabled: boolean;
  41303. /**
  41304. * Are ambient textures enabled in the application.
  41305. */
  41306. static AmbientTextureEnabled: boolean;
  41307. /**
  41308. * Are opacity textures enabled in the application.
  41309. */
  41310. static OpacityTextureEnabled: boolean;
  41311. /**
  41312. * Are reflection textures enabled in the application.
  41313. */
  41314. static ReflectionTextureEnabled: boolean;
  41315. /**
  41316. * Are emissive textures enabled in the application.
  41317. */
  41318. static EmissiveTextureEnabled: boolean;
  41319. /**
  41320. * Are specular textures enabled in the application.
  41321. */
  41322. static SpecularTextureEnabled: boolean;
  41323. /**
  41324. * Are bump textures enabled in the application.
  41325. */
  41326. static BumpTextureEnabled: boolean;
  41327. /**
  41328. * Are lightmap textures enabled in the application.
  41329. */
  41330. static LightmapTextureEnabled: boolean;
  41331. /**
  41332. * Are refraction textures enabled in the application.
  41333. */
  41334. static RefractionTextureEnabled: boolean;
  41335. /**
  41336. * Are color grading textures enabled in the application.
  41337. */
  41338. static ColorGradingTextureEnabled: boolean;
  41339. /**
  41340. * Are fresnels enabled in the application.
  41341. */
  41342. static FresnelEnabled: boolean;
  41343. }
  41344. }
  41345. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41346. import { Scene } from "babylonjs/scene";
  41347. import { Texture } from "babylonjs/Materials/Textures/texture";
  41348. /**
  41349. * A class extending Texture allowing drawing on a texture
  41350. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41351. */
  41352. export class DynamicTexture extends Texture {
  41353. private _generateMipMaps;
  41354. private _canvas;
  41355. private _context;
  41356. private _engine;
  41357. /**
  41358. * Creates a DynamicTexture
  41359. * @param name defines the name of the texture
  41360. * @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
  41361. * @param scene defines the scene where you want the texture
  41362. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41363. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41364. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41365. */
  41366. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41367. /**
  41368. * Get the current class name of the texture useful for serialization or dynamic coding.
  41369. * @returns "DynamicTexture"
  41370. */
  41371. getClassName(): string;
  41372. /**
  41373. * Gets the current state of canRescale
  41374. */
  41375. readonly canRescale: boolean;
  41376. private _recreate;
  41377. /**
  41378. * Scales the texture
  41379. * @param ratio the scale factor to apply to both width and height
  41380. */
  41381. scale(ratio: number): void;
  41382. /**
  41383. * Resizes the texture
  41384. * @param width the new width
  41385. * @param height the new height
  41386. */
  41387. scaleTo(width: number, height: number): void;
  41388. /**
  41389. * Gets the context of the canvas used by the texture
  41390. * @returns the canvas context of the dynamic texture
  41391. */
  41392. getContext(): CanvasRenderingContext2D;
  41393. /**
  41394. * Clears the texture
  41395. */
  41396. clear(): void;
  41397. /**
  41398. * Updates the texture
  41399. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41400. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41401. */
  41402. update(invertY?: boolean, premulAlpha?: boolean): void;
  41403. /**
  41404. * Draws text onto the texture
  41405. * @param text defines the text to be drawn
  41406. * @param x defines the placement of the text from the left
  41407. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41408. * @param font defines the font to be used with font-style, font-size, font-name
  41409. * @param color defines the color used for the text
  41410. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41411. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41412. * @param update defines whether texture is immediately update (default is true)
  41413. */
  41414. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41415. /**
  41416. * Clones the texture
  41417. * @returns the clone of the texture.
  41418. */
  41419. clone(): DynamicTexture;
  41420. /**
  41421. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41422. * @returns a serialized dynamic texture object
  41423. */
  41424. serialize(): any;
  41425. /** @hidden */
  41426. _rebuild(): void;
  41427. }
  41428. }
  41429. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41430. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41431. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41432. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41433. /** @hidden */
  41434. export var imageProcessingPixelShader: {
  41435. name: string;
  41436. shader: string;
  41437. };
  41438. }
  41439. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41440. import { Nullable } from "babylonjs/types";
  41441. import { Color4 } from "babylonjs/Maths/math.color";
  41442. import { Camera } from "babylonjs/Cameras/camera";
  41443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41444. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41445. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41446. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41447. import { Engine } from "babylonjs/Engines/engine";
  41448. import "babylonjs/Shaders/imageProcessing.fragment";
  41449. import "babylonjs/Shaders/postprocess.vertex";
  41450. /**
  41451. * ImageProcessingPostProcess
  41452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41453. */
  41454. export class ImageProcessingPostProcess extends PostProcess {
  41455. /**
  41456. * Default configuration related to image processing available in the PBR Material.
  41457. */
  41458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41459. /**
  41460. * Gets the image processing configuration used either in this material.
  41461. */
  41462. /**
  41463. * Sets the Default image processing configuration used either in the this material.
  41464. *
  41465. * If sets to null, the scene one is in use.
  41466. */
  41467. imageProcessingConfiguration: ImageProcessingConfiguration;
  41468. /**
  41469. * Keep track of the image processing observer to allow dispose and replace.
  41470. */
  41471. private _imageProcessingObserver;
  41472. /**
  41473. * Attaches a new image processing configuration to the PBR Material.
  41474. * @param configuration
  41475. */
  41476. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41477. /**
  41478. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41479. */
  41480. /**
  41481. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41482. */
  41483. colorCurves: Nullable<ColorCurves>;
  41484. /**
  41485. * Gets wether the color curves effect is enabled.
  41486. */
  41487. /**
  41488. * Sets wether the color curves effect is enabled.
  41489. */
  41490. colorCurvesEnabled: boolean;
  41491. /**
  41492. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41493. */
  41494. /**
  41495. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41496. */
  41497. colorGradingTexture: Nullable<BaseTexture>;
  41498. /**
  41499. * Gets wether the color grading effect is enabled.
  41500. */
  41501. /**
  41502. * Gets wether the color grading effect is enabled.
  41503. */
  41504. colorGradingEnabled: boolean;
  41505. /**
  41506. * Gets exposure used in the effect.
  41507. */
  41508. /**
  41509. * Sets exposure used in the effect.
  41510. */
  41511. exposure: number;
  41512. /**
  41513. * Gets wether tonemapping is enabled or not.
  41514. */
  41515. /**
  41516. * Sets wether tonemapping is enabled or not
  41517. */
  41518. toneMappingEnabled: boolean;
  41519. /**
  41520. * Gets the type of tone mapping effect.
  41521. */
  41522. /**
  41523. * Sets the type of tone mapping effect.
  41524. */
  41525. toneMappingType: number;
  41526. /**
  41527. * Gets contrast used in the effect.
  41528. */
  41529. /**
  41530. * Sets contrast used in the effect.
  41531. */
  41532. contrast: number;
  41533. /**
  41534. * Gets Vignette stretch size.
  41535. */
  41536. /**
  41537. * Sets Vignette stretch size.
  41538. */
  41539. vignetteStretch: number;
  41540. /**
  41541. * Gets Vignette centre X Offset.
  41542. */
  41543. /**
  41544. * Sets Vignette centre X Offset.
  41545. */
  41546. vignetteCentreX: number;
  41547. /**
  41548. * Gets Vignette centre Y Offset.
  41549. */
  41550. /**
  41551. * Sets Vignette centre Y Offset.
  41552. */
  41553. vignetteCentreY: number;
  41554. /**
  41555. * Gets Vignette weight or intensity of the vignette effect.
  41556. */
  41557. /**
  41558. * Sets Vignette weight or intensity of the vignette effect.
  41559. */
  41560. vignetteWeight: number;
  41561. /**
  41562. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41563. * if vignetteEnabled is set to true.
  41564. */
  41565. /**
  41566. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41567. * if vignetteEnabled is set to true.
  41568. */
  41569. vignetteColor: Color4;
  41570. /**
  41571. * Gets Camera field of view used by the Vignette effect.
  41572. */
  41573. /**
  41574. * Sets Camera field of view used by the Vignette effect.
  41575. */
  41576. vignetteCameraFov: number;
  41577. /**
  41578. * Gets the vignette blend mode allowing different kind of effect.
  41579. */
  41580. /**
  41581. * Sets the vignette blend mode allowing different kind of effect.
  41582. */
  41583. vignetteBlendMode: number;
  41584. /**
  41585. * Gets wether the vignette effect is enabled.
  41586. */
  41587. /**
  41588. * Sets wether the vignette effect is enabled.
  41589. */
  41590. vignetteEnabled: boolean;
  41591. private _fromLinearSpace;
  41592. /**
  41593. * Gets wether the input of the processing is in Gamma or Linear Space.
  41594. */
  41595. /**
  41596. * Sets wether the input of the processing is in Gamma or Linear Space.
  41597. */
  41598. fromLinearSpace: boolean;
  41599. /**
  41600. * Defines cache preventing GC.
  41601. */
  41602. private _defines;
  41603. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41604. /**
  41605. * "ImageProcessingPostProcess"
  41606. * @returns "ImageProcessingPostProcess"
  41607. */
  41608. getClassName(): string;
  41609. protected _updateParameters(): void;
  41610. dispose(camera?: Camera): void;
  41611. }
  41612. }
  41613. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41614. import { Scene } from "babylonjs/scene";
  41615. import { Color3 } from "babylonjs/Maths/math.color";
  41616. import { Mesh } from "babylonjs/Meshes/mesh";
  41617. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41618. import { Nullable } from "babylonjs/types";
  41619. /**
  41620. * Class containing static functions to help procedurally build meshes
  41621. */
  41622. export class GroundBuilder {
  41623. /**
  41624. * Creates a ground mesh
  41625. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41626. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41628. * @param name defines the name of the mesh
  41629. * @param options defines the options used to create the mesh
  41630. * @param scene defines the hosting scene
  41631. * @returns the ground mesh
  41632. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41633. */
  41634. static CreateGround(name: string, options: {
  41635. width?: number;
  41636. height?: number;
  41637. subdivisions?: number;
  41638. subdivisionsX?: number;
  41639. subdivisionsY?: number;
  41640. updatable?: boolean;
  41641. }, scene: any): Mesh;
  41642. /**
  41643. * Creates a tiled ground mesh
  41644. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41645. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41646. * * 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
  41647. * * 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
  41648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41649. * @param name defines the name of the mesh
  41650. * @param options defines the options used to create the mesh
  41651. * @param scene defines the hosting scene
  41652. * @returns the tiled ground mesh
  41653. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41654. */
  41655. static CreateTiledGround(name: string, options: {
  41656. xmin: number;
  41657. zmin: number;
  41658. xmax: number;
  41659. zmax: number;
  41660. subdivisions?: {
  41661. w: number;
  41662. h: number;
  41663. };
  41664. precision?: {
  41665. w: number;
  41666. h: number;
  41667. };
  41668. updatable?: boolean;
  41669. }, scene?: Nullable<Scene>): Mesh;
  41670. /**
  41671. * Creates a ground mesh from a height map
  41672. * * The parameter `url` sets the URL of the height map image resource.
  41673. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41674. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41675. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41676. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41677. * * 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.
  41678. * * 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).
  41679. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41681. * @param name defines the name of the mesh
  41682. * @param url defines the url to the height map
  41683. * @param options defines the options used to create the mesh
  41684. * @param scene defines the hosting scene
  41685. * @returns the ground mesh
  41686. * @see https://doc.babylonjs.com/babylon101/height_map
  41687. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41688. */
  41689. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41690. width?: number;
  41691. height?: number;
  41692. subdivisions?: number;
  41693. minHeight?: number;
  41694. maxHeight?: number;
  41695. colorFilter?: Color3;
  41696. alphaFilter?: number;
  41697. updatable?: boolean;
  41698. onReady?: (mesh: GroundMesh) => void;
  41699. }, scene?: Nullable<Scene>): GroundMesh;
  41700. }
  41701. }
  41702. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41703. import { Vector4 } from "babylonjs/Maths/math.vector";
  41704. import { Mesh } from "babylonjs/Meshes/mesh";
  41705. /**
  41706. * Class containing static functions to help procedurally build meshes
  41707. */
  41708. export class TorusBuilder {
  41709. /**
  41710. * Creates a torus mesh
  41711. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41712. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41713. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41717. * @param name defines the name of the mesh
  41718. * @param options defines the options used to create the mesh
  41719. * @param scene defines the hosting scene
  41720. * @returns the torus mesh
  41721. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41722. */
  41723. static CreateTorus(name: string, options: {
  41724. diameter?: number;
  41725. thickness?: number;
  41726. tessellation?: number;
  41727. updatable?: boolean;
  41728. sideOrientation?: number;
  41729. frontUVs?: Vector4;
  41730. backUVs?: Vector4;
  41731. }, scene: any): Mesh;
  41732. }
  41733. }
  41734. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41735. import { Vector4 } from "babylonjs/Maths/math.vector";
  41736. import { Color4 } from "babylonjs/Maths/math.color";
  41737. import { Mesh } from "babylonjs/Meshes/mesh";
  41738. /**
  41739. * Class containing static functions to help procedurally build meshes
  41740. */
  41741. export class CylinderBuilder {
  41742. /**
  41743. * Creates a cylinder or a cone mesh
  41744. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41745. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41746. * * 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.
  41747. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41748. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41749. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41750. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41751. * * 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).
  41752. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41753. * * 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).
  41754. * * 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
  41755. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41756. * * 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
  41757. * * 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.
  41758. * * If `enclose` is false, a ring surface is one element.
  41759. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41760. * * 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
  41761. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41762. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41764. * @param name defines the name of the mesh
  41765. * @param options defines the options used to create the mesh
  41766. * @param scene defines the hosting scene
  41767. * @returns the cylinder mesh
  41768. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41769. */
  41770. static CreateCylinder(name: string, options: {
  41771. height?: number;
  41772. diameterTop?: number;
  41773. diameterBottom?: number;
  41774. diameter?: number;
  41775. tessellation?: number;
  41776. subdivisions?: number;
  41777. arc?: number;
  41778. faceColors?: Color4[];
  41779. faceUV?: Vector4[];
  41780. updatable?: boolean;
  41781. hasRings?: boolean;
  41782. enclose?: boolean;
  41783. cap?: number;
  41784. sideOrientation?: number;
  41785. frontUVs?: Vector4;
  41786. backUVs?: Vector4;
  41787. }, scene: any): Mesh;
  41788. }
  41789. }
  41790. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41791. import { Observable } from "babylonjs/Misc/observable";
  41792. import { Nullable } from "babylonjs/types";
  41793. import { Camera } from "babylonjs/Cameras/camera";
  41794. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41795. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41796. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41797. import { Scene } from "babylonjs/scene";
  41798. import { Vector3 } from "babylonjs/Maths/math.vector";
  41799. import { Color3 } from "babylonjs/Maths/math.color";
  41800. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41801. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41802. import { Mesh } from "babylonjs/Meshes/mesh";
  41803. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41804. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41805. import "babylonjs/Meshes/Builders/groundBuilder";
  41806. import "babylonjs/Meshes/Builders/torusBuilder";
  41807. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41808. import "babylonjs/Gamepads/gamepadSceneComponent";
  41809. import "babylonjs/Animations/animatable";
  41810. /**
  41811. * Options to modify the vr teleportation behavior.
  41812. */
  41813. export interface VRTeleportationOptions {
  41814. /**
  41815. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41816. */
  41817. floorMeshName?: string;
  41818. /**
  41819. * A list of meshes to be used as the teleportation floor. (default: empty)
  41820. */
  41821. floorMeshes?: Mesh[];
  41822. }
  41823. /**
  41824. * Options to modify the vr experience helper's behavior.
  41825. */
  41826. export interface VRExperienceHelperOptions extends WebVROptions {
  41827. /**
  41828. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41829. */
  41830. createDeviceOrientationCamera?: boolean;
  41831. /**
  41832. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41833. */
  41834. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41835. /**
  41836. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41837. */
  41838. laserToggle?: boolean;
  41839. /**
  41840. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41841. */
  41842. floorMeshes?: Mesh[];
  41843. /**
  41844. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41845. */
  41846. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41847. }
  41848. /**
  41849. * Event containing information after VR has been entered
  41850. */
  41851. export class OnAfterEnteringVRObservableEvent {
  41852. /**
  41853. * If entering vr was successful
  41854. */
  41855. success: boolean;
  41856. }
  41857. /**
  41858. * Helps to quickly add VR support to an existing scene.
  41859. * See http://doc.babylonjs.com/how_to/webvr_helper
  41860. */
  41861. export class VRExperienceHelper {
  41862. /** Options to modify the vr experience helper's behavior. */
  41863. webVROptions: VRExperienceHelperOptions;
  41864. private _scene;
  41865. private _position;
  41866. private _btnVR;
  41867. private _btnVRDisplayed;
  41868. private _webVRsupported;
  41869. private _webVRready;
  41870. private _webVRrequesting;
  41871. private _webVRpresenting;
  41872. private _hasEnteredVR;
  41873. private _fullscreenVRpresenting;
  41874. private _canvas;
  41875. private _webVRCamera;
  41876. private _vrDeviceOrientationCamera;
  41877. private _deviceOrientationCamera;
  41878. private _existingCamera;
  41879. private _onKeyDown;
  41880. private _onVrDisplayPresentChange;
  41881. private _onVRDisplayChanged;
  41882. private _onVRRequestPresentStart;
  41883. private _onVRRequestPresentComplete;
  41884. /**
  41885. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  41886. */
  41887. enableGazeEvenWhenNoPointerLock: boolean;
  41888. /**
  41889. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  41890. */
  41891. exitVROnDoubleTap: boolean;
  41892. /**
  41893. * Observable raised right before entering VR.
  41894. */
  41895. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41896. /**
  41897. * Observable raised when entering VR has completed.
  41898. */
  41899. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41900. /**
  41901. * Observable raised when exiting VR.
  41902. */
  41903. onExitingVRObservable: Observable<VRExperienceHelper>;
  41904. /**
  41905. * Observable raised when controller mesh is loaded.
  41906. */
  41907. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41908. /** Return this.onEnteringVRObservable
  41909. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41910. */
  41911. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41912. /** Return this.onExitingVRObservable
  41913. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41914. */
  41915. readonly onExitingVR: Observable<VRExperienceHelper>;
  41916. /** Return this.onControllerMeshLoadedObservable
  41917. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41918. */
  41919. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41920. private _rayLength;
  41921. private _useCustomVRButton;
  41922. private _teleportationRequested;
  41923. private _teleportActive;
  41924. private _floorMeshName;
  41925. private _floorMeshesCollection;
  41926. private _rotationAllowed;
  41927. private _teleportBackwardsVector;
  41928. private _teleportationTarget;
  41929. private _isDefaultTeleportationTarget;
  41930. private _postProcessMove;
  41931. private _teleportationFillColor;
  41932. private _teleportationBorderColor;
  41933. private _rotationAngle;
  41934. private _haloCenter;
  41935. private _cameraGazer;
  41936. private _padSensibilityUp;
  41937. private _padSensibilityDown;
  41938. private _leftController;
  41939. private _rightController;
  41940. /**
  41941. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41942. */
  41943. onNewMeshSelected: Observable<AbstractMesh>;
  41944. /**
  41945. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41946. */
  41947. onNewMeshPicked: Observable<PickingInfo>;
  41948. private _circleEase;
  41949. /**
  41950. * Observable raised before camera teleportation
  41951. */
  41952. onBeforeCameraTeleport: Observable<Vector3>;
  41953. /**
  41954. * Observable raised after camera teleportation
  41955. */
  41956. onAfterCameraTeleport: Observable<Vector3>;
  41957. /**
  41958. * Observable raised when current selected mesh gets unselected
  41959. */
  41960. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41961. private _raySelectionPredicate;
  41962. /**
  41963. * To be optionaly changed by user to define custom ray selection
  41964. */
  41965. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41966. /**
  41967. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41968. */
  41969. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41970. /**
  41971. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41972. */
  41973. teleportationEnabled: boolean;
  41974. private _defaultHeight;
  41975. private _teleportationInitialized;
  41976. private _interactionsEnabled;
  41977. private _interactionsRequested;
  41978. private _displayGaze;
  41979. private _displayLaserPointer;
  41980. /**
  41981. * The mesh used to display where the user is going to teleport.
  41982. */
  41983. /**
  41984. * Sets the mesh to be used to display where the user is going to teleport.
  41985. */
  41986. teleportationTarget: Mesh;
  41987. /**
  41988. * 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
  41989. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41990. * See http://doc.babylonjs.com/resources/baking_transformations
  41991. */
  41992. gazeTrackerMesh: Mesh;
  41993. /**
  41994. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41995. */
  41996. updateGazeTrackerScale: boolean;
  41997. /**
  41998. * If the gaze trackers color should be updated when selecting meshes
  41999. */
  42000. updateGazeTrackerColor: boolean;
  42001. /**
  42002. * The gaze tracking mesh corresponding to the left controller
  42003. */
  42004. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42005. /**
  42006. * The gaze tracking mesh corresponding to the right controller
  42007. */
  42008. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42009. /**
  42010. * If the ray of the gaze should be displayed.
  42011. */
  42012. /**
  42013. * Sets if the ray of the gaze should be displayed.
  42014. */
  42015. displayGaze: boolean;
  42016. /**
  42017. * If the ray of the LaserPointer should be displayed.
  42018. */
  42019. /**
  42020. * Sets if the ray of the LaserPointer should be displayed.
  42021. */
  42022. displayLaserPointer: boolean;
  42023. /**
  42024. * The deviceOrientationCamera used as the camera when not in VR.
  42025. */
  42026. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42027. /**
  42028. * Based on the current WebVR support, returns the current VR camera used.
  42029. */
  42030. readonly currentVRCamera: Nullable<Camera>;
  42031. /**
  42032. * The webVRCamera which is used when in VR.
  42033. */
  42034. readonly webVRCamera: WebVRFreeCamera;
  42035. /**
  42036. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42037. */
  42038. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42039. /**
  42040. * The html button that is used to trigger entering into VR.
  42041. */
  42042. readonly vrButton: Nullable<HTMLButtonElement>;
  42043. private readonly _teleportationRequestInitiated;
  42044. /**
  42045. * Defines wether or not Pointer lock should be requested when switching to
  42046. * full screen.
  42047. */
  42048. requestPointerLockOnFullScreen: boolean;
  42049. /**
  42050. * Instantiates a VRExperienceHelper.
  42051. * Helps to quickly add VR support to an existing scene.
  42052. * @param scene The scene the VRExperienceHelper belongs to.
  42053. * @param webVROptions Options to modify the vr experience helper's behavior.
  42054. */
  42055. constructor(scene: Scene,
  42056. /** Options to modify the vr experience helper's behavior. */
  42057. webVROptions?: VRExperienceHelperOptions);
  42058. private _onDefaultMeshLoaded;
  42059. private _onResize;
  42060. private _onFullscreenChange;
  42061. /**
  42062. * Gets a value indicating if we are currently in VR mode.
  42063. */
  42064. readonly isInVRMode: boolean;
  42065. private onVrDisplayPresentChange;
  42066. private onVRDisplayChanged;
  42067. private moveButtonToBottomRight;
  42068. private displayVRButton;
  42069. private updateButtonVisibility;
  42070. private _cachedAngularSensibility;
  42071. /**
  42072. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42073. * Otherwise, will use the fullscreen API.
  42074. */
  42075. enterVR(): void;
  42076. /**
  42077. * Attempt to exit VR, or fullscreen.
  42078. */
  42079. exitVR(): void;
  42080. /**
  42081. * The position of the vr experience helper.
  42082. */
  42083. /**
  42084. * Sets the position of the vr experience helper.
  42085. */
  42086. position: Vector3;
  42087. /**
  42088. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42089. */
  42090. enableInteractions(): void;
  42091. private readonly _noControllerIsActive;
  42092. private beforeRender;
  42093. private _isTeleportationFloor;
  42094. /**
  42095. * Adds a floor mesh to be used for teleportation.
  42096. * @param floorMesh the mesh to be used for teleportation.
  42097. */
  42098. addFloorMesh(floorMesh: Mesh): void;
  42099. /**
  42100. * Removes a floor mesh from being used for teleportation.
  42101. * @param floorMesh the mesh to be removed.
  42102. */
  42103. removeFloorMesh(floorMesh: Mesh): void;
  42104. /**
  42105. * Enables interactions and teleportation using the VR controllers and gaze.
  42106. * @param vrTeleportationOptions options to modify teleportation behavior.
  42107. */
  42108. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42109. private _onNewGamepadConnected;
  42110. private _tryEnableInteractionOnController;
  42111. private _onNewGamepadDisconnected;
  42112. private _enableInteractionOnController;
  42113. private _checkTeleportWithRay;
  42114. private _checkRotate;
  42115. private _checkTeleportBackwards;
  42116. private _enableTeleportationOnController;
  42117. private _createTeleportationCircles;
  42118. private _displayTeleportationTarget;
  42119. private _hideTeleportationTarget;
  42120. private _rotateCamera;
  42121. private _moveTeleportationSelectorTo;
  42122. private _workingVector;
  42123. private _workingQuaternion;
  42124. private _workingMatrix;
  42125. /**
  42126. * Teleports the users feet to the desired location
  42127. * @param location The location where the user's feet should be placed
  42128. */
  42129. teleportCamera(location: Vector3): void;
  42130. private _convertNormalToDirectionOfRay;
  42131. private _castRayAndSelectObject;
  42132. private _notifySelectedMeshUnselected;
  42133. /**
  42134. * Sets the color of the laser ray from the vr controllers.
  42135. * @param color new color for the ray.
  42136. */
  42137. changeLaserColor(color: Color3): void;
  42138. /**
  42139. * Sets the color of the ray from the vr headsets gaze.
  42140. * @param color new color for the ray.
  42141. */
  42142. changeGazeColor(color: Color3): void;
  42143. /**
  42144. * Exits VR and disposes of the vr experience helper
  42145. */
  42146. dispose(): void;
  42147. /**
  42148. * Gets the name of the VRExperienceHelper class
  42149. * @returns "VRExperienceHelper"
  42150. */
  42151. getClassName(): string;
  42152. }
  42153. }
  42154. declare module "babylonjs/Cameras/VR/index" {
  42155. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42156. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42157. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42158. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42159. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42160. export * from "babylonjs/Cameras/VR/webVRCamera";
  42161. }
  42162. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42163. import { Observable } from "babylonjs/Misc/observable";
  42164. import { Nullable } from "babylonjs/types";
  42165. import { IDisposable, Scene } from "babylonjs/scene";
  42166. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42167. /**
  42168. * Manages an XRSession to work with Babylon's engine
  42169. * @see https://doc.babylonjs.com/how_to/webxr
  42170. */
  42171. export class WebXRSessionManager implements IDisposable {
  42172. private scene;
  42173. /**
  42174. * Fires every time a new xrFrame arrives which can be used to update the camera
  42175. */
  42176. onXRFrameObservable: Observable<any>;
  42177. /**
  42178. * Fires when the xr session is ended either by the device or manually done
  42179. */
  42180. onXRSessionEnded: Observable<any>;
  42181. /**
  42182. * Underlying xr session
  42183. */
  42184. session: XRSession;
  42185. /**
  42186. * Type of reference space used when creating the session
  42187. */
  42188. referenceSpace: XRReferenceSpace;
  42189. /** @hidden */
  42190. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42191. /**
  42192. * Current XR frame
  42193. */
  42194. currentFrame: Nullable<XRFrame>;
  42195. private _xrNavigator;
  42196. private baseLayer;
  42197. /**
  42198. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42199. * @param scene The scene which the session should be created for
  42200. */
  42201. constructor(scene: Scene);
  42202. /**
  42203. * Initializes the manager
  42204. * After initialization enterXR can be called to start an XR session
  42205. * @returns Promise which resolves after it is initialized
  42206. */
  42207. initializeAsync(): Promise<void>;
  42208. /**
  42209. * Initializes an xr session
  42210. * @param xrSessionMode mode to initialize
  42211. * @returns a promise which will resolve once the session has been initialized
  42212. */
  42213. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42214. /**
  42215. * Sets the reference space on the xr session
  42216. * @param referenceSpace space to set
  42217. * @returns a promise that will resolve once the reference space has been set
  42218. */
  42219. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42220. /**
  42221. * Updates the render state of the session
  42222. * @param state state to set
  42223. * @returns a promise that resolves once the render state has been updated
  42224. */
  42225. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42226. /**
  42227. * Starts rendering to the xr layer
  42228. * @returns a promise that will resolve once rendering has started
  42229. */
  42230. startRenderingToXRAsync(): Promise<void>;
  42231. /**
  42232. * Stops the xrSession and restores the renderloop
  42233. * @returns Promise which resolves after it exits XR
  42234. */
  42235. exitXRAsync(): Promise<unknown>;
  42236. /**
  42237. * Checks if a session would be supported for the creation options specified
  42238. * @param sessionMode session mode to check if supported eg. immersive-vr
  42239. * @returns true if supported
  42240. */
  42241. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42242. /**
  42243. * @hidden
  42244. * Converts the render layer of xrSession to a render target
  42245. * @param session session to create render target for
  42246. * @param scene scene the new render target should be created for
  42247. */
  42248. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42249. /**
  42250. * Disposes of the session manager
  42251. */
  42252. dispose(): void;
  42253. }
  42254. }
  42255. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42256. import { Scene } from "babylonjs/scene";
  42257. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42258. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42259. /**
  42260. * WebXR Camera which holds the views for the xrSession
  42261. * @see https://doc.babylonjs.com/how_to/webxr
  42262. */
  42263. export class WebXRCamera extends FreeCamera {
  42264. private static _TmpMatrix;
  42265. /**
  42266. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42267. * @param name the name of the camera
  42268. * @param scene the scene to add the camera to
  42269. */
  42270. constructor(name: string, scene: Scene);
  42271. private _updateNumberOfRigCameras;
  42272. /** @hidden */
  42273. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42274. /**
  42275. * Updates the cameras position from the current pose information of the XR session
  42276. * @param xrSessionManager the session containing pose information
  42277. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42278. */
  42279. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42280. }
  42281. }
  42282. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42283. import { Nullable } from "babylonjs/types";
  42284. import { IDisposable } from "babylonjs/scene";
  42285. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42286. /**
  42287. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42288. */
  42289. export class WebXRManagedOutputCanvas implements IDisposable {
  42290. private helper;
  42291. private _canvas;
  42292. /**
  42293. * xrpresent context of the canvas which can be used to display/mirror xr content
  42294. */
  42295. canvasContext: WebGLRenderingContext;
  42296. /**
  42297. * xr layer for the canvas
  42298. */
  42299. xrLayer: Nullable<XRWebGLLayer>;
  42300. /**
  42301. * Initializes the xr layer for the session
  42302. * @param xrSession xr session
  42303. * @returns a promise that will resolve once the XR Layer has been created
  42304. */
  42305. initializeXRLayerAsync(xrSession: any): any;
  42306. /**
  42307. * Initializes the canvas to be added/removed upon entering/exiting xr
  42308. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42309. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42310. */
  42311. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42312. /**
  42313. * Disposes of the object
  42314. */
  42315. dispose(): void;
  42316. private _setManagedOutputCanvas;
  42317. private _addCanvas;
  42318. private _removeCanvas;
  42319. }
  42320. }
  42321. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42322. import { Observable } from "babylonjs/Misc/observable";
  42323. import { IDisposable, Scene } from "babylonjs/scene";
  42324. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42326. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42327. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42328. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42329. /**
  42330. * States of the webXR experience
  42331. */
  42332. export enum WebXRState {
  42333. /**
  42334. * Transitioning to being in XR mode
  42335. */
  42336. ENTERING_XR = 0,
  42337. /**
  42338. * Transitioning to non XR mode
  42339. */
  42340. EXITING_XR = 1,
  42341. /**
  42342. * In XR mode and presenting
  42343. */
  42344. IN_XR = 2,
  42345. /**
  42346. * Not entered XR mode
  42347. */
  42348. NOT_IN_XR = 3
  42349. }
  42350. /**
  42351. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42352. * @see https://doc.babylonjs.com/how_to/webxr
  42353. */
  42354. export class WebXRExperienceHelper implements IDisposable {
  42355. private scene;
  42356. /**
  42357. * 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
  42358. */
  42359. container: AbstractMesh;
  42360. /**
  42361. * Camera used to render xr content
  42362. */
  42363. camera: WebXRCamera;
  42364. /**
  42365. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42366. */
  42367. state: WebXRState;
  42368. private _setState;
  42369. private static _TmpVector;
  42370. /**
  42371. * Fires when the state of the experience helper has changed
  42372. */
  42373. onStateChangedObservable: Observable<WebXRState>;
  42374. /** Session manager used to keep track of xr session */
  42375. sessionManager: WebXRSessionManager;
  42376. private _nonVRCamera;
  42377. private _originalSceneAutoClear;
  42378. private _supported;
  42379. /**
  42380. * Creates the experience helper
  42381. * @param scene the scene to attach the experience helper to
  42382. * @returns a promise for the experience helper
  42383. */
  42384. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42385. /**
  42386. * Creates a WebXRExperienceHelper
  42387. * @param scene The scene the helper should be created in
  42388. */
  42389. private constructor();
  42390. /**
  42391. * Exits XR mode and returns the scene to its original state
  42392. * @returns promise that resolves after xr mode has exited
  42393. */
  42394. exitXRAsync(): Promise<unknown>;
  42395. /**
  42396. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42397. * @param sessionCreationOptions options for the XR session
  42398. * @param referenceSpaceType frame of reference of the XR session
  42399. * @param outputCanvas the output canvas that will be used to enter XR mode
  42400. * @returns promise that resolves after xr mode has entered
  42401. */
  42402. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  42403. /**
  42404. * Updates the global position of the camera by moving the camera's container
  42405. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42406. * @param position The desired global position of the camera
  42407. */
  42408. setPositionOfCameraUsingContainer(position: Vector3): void;
  42409. /**
  42410. * Rotates the xr camera by rotating the camera's container around the camera's position
  42411. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42412. * @param rotation the desired quaternion rotation to apply to the camera
  42413. */
  42414. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42415. /**
  42416. * Disposes of the experience helper
  42417. */
  42418. dispose(): void;
  42419. }
  42420. }
  42421. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42422. import { Nullable } from "babylonjs/types";
  42423. import { Observable } from "babylonjs/Misc/observable";
  42424. import { IDisposable, Scene } from "babylonjs/scene";
  42425. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42426. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42427. /**
  42428. * Button which can be used to enter a different mode of XR
  42429. */
  42430. export class WebXREnterExitUIButton {
  42431. /** button element */
  42432. element: HTMLElement;
  42433. /** XR initialization options for the button */
  42434. sessionMode: XRSessionMode;
  42435. /** Reference space type */
  42436. referenceSpaceType: XRReferenceSpaceType;
  42437. /**
  42438. * Creates a WebXREnterExitUIButton
  42439. * @param element button element
  42440. * @param sessionMode XR initialization session mode
  42441. * @param referenceSpaceType the type of reference space to be used
  42442. */
  42443. constructor(
  42444. /** button element */
  42445. element: HTMLElement,
  42446. /** XR initialization options for the button */
  42447. sessionMode: XRSessionMode,
  42448. /** Reference space type */
  42449. referenceSpaceType: XRReferenceSpaceType);
  42450. /**
  42451. * Overwritable function which can be used to update the button's visuals when the state changes
  42452. * @param activeButton the current active button in the UI
  42453. */
  42454. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42455. }
  42456. /**
  42457. * Options to create the webXR UI
  42458. */
  42459. export class WebXREnterExitUIOptions {
  42460. /**
  42461. * Context to enter xr with
  42462. */
  42463. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  42464. /**
  42465. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42466. */
  42467. customButtons?: Array<WebXREnterExitUIButton>;
  42468. }
  42469. /**
  42470. * UI to allow the user to enter/exit XR mode
  42471. */
  42472. export class WebXREnterExitUI implements IDisposable {
  42473. private scene;
  42474. private _overlay;
  42475. private _buttons;
  42476. private _activeButton;
  42477. /**
  42478. * Fired every time the active button is changed.
  42479. *
  42480. * When xr is entered via a button that launches xr that button will be the callback parameter
  42481. *
  42482. * When exiting xr the callback parameter will be null)
  42483. */
  42484. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42485. /**
  42486. * Creates UI to allow the user to enter/exit XR mode
  42487. * @param scene the scene to add the ui to
  42488. * @param helper the xr experience helper to enter/exit xr with
  42489. * @param options options to configure the UI
  42490. * @returns the created ui
  42491. */
  42492. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42493. private constructor();
  42494. private _updateButtons;
  42495. /**
  42496. * Disposes of the object
  42497. */
  42498. dispose(): void;
  42499. }
  42500. }
  42501. declare module "babylonjs/Cameras/XR/webXRController" {
  42502. import { Nullable } from "babylonjs/types";
  42503. import { Observable } from "babylonjs/Misc/observable";
  42504. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42505. import { Ray } from "babylonjs/Culling/ray";
  42506. import { Scene } from "babylonjs/scene";
  42507. /**
  42508. * Represents an XR input
  42509. */
  42510. export class WebXRController {
  42511. private scene;
  42512. /** The underlying input source for the controller */
  42513. inputSource: XRInputSource;
  42514. private parentContainer;
  42515. /**
  42516. * 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
  42517. */
  42518. grip?: AbstractMesh;
  42519. /**
  42520. * Pointer which can be used to select objects or attach a visible laser to
  42521. */
  42522. pointer: AbstractMesh;
  42523. /**
  42524. * Event that fires when the controller is removed/disposed
  42525. */
  42526. onDisposeObservable: Observable<{}>;
  42527. private _tmpMatrix;
  42528. private _tmpQuaternion;
  42529. private _tmpVector;
  42530. /**
  42531. * Creates the controller
  42532. * @see https://doc.babylonjs.com/how_to/webxr
  42533. * @param scene the scene which the controller should be associated to
  42534. * @param inputSource the underlying input source for the controller
  42535. * @param parentContainer parent that the controller meshes should be children of
  42536. */
  42537. constructor(scene: Scene,
  42538. /** The underlying input source for the controller */
  42539. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  42540. /**
  42541. * Updates the controller pose based on the given XRFrame
  42542. * @param xrFrame xr frame to update the pose with
  42543. * @param referenceSpace reference space to use
  42544. */
  42545. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  42546. /**
  42547. * Gets a world space ray coming from the controller
  42548. * @param result the resulting ray
  42549. */
  42550. getWorldPointerRayToRef(result: Ray): void;
  42551. /**
  42552. * Disposes of the object
  42553. */
  42554. dispose(): void;
  42555. }
  42556. }
  42557. declare module "babylonjs/Cameras/XR/webXRInput" {
  42558. import { Observable } from "babylonjs/Misc/observable";
  42559. import { IDisposable } from "babylonjs/scene";
  42560. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42561. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  42562. /**
  42563. * XR input used to track XR inputs such as controllers/rays
  42564. */
  42565. export class WebXRInput implements IDisposable {
  42566. /**
  42567. * Base experience the input listens to
  42568. */
  42569. baseExperience: WebXRExperienceHelper;
  42570. /**
  42571. * XR controllers being tracked
  42572. */
  42573. controllers: Array<WebXRController>;
  42574. private _frameObserver;
  42575. private _stateObserver;
  42576. /**
  42577. * Event when a controller has been connected/added
  42578. */
  42579. onControllerAddedObservable: Observable<WebXRController>;
  42580. /**
  42581. * Event when a controller has been removed/disconnected
  42582. */
  42583. onControllerRemovedObservable: Observable<WebXRController>;
  42584. /**
  42585. * Initializes the WebXRInput
  42586. * @param baseExperience experience helper which the input should be created for
  42587. */
  42588. constructor(
  42589. /**
  42590. * Base experience the input listens to
  42591. */
  42592. baseExperience: WebXRExperienceHelper);
  42593. private _onInputSourcesChange;
  42594. private _addAndRemoveControllers;
  42595. /**
  42596. * Disposes of the object
  42597. */
  42598. dispose(): void;
  42599. }
  42600. }
  42601. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  42602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42603. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42604. /**
  42605. * Enables teleportation
  42606. */
  42607. export class WebXRControllerTeleportation {
  42608. private _teleportationFillColor;
  42609. private _teleportationBorderColor;
  42610. private _tmpRay;
  42611. private _tmpVector;
  42612. /**
  42613. * Creates a WebXRControllerTeleportation
  42614. * @param input input manager to add teleportation to
  42615. * @param floorMeshes floormeshes which can be teleported to
  42616. */
  42617. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  42618. }
  42619. }
  42620. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  42621. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  42622. /**
  42623. * Handles pointer input automatically for the pointer of XR controllers
  42624. */
  42625. export class WebXRControllerPointerSelection {
  42626. private static _idCounter;
  42627. private _tmpRay;
  42628. /**
  42629. * Creates a WebXRControllerPointerSelection
  42630. * @param input input manager to setup pointer selection
  42631. */
  42632. constructor(input: WebXRInput);
  42633. private _convertNormalToDirectionOfRay;
  42634. private _updatePointerDistance;
  42635. }
  42636. }
  42637. declare module "babylonjs/Loading/sceneLoader" {
  42638. import { Observable } from "babylonjs/Misc/observable";
  42639. import { Nullable } from "babylonjs/types";
  42640. import { Scene } from "babylonjs/scene";
  42641. import { Engine } from "babylonjs/Engines/engine";
  42642. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42643. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42644. import { AssetContainer } from "babylonjs/assetContainer";
  42645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42646. import { Skeleton } from "babylonjs/Bones/skeleton";
  42647. /**
  42648. * Class used to represent data loading progression
  42649. */
  42650. export class SceneLoaderProgressEvent {
  42651. /** defines if data length to load can be evaluated */
  42652. readonly lengthComputable: boolean;
  42653. /** defines the loaded data length */
  42654. readonly loaded: number;
  42655. /** defines the data length to load */
  42656. readonly total: number;
  42657. /**
  42658. * Create a new progress event
  42659. * @param lengthComputable defines if data length to load can be evaluated
  42660. * @param loaded defines the loaded data length
  42661. * @param total defines the data length to load
  42662. */
  42663. constructor(
  42664. /** defines if data length to load can be evaluated */
  42665. lengthComputable: boolean,
  42666. /** defines the loaded data length */
  42667. loaded: number,
  42668. /** defines the data length to load */
  42669. total: number);
  42670. /**
  42671. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42672. * @param event defines the source event
  42673. * @returns a new SceneLoaderProgressEvent
  42674. */
  42675. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42676. }
  42677. /**
  42678. * Interface used by SceneLoader plugins to define supported file extensions
  42679. */
  42680. export interface ISceneLoaderPluginExtensions {
  42681. /**
  42682. * Defines the list of supported extensions
  42683. */
  42684. [extension: string]: {
  42685. isBinary: boolean;
  42686. };
  42687. }
  42688. /**
  42689. * Interface used by SceneLoader plugin factory
  42690. */
  42691. export interface ISceneLoaderPluginFactory {
  42692. /**
  42693. * Defines the name of the factory
  42694. */
  42695. name: string;
  42696. /**
  42697. * Function called to create a new plugin
  42698. * @return the new plugin
  42699. */
  42700. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  42701. /**
  42702. * Boolean indicating if the plugin can direct load specific data
  42703. */
  42704. canDirectLoad?: (data: string) => boolean;
  42705. }
  42706. /**
  42707. * Interface used to define a SceneLoader plugin
  42708. */
  42709. export interface ISceneLoaderPlugin {
  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 meshes The meshes array to import into
  42725. * @param particleSystems The particle systems array to import into
  42726. * @param skeletons The skeletons array to import into
  42727. * @param onError The callback when import fails
  42728. * @returns True if successful or false otherwise
  42729. */
  42730. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  42731. /**
  42732. * Load into a scene.
  42733. * @param scene The scene to load into
  42734. * @param data The data to import
  42735. * @param rootUrl The root url for scene and resources
  42736. * @param onError The callback when import fails
  42737. * @returns true if successful or false otherwise
  42738. */
  42739. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  42740. /**
  42741. * The callback that returns true if the data can be directly loaded.
  42742. */
  42743. canDirectLoad?: (data: string) => boolean;
  42744. /**
  42745. * The callback that allows custom handling of the root url based on the response url.
  42746. */
  42747. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42748. /**
  42749. * Load into an asset container.
  42750. * @param scene The scene to load into
  42751. * @param data The data to import
  42752. * @param rootUrl The root url for scene and resources
  42753. * @param onError The callback when import fails
  42754. * @returns The loaded asset container
  42755. */
  42756. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  42757. }
  42758. /**
  42759. * Interface used to define an async SceneLoader plugin
  42760. */
  42761. export interface ISceneLoaderPluginAsync {
  42762. /**
  42763. * The friendly name of this plugin.
  42764. */
  42765. name: string;
  42766. /**
  42767. * The file extensions supported by this plugin.
  42768. */
  42769. extensions: string | ISceneLoaderPluginExtensions;
  42770. /**
  42771. * Import meshes into a scene.
  42772. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42773. * @param scene The scene to import into
  42774. * @param data The data to import
  42775. * @param rootUrl The root url for scene and resources
  42776. * @param onProgress The callback when the load progresses
  42777. * @param fileName Defines the name of the file to load
  42778. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  42779. */
  42780. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  42781. meshes: AbstractMesh[];
  42782. particleSystems: IParticleSystem[];
  42783. skeletons: Skeleton[];
  42784. animationGroups: AnimationGroup[];
  42785. }>;
  42786. /**
  42787. * Load into a scene.
  42788. * @param scene The scene to load into
  42789. * @param data The data to import
  42790. * @param rootUrl The root url for scene and resources
  42791. * @param onProgress The callback when the load progresses
  42792. * @param fileName Defines the name of the file to load
  42793. * @returns Nothing
  42794. */
  42795. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  42796. /**
  42797. * The callback that returns true if the data can be directly loaded.
  42798. */
  42799. canDirectLoad?: (data: string) => boolean;
  42800. /**
  42801. * The callback that allows custom handling of the root url based on the response url.
  42802. */
  42803. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  42804. /**
  42805. * Load into an asset container.
  42806. * @param scene The scene to load into
  42807. * @param data The data to import
  42808. * @param rootUrl The root url for scene and resources
  42809. * @param onProgress The callback when the load progresses
  42810. * @param fileName Defines the name of the file to load
  42811. * @returns The loaded asset container
  42812. */
  42813. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  42814. }
  42815. /**
  42816. * Class used to load scene from various file formats using registered plugins
  42817. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  42818. */
  42819. export class SceneLoader {
  42820. /**
  42821. * No logging while loading
  42822. */
  42823. static readonly NO_LOGGING: number;
  42824. /**
  42825. * Minimal logging while loading
  42826. */
  42827. static readonly MINIMAL_LOGGING: number;
  42828. /**
  42829. * Summary logging while loading
  42830. */
  42831. static readonly SUMMARY_LOGGING: number;
  42832. /**
  42833. * Detailled logging while loading
  42834. */
  42835. static readonly DETAILED_LOGGING: number;
  42836. /**
  42837. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  42838. */
  42839. static ForceFullSceneLoadingForIncremental: boolean;
  42840. /**
  42841. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  42842. */
  42843. static ShowLoadingScreen: boolean;
  42844. /**
  42845. * Defines the current logging level (while loading the scene)
  42846. * @ignorenaming
  42847. */
  42848. static loggingLevel: number;
  42849. /**
  42850. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  42851. */
  42852. static CleanBoneMatrixWeights: boolean;
  42853. /**
  42854. * Event raised when a plugin is used to load a scene
  42855. */
  42856. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  42857. private static _registeredPlugins;
  42858. private static _getDefaultPlugin;
  42859. private static _getPluginForExtension;
  42860. private static _getPluginForDirectLoad;
  42861. private static _getPluginForFilename;
  42862. private static _getDirectLoad;
  42863. private static _loadData;
  42864. private static _getFileInfo;
  42865. /**
  42866. * Gets a plugin that can load the given extension
  42867. * @param extension defines the extension to load
  42868. * @returns a plugin or null if none works
  42869. */
  42870. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  42871. /**
  42872. * Gets a boolean indicating that the given extension can be loaded
  42873. * @param extension defines the extension to load
  42874. * @returns true if the extension is supported
  42875. */
  42876. static IsPluginForExtensionAvailable(extension: string): boolean;
  42877. /**
  42878. * Adds a new plugin to the list of registered plugins
  42879. * @param plugin defines the plugin to add
  42880. */
  42881. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  42882. /**
  42883. * Import meshes into a scene
  42884. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42885. * @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)
  42886. * @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)
  42887. * @param scene the instance of BABYLON.Scene to append to
  42888. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  42889. * @param onProgress a callback with a progress event for each file being loaded
  42890. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42891. * @param pluginExtension the extension used to determine the plugin
  42892. * @returns The loaded plugin
  42893. */
  42894. 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>;
  42895. /**
  42896. * Import meshes into a scene
  42897. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  42898. * @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)
  42899. * @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)
  42900. * @param scene the instance of BABYLON.Scene to append to
  42901. * @param onProgress a callback with a progress event for each file being loaded
  42902. * @param pluginExtension the extension used to determine the plugin
  42903. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  42904. */
  42905. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  42906. meshes: AbstractMesh[];
  42907. particleSystems: IParticleSystem[];
  42908. skeletons: Skeleton[];
  42909. animationGroups: AnimationGroup[];
  42910. }>;
  42911. /**
  42912. * Load a scene
  42913. * @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)
  42914. * @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)
  42915. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42916. * @param onSuccess a callback with the scene when import succeeds
  42917. * @param onProgress a callback with a progress event for each file being loaded
  42918. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42919. * @param pluginExtension the extension used to determine the plugin
  42920. * @returns The loaded plugin
  42921. */
  42922. 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>;
  42923. /**
  42924. * Load a scene
  42925. * @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)
  42926. * @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)
  42927. * @param engine is the instance of BABYLON.Engine to use to create the scene
  42928. * @param onProgress a callback with a progress event for each file being loaded
  42929. * @param pluginExtension the extension used to determine the plugin
  42930. * @returns The loaded scene
  42931. */
  42932. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42933. /**
  42934. * Append a scene
  42935. * @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)
  42936. * @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)
  42937. * @param scene is the instance of BABYLON.Scene to append to
  42938. * @param onSuccess a callback with the scene when import succeeds
  42939. * @param onProgress a callback with a progress event for each file being loaded
  42940. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42941. * @param pluginExtension the extension used to determine the plugin
  42942. * @returns The loaded plugin
  42943. */
  42944. 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>;
  42945. /**
  42946. * Append a scene
  42947. * @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)
  42948. * @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)
  42949. * @param scene is the instance of BABYLON.Scene to append to
  42950. * @param onProgress a callback with a progress event for each file being loaded
  42951. * @param pluginExtension the extension used to determine the plugin
  42952. * @returns The given scene
  42953. */
  42954. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  42955. /**
  42956. * Load a scene into an asset container
  42957. * @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)
  42958. * @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)
  42959. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42960. * @param onSuccess a callback with the scene when import succeeds
  42961. * @param onProgress a callback with a progress event for each file being loaded
  42962. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  42963. * @param pluginExtension the extension used to determine the plugin
  42964. * @returns The loaded plugin
  42965. */
  42966. 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>;
  42967. /**
  42968. * Load a scene into an asset container
  42969. * @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)
  42970. * @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)
  42971. * @param scene is the instance of Scene to append to
  42972. * @param onProgress a callback with a progress event for each file being loaded
  42973. * @param pluginExtension the extension used to determine the plugin
  42974. * @returns The loaded asset container
  42975. */
  42976. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  42977. }
  42978. }
  42979. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42980. import { Scene } from "babylonjs/scene";
  42981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42983. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42984. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42985. /**
  42986. * Generic Controller
  42987. */
  42988. export class GenericController extends WebVRController {
  42989. /**
  42990. * Base Url for the controller model.
  42991. */
  42992. static readonly MODEL_BASE_URL: string;
  42993. /**
  42994. * File name for the controller model.
  42995. */
  42996. static readonly MODEL_FILENAME: string;
  42997. /**
  42998. * Creates a new GenericController from a gamepad
  42999. * @param vrGamepad the gamepad that the controller should be created from
  43000. */
  43001. constructor(vrGamepad: any);
  43002. /**
  43003. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43004. * @param scene scene in which to add meshes
  43005. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43006. */
  43007. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43008. /**
  43009. * Called once for each button that changed state since the last frame
  43010. * @param buttonIdx Which button index changed
  43011. * @param state New state of the button
  43012. * @param changes Which properties on the state changed since last frame
  43013. */
  43014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43015. }
  43016. }
  43017. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43018. import { Observable } from "babylonjs/Misc/observable";
  43019. import { Scene } from "babylonjs/scene";
  43020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43021. import { Ray } from "babylonjs/Culling/ray";
  43022. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43023. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43024. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43025. /**
  43026. * Defines the WindowsMotionController object that the state of the windows motion controller
  43027. */
  43028. export class WindowsMotionController extends WebVRController {
  43029. /**
  43030. * The base url used to load the left and right controller models
  43031. */
  43032. static MODEL_BASE_URL: string;
  43033. /**
  43034. * The name of the left controller model file
  43035. */
  43036. static MODEL_LEFT_FILENAME: string;
  43037. /**
  43038. * The name of the right controller model file
  43039. */
  43040. static MODEL_RIGHT_FILENAME: string;
  43041. /**
  43042. * The controller name prefix for this controller type
  43043. */
  43044. static readonly GAMEPAD_ID_PREFIX: string;
  43045. /**
  43046. * The controller id pattern for this controller type
  43047. */
  43048. private static readonly GAMEPAD_ID_PATTERN;
  43049. private _loadedMeshInfo;
  43050. private readonly _mapping;
  43051. /**
  43052. * Fired when the trackpad on this controller is clicked
  43053. */
  43054. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43055. /**
  43056. * Fired when the trackpad on this controller is modified
  43057. */
  43058. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43059. /**
  43060. * The current x and y values of this controller's trackpad
  43061. */
  43062. trackpad: StickValues;
  43063. /**
  43064. * Creates a new WindowsMotionController from a gamepad
  43065. * @param vrGamepad the gamepad that the controller should be created from
  43066. */
  43067. constructor(vrGamepad: any);
  43068. /**
  43069. * Fired when the trigger on this controller is modified
  43070. */
  43071. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43072. /**
  43073. * Fired when the menu button on this controller is modified
  43074. */
  43075. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43076. /**
  43077. * Fired when the grip button on this controller is modified
  43078. */
  43079. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43080. /**
  43081. * Fired when the thumbstick button on this controller is modified
  43082. */
  43083. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43084. /**
  43085. * Fired when the touchpad button on this controller is modified
  43086. */
  43087. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43088. /**
  43089. * Fired when the touchpad values on this controller are modified
  43090. */
  43091. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43092. private _updateTrackpad;
  43093. /**
  43094. * Called once per frame by the engine.
  43095. */
  43096. update(): void;
  43097. /**
  43098. * Called once for each button that changed state since the last frame
  43099. * @param buttonIdx Which button index changed
  43100. * @param state New state of the button
  43101. * @param changes Which properties on the state changed since last frame
  43102. */
  43103. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43104. /**
  43105. * Moves the buttons on the controller mesh based on their current state
  43106. * @param buttonName the name of the button to move
  43107. * @param buttonValue the value of the button which determines the buttons new position
  43108. */
  43109. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43110. /**
  43111. * Moves the axis on the controller mesh based on its current state
  43112. * @param axis the index of the axis
  43113. * @param axisValue the value of the axis which determines the meshes new position
  43114. * @hidden
  43115. */
  43116. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43117. /**
  43118. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43119. * @param scene scene in which to add meshes
  43120. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43121. */
  43122. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43123. /**
  43124. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43125. * can be transformed by button presses and axes values, based on this._mapping.
  43126. *
  43127. * @param scene scene in which the meshes exist
  43128. * @param meshes list of meshes that make up the controller model to process
  43129. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43130. */
  43131. private processModel;
  43132. private createMeshInfo;
  43133. /**
  43134. * Gets the ray of the controller in the direction the controller is pointing
  43135. * @param length the length the resulting ray should be
  43136. * @returns a ray in the direction the controller is pointing
  43137. */
  43138. getForwardRay(length?: number): Ray;
  43139. /**
  43140. * Disposes of the controller
  43141. */
  43142. dispose(): void;
  43143. }
  43144. }
  43145. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43146. import { Observable } from "babylonjs/Misc/observable";
  43147. import { Scene } from "babylonjs/scene";
  43148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43149. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43150. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43151. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43152. /**
  43153. * Oculus Touch Controller
  43154. */
  43155. export class OculusTouchController extends WebVRController {
  43156. /**
  43157. * Base Url for the controller model.
  43158. */
  43159. static MODEL_BASE_URL: string;
  43160. /**
  43161. * File name for the left controller model.
  43162. */
  43163. static MODEL_LEFT_FILENAME: string;
  43164. /**
  43165. * File name for the right controller model.
  43166. */
  43167. static MODEL_RIGHT_FILENAME: string;
  43168. /**
  43169. * Base Url for the Quest controller model.
  43170. */
  43171. static QUEST_MODEL_BASE_URL: string;
  43172. /**
  43173. * @hidden
  43174. * If the controllers are running on a device that needs the updated Quest controller models
  43175. */
  43176. static _IsQuest: boolean;
  43177. /**
  43178. * Fired when the secondary trigger on this controller is modified
  43179. */
  43180. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43181. /**
  43182. * Fired when the thumb rest on this controller is modified
  43183. */
  43184. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43185. /**
  43186. * Creates a new OculusTouchController from a gamepad
  43187. * @param vrGamepad the gamepad that the controller should be created from
  43188. */
  43189. constructor(vrGamepad: any);
  43190. /**
  43191. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43192. * @param scene scene in which to add meshes
  43193. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43194. */
  43195. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43196. /**
  43197. * Fired when the A button on this controller is modified
  43198. */
  43199. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43200. /**
  43201. * Fired when the B button on this controller is modified
  43202. */
  43203. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43204. /**
  43205. * Fired when the X button on this controller is modified
  43206. */
  43207. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43208. /**
  43209. * Fired when the Y button on this controller is modified
  43210. */
  43211. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43212. /**
  43213. * Called once for each button that changed state since the last frame
  43214. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43215. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43216. * 2) secondary trigger (same)
  43217. * 3) A (right) X (left), touch, pressed = value
  43218. * 4) B / Y
  43219. * 5) thumb rest
  43220. * @param buttonIdx Which button index changed
  43221. * @param state New state of the button
  43222. * @param changes Which properties on the state changed since last frame
  43223. */
  43224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43225. }
  43226. }
  43227. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43228. import { Scene } from "babylonjs/scene";
  43229. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43230. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43231. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43232. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43233. import { Observable } from "babylonjs/Misc/observable";
  43234. /**
  43235. * Vive Controller
  43236. */
  43237. export class ViveController extends WebVRController {
  43238. /**
  43239. * Base Url for the controller model.
  43240. */
  43241. static MODEL_BASE_URL: string;
  43242. /**
  43243. * File name for the controller model.
  43244. */
  43245. static MODEL_FILENAME: string;
  43246. /**
  43247. * Creates a new ViveController from a gamepad
  43248. * @param vrGamepad the gamepad that the controller should be created from
  43249. */
  43250. constructor(vrGamepad: any);
  43251. /**
  43252. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43253. * @param scene scene in which to add meshes
  43254. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43255. */
  43256. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43257. /**
  43258. * Fired when the left button on this controller is modified
  43259. */
  43260. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43261. /**
  43262. * Fired when the right button on this controller is modified
  43263. */
  43264. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43265. /**
  43266. * Fired when the menu button on this controller is modified
  43267. */
  43268. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43269. /**
  43270. * Called once for each button that changed state since the last frame
  43271. * Vive mapping:
  43272. * 0: touchpad
  43273. * 1: trigger
  43274. * 2: left AND right buttons
  43275. * 3: menu button
  43276. * @param buttonIdx Which button index changed
  43277. * @param state New state of the button
  43278. * @param changes Which properties on the state changed since last frame
  43279. */
  43280. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43281. }
  43282. }
  43283. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43284. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43285. /**
  43286. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43287. */
  43288. export class WebXRControllerModelLoader {
  43289. /**
  43290. * Creates the WebXRControllerModelLoader
  43291. * @param input xr input that creates the controllers
  43292. */
  43293. constructor(input: WebXRInput);
  43294. }
  43295. }
  43296. declare module "babylonjs/Cameras/XR/index" {
  43297. export * from "babylonjs/Cameras/XR/webXRCamera";
  43298. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43299. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43300. export * from "babylonjs/Cameras/XR/webXRInput";
  43301. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43302. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43303. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43304. export * from "babylonjs/Cameras/XR/webXRController";
  43305. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43306. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43307. }
  43308. declare module "babylonjs/Cameras/RigModes/index" {
  43309. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43310. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43311. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43312. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43313. }
  43314. declare module "babylonjs/Cameras/index" {
  43315. export * from "babylonjs/Cameras/Inputs/index";
  43316. export * from "babylonjs/Cameras/cameraInputsManager";
  43317. export * from "babylonjs/Cameras/camera";
  43318. export * from "babylonjs/Cameras/targetCamera";
  43319. export * from "babylonjs/Cameras/freeCamera";
  43320. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43321. export * from "babylonjs/Cameras/touchCamera";
  43322. export * from "babylonjs/Cameras/arcRotateCamera";
  43323. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43324. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43325. export * from "babylonjs/Cameras/flyCamera";
  43326. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43327. export * from "babylonjs/Cameras/followCamera";
  43328. export * from "babylonjs/Cameras/gamepadCamera";
  43329. export * from "babylonjs/Cameras/Stereoscopic/index";
  43330. export * from "babylonjs/Cameras/universalCamera";
  43331. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43332. export * from "babylonjs/Cameras/VR/index";
  43333. export * from "babylonjs/Cameras/XR/index";
  43334. export * from "babylonjs/Cameras/RigModes/index";
  43335. }
  43336. declare module "babylonjs/Collisions/index" {
  43337. export * from "babylonjs/Collisions/collider";
  43338. export * from "babylonjs/Collisions/collisionCoordinator";
  43339. export * from "babylonjs/Collisions/pickingInfo";
  43340. export * from "babylonjs/Collisions/intersectionInfo";
  43341. export * from "babylonjs/Collisions/meshCollisionData";
  43342. }
  43343. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43344. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43345. import { Vector3 } from "babylonjs/Maths/math.vector";
  43346. import { Ray } from "babylonjs/Culling/ray";
  43347. import { Plane } from "babylonjs/Maths/math.plane";
  43348. /**
  43349. * Contains an array of blocks representing the octree
  43350. */
  43351. export interface IOctreeContainer<T> {
  43352. /**
  43353. * Blocks within the octree
  43354. */
  43355. blocks: Array<OctreeBlock<T>>;
  43356. }
  43357. /**
  43358. * Class used to store a cell in an octree
  43359. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43360. */
  43361. export class OctreeBlock<T> {
  43362. /**
  43363. * Gets the content of the current block
  43364. */
  43365. entries: T[];
  43366. /**
  43367. * Gets the list of block children
  43368. */
  43369. blocks: Array<OctreeBlock<T>>;
  43370. private _depth;
  43371. private _maxDepth;
  43372. private _capacity;
  43373. private _minPoint;
  43374. private _maxPoint;
  43375. private _boundingVectors;
  43376. private _creationFunc;
  43377. /**
  43378. * Creates a new block
  43379. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  43380. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  43381. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43382. * @param depth defines the current depth of this block in the octree
  43383. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  43384. * @param creationFunc defines a callback to call when an element is added to the block
  43385. */
  43386. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  43387. /**
  43388. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  43389. */
  43390. readonly capacity: number;
  43391. /**
  43392. * Gets the minimum vector (in world space) of the block's bounding box
  43393. */
  43394. readonly minPoint: Vector3;
  43395. /**
  43396. * Gets the maximum vector (in world space) of the block's bounding box
  43397. */
  43398. readonly maxPoint: Vector3;
  43399. /**
  43400. * Add a new element to this block
  43401. * @param entry defines the element to add
  43402. */
  43403. addEntry(entry: T): void;
  43404. /**
  43405. * Remove an element from this block
  43406. * @param entry defines the element to remove
  43407. */
  43408. removeEntry(entry: T): void;
  43409. /**
  43410. * Add an array of elements to this block
  43411. * @param entries defines the array of elements to add
  43412. */
  43413. addEntries(entries: T[]): void;
  43414. /**
  43415. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  43416. * @param frustumPlanes defines the frustum planes to test
  43417. * @param selection defines the array to store current content if selection is positive
  43418. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43419. */
  43420. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43421. /**
  43422. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  43423. * @param sphereCenter defines the bounding sphere center
  43424. * @param sphereRadius defines the bounding sphere radius
  43425. * @param selection defines the array to store current content if selection is positive
  43426. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43427. */
  43428. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  43429. /**
  43430. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  43431. * @param ray defines the ray to test with
  43432. * @param selection defines the array to store current content if selection is positive
  43433. */
  43434. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  43435. /**
  43436. * Subdivide the content into child blocks (this block will then be empty)
  43437. */
  43438. createInnerBlocks(): void;
  43439. /**
  43440. * @hidden
  43441. */
  43442. 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;
  43443. }
  43444. }
  43445. declare module "babylonjs/Culling/Octrees/octree" {
  43446. import { SmartArray } from "babylonjs/Misc/smartArray";
  43447. import { Vector3 } from "babylonjs/Maths/math.vector";
  43448. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43450. import { Ray } from "babylonjs/Culling/ray";
  43451. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  43452. import { Plane } from "babylonjs/Maths/math.plane";
  43453. /**
  43454. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  43455. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43456. */
  43457. export class Octree<T> {
  43458. /** 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.) */
  43459. maxDepth: number;
  43460. /**
  43461. * Blocks within the octree containing objects
  43462. */
  43463. blocks: Array<OctreeBlock<T>>;
  43464. /**
  43465. * Content stored in the octree
  43466. */
  43467. dynamicContent: T[];
  43468. private _maxBlockCapacity;
  43469. private _selectionContent;
  43470. private _creationFunc;
  43471. /**
  43472. * Creates a octree
  43473. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43474. * @param creationFunc function to be used to instatiate the octree
  43475. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  43476. * @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.)
  43477. */
  43478. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  43479. /** 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.) */
  43480. maxDepth?: number);
  43481. /**
  43482. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  43483. * @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);
  43484. * @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);
  43485. * @param entries meshes to be added to the octree blocks
  43486. */
  43487. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  43488. /**
  43489. * Adds a mesh to the octree
  43490. * @param entry Mesh to add to the octree
  43491. */
  43492. addMesh(entry: T): void;
  43493. /**
  43494. * Remove an element from the octree
  43495. * @param entry defines the element to remove
  43496. */
  43497. removeMesh(entry: T): void;
  43498. /**
  43499. * Selects an array of meshes within the frustum
  43500. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  43501. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  43502. * @returns array of meshes within the frustum
  43503. */
  43504. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  43505. /**
  43506. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  43507. * @param sphereCenter defines the bounding sphere center
  43508. * @param sphereRadius defines the bounding sphere radius
  43509. * @param allowDuplicate defines if the selection array can contains duplicated entries
  43510. * @returns an array of objects that intersect the sphere
  43511. */
  43512. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  43513. /**
  43514. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  43515. * @param ray defines the ray to test with
  43516. * @returns array of intersected objects
  43517. */
  43518. intersectsRay(ray: Ray): SmartArray<T>;
  43519. /**
  43520. * Adds a mesh into the octree block if it intersects the block
  43521. */
  43522. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  43523. /**
  43524. * Adds a submesh into the octree block if it intersects the block
  43525. */
  43526. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  43527. }
  43528. }
  43529. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  43530. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  43531. import { Scene } from "babylonjs/scene";
  43532. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43534. import { Ray } from "babylonjs/Culling/ray";
  43535. import { Octree } from "babylonjs/Culling/Octrees/octree";
  43536. import { Collider } from "babylonjs/Collisions/collider";
  43537. module "babylonjs/scene" {
  43538. interface Scene {
  43539. /**
  43540. * @hidden
  43541. * Backing Filed
  43542. */
  43543. _selectionOctree: Octree<AbstractMesh>;
  43544. /**
  43545. * Gets the octree used to boost mesh selection (picking)
  43546. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43547. */
  43548. selectionOctree: Octree<AbstractMesh>;
  43549. /**
  43550. * Creates or updates the octree used to boost selection (picking)
  43551. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43552. * @param maxCapacity defines the maximum capacity per leaf
  43553. * @param maxDepth defines the maximum depth of the octree
  43554. * @returns an octree of AbstractMesh
  43555. */
  43556. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  43557. }
  43558. }
  43559. module "babylonjs/Meshes/abstractMesh" {
  43560. interface AbstractMesh {
  43561. /**
  43562. * @hidden
  43563. * Backing Field
  43564. */
  43565. _submeshesOctree: Octree<SubMesh>;
  43566. /**
  43567. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  43568. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  43569. * @param maxCapacity defines the maximum size of each block (64 by default)
  43570. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  43571. * @returns the new octree
  43572. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  43573. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43574. */
  43575. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  43576. }
  43577. }
  43578. /**
  43579. * Defines the octree scene component responsible to manage any octrees
  43580. * in a given scene.
  43581. */
  43582. export class OctreeSceneComponent {
  43583. /**
  43584. * The component name help to identify the component in the list of scene components.
  43585. */
  43586. readonly name: string;
  43587. /**
  43588. * The scene the component belongs to.
  43589. */
  43590. scene: Scene;
  43591. /**
  43592. * Indicates if the meshes have been checked to make sure they are isEnabled()
  43593. */
  43594. readonly checksIsEnabled: boolean;
  43595. /**
  43596. * Creates a new instance of the component for the given scene
  43597. * @param scene Defines the scene to register the component in
  43598. */
  43599. constructor(scene: Scene);
  43600. /**
  43601. * Registers the component in a given scene
  43602. */
  43603. register(): void;
  43604. /**
  43605. * Return the list of active meshes
  43606. * @returns the list of active meshes
  43607. */
  43608. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43609. /**
  43610. * Return the list of active sub meshes
  43611. * @param mesh The mesh to get the candidates sub meshes from
  43612. * @returns the list of active sub meshes
  43613. */
  43614. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43615. private _tempRay;
  43616. /**
  43617. * Return the list of sub meshes intersecting with a given local ray
  43618. * @param mesh defines the mesh to find the submesh for
  43619. * @param localRay defines the ray in local space
  43620. * @returns the list of intersecting sub meshes
  43621. */
  43622. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  43623. /**
  43624. * Return the list of sub meshes colliding with a collider
  43625. * @param mesh defines the mesh to find the submesh for
  43626. * @param collider defines the collider to evaluate the collision against
  43627. * @returns the list of colliding sub meshes
  43628. */
  43629. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  43630. /**
  43631. * Rebuilds the elements related to this component in case of
  43632. * context lost for instance.
  43633. */
  43634. rebuild(): void;
  43635. /**
  43636. * Disposes the component and the associated ressources.
  43637. */
  43638. dispose(): void;
  43639. }
  43640. }
  43641. declare module "babylonjs/Culling/Octrees/index" {
  43642. export * from "babylonjs/Culling/Octrees/octree";
  43643. export * from "babylonjs/Culling/Octrees/octreeBlock";
  43644. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  43645. }
  43646. declare module "babylonjs/Culling/index" {
  43647. export * from "babylonjs/Culling/boundingBox";
  43648. export * from "babylonjs/Culling/boundingInfo";
  43649. export * from "babylonjs/Culling/boundingSphere";
  43650. export * from "babylonjs/Culling/Octrees/index";
  43651. export * from "babylonjs/Culling/ray";
  43652. }
  43653. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  43654. import { IDisposable, Scene } from "babylonjs/scene";
  43655. import { Nullable } from "babylonjs/types";
  43656. import { Observable } from "babylonjs/Misc/observable";
  43657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43658. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  43659. import { Camera } from "babylonjs/Cameras/camera";
  43660. /**
  43661. * Renders a layer on top of an existing scene
  43662. */
  43663. export class UtilityLayerRenderer implements IDisposable {
  43664. /** the original scene that will be rendered on top of */
  43665. originalScene: Scene;
  43666. private _pointerCaptures;
  43667. private _lastPointerEvents;
  43668. private static _DefaultUtilityLayer;
  43669. private static _DefaultKeepDepthUtilityLayer;
  43670. private _sharedGizmoLight;
  43671. private _renderCamera;
  43672. /**
  43673. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  43674. * @returns the camera that is used when rendering the utility layer
  43675. */
  43676. getRenderCamera(): Nullable<Camera>;
  43677. /**
  43678. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  43679. * @param cam the camera that should be used when rendering the utility layer
  43680. */
  43681. setRenderCamera(cam: Nullable<Camera>): void;
  43682. /**
  43683. * @hidden
  43684. * Light which used by gizmos to get light shading
  43685. */
  43686. _getSharedGizmoLight(): HemisphericLight;
  43687. /**
  43688. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  43689. */
  43690. pickUtilitySceneFirst: boolean;
  43691. /**
  43692. * 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)
  43693. */
  43694. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  43695. /**
  43696. * 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)
  43697. */
  43698. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  43699. /**
  43700. * The scene that is rendered on top of the original scene
  43701. */
  43702. utilityLayerScene: Scene;
  43703. /**
  43704. * If the utility layer should automatically be rendered on top of existing scene
  43705. */
  43706. shouldRender: boolean;
  43707. /**
  43708. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  43709. */
  43710. onlyCheckPointerDownEvents: boolean;
  43711. /**
  43712. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  43713. */
  43714. processAllEvents: boolean;
  43715. /**
  43716. * Observable raised when the pointer move from the utility layer scene to the main scene
  43717. */
  43718. onPointerOutObservable: Observable<number>;
  43719. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  43720. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  43721. private _afterRenderObserver;
  43722. private _sceneDisposeObserver;
  43723. private _originalPointerObserver;
  43724. /**
  43725. * Instantiates a UtilityLayerRenderer
  43726. * @param originalScene the original scene that will be rendered on top of
  43727. * @param handleEvents boolean indicating if the utility layer should handle events
  43728. */
  43729. constructor(
  43730. /** the original scene that will be rendered on top of */
  43731. originalScene: Scene, handleEvents?: boolean);
  43732. private _notifyObservers;
  43733. /**
  43734. * Renders the utility layers scene on top of the original scene
  43735. */
  43736. render(): void;
  43737. /**
  43738. * Disposes of the renderer
  43739. */
  43740. dispose(): void;
  43741. private _updateCamera;
  43742. }
  43743. }
  43744. declare module "babylonjs/Gizmos/gizmo" {
  43745. import { Nullable } from "babylonjs/types";
  43746. import { IDisposable } from "babylonjs/scene";
  43747. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43748. import { Mesh } from "babylonjs/Meshes/mesh";
  43749. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43750. /**
  43751. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  43752. */
  43753. export class Gizmo implements IDisposable {
  43754. /** The utility layer the gizmo will be added to */
  43755. gizmoLayer: UtilityLayerRenderer;
  43756. /**
  43757. * The root mesh of the gizmo
  43758. */
  43759. _rootMesh: Mesh;
  43760. private _attachedMesh;
  43761. /**
  43762. * Ratio for the scale of the gizmo (Default: 1)
  43763. */
  43764. scaleRatio: number;
  43765. /**
  43766. * If a custom mesh has been set (Default: false)
  43767. */
  43768. protected _customMeshSet: boolean;
  43769. /**
  43770. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  43771. * * When set, interactions will be enabled
  43772. */
  43773. attachedMesh: Nullable<AbstractMesh>;
  43774. /**
  43775. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43776. * @param mesh The mesh to replace the default mesh of the gizmo
  43777. */
  43778. setCustomMesh(mesh: Mesh): void;
  43779. /**
  43780. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  43781. */
  43782. updateGizmoRotationToMatchAttachedMesh: boolean;
  43783. /**
  43784. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  43785. */
  43786. updateGizmoPositionToMatchAttachedMesh: boolean;
  43787. /**
  43788. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  43789. */
  43790. updateScale: boolean;
  43791. protected _interactionsEnabled: boolean;
  43792. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43793. private _beforeRenderObserver;
  43794. private _tempVector;
  43795. /**
  43796. * Creates a gizmo
  43797. * @param gizmoLayer The utility layer the gizmo will be added to
  43798. */
  43799. constructor(
  43800. /** The utility layer the gizmo will be added to */
  43801. gizmoLayer?: UtilityLayerRenderer);
  43802. /**
  43803. * Updates the gizmo to match the attached mesh's position/rotation
  43804. */
  43805. protected _update(): void;
  43806. /**
  43807. * Disposes of the gizmo
  43808. */
  43809. dispose(): void;
  43810. }
  43811. }
  43812. declare module "babylonjs/Gizmos/planeDragGizmo" {
  43813. import { Observable } from "babylonjs/Misc/observable";
  43814. import { Nullable } from "babylonjs/types";
  43815. import { Vector3 } from "babylonjs/Maths/math.vector";
  43816. import { Color3 } from "babylonjs/Maths/math.color";
  43817. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43819. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43820. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43821. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43822. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43823. import { Scene } from "babylonjs/scene";
  43824. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43825. /**
  43826. * Single plane drag gizmo
  43827. */
  43828. export class PlaneDragGizmo extends Gizmo {
  43829. /**
  43830. * Drag behavior responsible for the gizmos dragging interactions
  43831. */
  43832. dragBehavior: PointerDragBehavior;
  43833. private _pointerObserver;
  43834. /**
  43835. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43836. */
  43837. snapDistance: number;
  43838. /**
  43839. * Event that fires each time the gizmo snaps to a new location.
  43840. * * snapDistance is the the change in distance
  43841. */
  43842. onSnapObservable: Observable<{
  43843. snapDistance: number;
  43844. }>;
  43845. private _plane;
  43846. private _coloredMaterial;
  43847. private _hoverMaterial;
  43848. private _isEnabled;
  43849. private _parent;
  43850. /** @hidden */
  43851. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  43852. /** @hidden */
  43853. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43854. /**
  43855. * Creates a PlaneDragGizmo
  43856. * @param gizmoLayer The utility layer the gizmo will be added to
  43857. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  43858. * @param color The color of the gizmo
  43859. */
  43860. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  43861. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43862. /**
  43863. * If the gizmo is enabled
  43864. */
  43865. isEnabled: boolean;
  43866. /**
  43867. * Disposes of the gizmo
  43868. */
  43869. dispose(): void;
  43870. }
  43871. }
  43872. declare module "babylonjs/Gizmos/positionGizmo" {
  43873. import { Observable } from "babylonjs/Misc/observable";
  43874. import { Nullable } from "babylonjs/types";
  43875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43876. import { Mesh } from "babylonjs/Meshes/mesh";
  43877. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43878. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  43879. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  43880. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43881. /**
  43882. * Gizmo that enables dragging a mesh along 3 axis
  43883. */
  43884. export class PositionGizmo extends Gizmo {
  43885. /**
  43886. * Internal gizmo used for interactions on the x axis
  43887. */
  43888. xGizmo: AxisDragGizmo;
  43889. /**
  43890. * Internal gizmo used for interactions on the y axis
  43891. */
  43892. yGizmo: AxisDragGizmo;
  43893. /**
  43894. * Internal gizmo used for interactions on the z axis
  43895. */
  43896. zGizmo: AxisDragGizmo;
  43897. /**
  43898. * Internal gizmo used for interactions on the yz plane
  43899. */
  43900. xPlaneGizmo: PlaneDragGizmo;
  43901. /**
  43902. * Internal gizmo used for interactions on the xz plane
  43903. */
  43904. yPlaneGizmo: PlaneDragGizmo;
  43905. /**
  43906. * Internal gizmo used for interactions on the xy plane
  43907. */
  43908. zPlaneGizmo: PlaneDragGizmo;
  43909. /**
  43910. * private variables
  43911. */
  43912. private _meshAttached;
  43913. private _updateGizmoRotationToMatchAttachedMesh;
  43914. private _snapDistance;
  43915. private _scaleRatio;
  43916. /** Fires an event when any of it's sub gizmos are dragged */
  43917. onDragStartObservable: Observable<unknown>;
  43918. /** Fires an event when any of it's sub gizmos are released from dragging */
  43919. onDragEndObservable: Observable<unknown>;
  43920. /**
  43921. * If set to true, planar drag is enabled
  43922. */
  43923. private _planarGizmoEnabled;
  43924. attachedMesh: Nullable<AbstractMesh>;
  43925. /**
  43926. * Creates a PositionGizmo
  43927. * @param gizmoLayer The utility layer the gizmo will be added to
  43928. */
  43929. constructor(gizmoLayer?: UtilityLayerRenderer);
  43930. /**
  43931. * If the planar drag gizmo is enabled
  43932. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  43933. */
  43934. planarGizmoEnabled: boolean;
  43935. updateGizmoRotationToMatchAttachedMesh: boolean;
  43936. /**
  43937. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43938. */
  43939. snapDistance: number;
  43940. /**
  43941. * Ratio for the scale of the gizmo (Default: 1)
  43942. */
  43943. scaleRatio: number;
  43944. /**
  43945. * Disposes of the gizmo
  43946. */
  43947. dispose(): void;
  43948. /**
  43949. * CustomMeshes are not supported by this gizmo
  43950. * @param mesh The mesh to replace the default mesh of the gizmo
  43951. */
  43952. setCustomMesh(mesh: Mesh): void;
  43953. }
  43954. }
  43955. declare module "babylonjs/Gizmos/axisDragGizmo" {
  43956. import { Observable } from "babylonjs/Misc/observable";
  43957. import { Nullable } from "babylonjs/types";
  43958. import { Vector3 } from "babylonjs/Maths/math.vector";
  43959. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43961. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43962. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43963. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43964. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  43965. import { Scene } from "babylonjs/scene";
  43966. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  43967. import { Color3 } from "babylonjs/Maths/math.color";
  43968. /**
  43969. * Single axis drag gizmo
  43970. */
  43971. export class AxisDragGizmo extends Gizmo {
  43972. /**
  43973. * Drag behavior responsible for the gizmos dragging interactions
  43974. */
  43975. dragBehavior: PointerDragBehavior;
  43976. private _pointerObserver;
  43977. /**
  43978. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43979. */
  43980. snapDistance: number;
  43981. /**
  43982. * Event that fires each time the gizmo snaps to a new location.
  43983. * * snapDistance is the the change in distance
  43984. */
  43985. onSnapObservable: Observable<{
  43986. snapDistance: number;
  43987. }>;
  43988. private _isEnabled;
  43989. private _parent;
  43990. private _arrow;
  43991. private _coloredMaterial;
  43992. private _hoverMaterial;
  43993. /** @hidden */
  43994. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  43995. /** @hidden */
  43996. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  43997. /**
  43998. * Creates an AxisDragGizmo
  43999. * @param gizmoLayer The utility layer the gizmo will be added to
  44000. * @param dragAxis The axis which the gizmo will be able to drag on
  44001. * @param color The color of the gizmo
  44002. */
  44003. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44005. /**
  44006. * If the gizmo is enabled
  44007. */
  44008. isEnabled: boolean;
  44009. /**
  44010. * Disposes of the gizmo
  44011. */
  44012. dispose(): void;
  44013. }
  44014. }
  44015. declare module "babylonjs/Debug/axesViewer" {
  44016. import { Vector3 } from "babylonjs/Maths/math.vector";
  44017. import { Nullable } from "babylonjs/types";
  44018. import { Scene } from "babylonjs/scene";
  44019. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44020. /**
  44021. * The Axes viewer will show 3 axes in a specific point in space
  44022. */
  44023. export class AxesViewer {
  44024. private _xAxis;
  44025. private _yAxis;
  44026. private _zAxis;
  44027. private _scaleLinesFactor;
  44028. private _instanced;
  44029. /**
  44030. * Gets the hosting scene
  44031. */
  44032. scene: Scene;
  44033. /**
  44034. * Gets or sets a number used to scale line length
  44035. */
  44036. scaleLines: number;
  44037. /** Gets the node hierarchy used to render x-axis */
  44038. readonly xAxis: TransformNode;
  44039. /** Gets the node hierarchy used to render y-axis */
  44040. readonly yAxis: TransformNode;
  44041. /** Gets the node hierarchy used to render z-axis */
  44042. readonly zAxis: TransformNode;
  44043. /**
  44044. * Creates a new AxesViewer
  44045. * @param scene defines the hosting scene
  44046. * @param scaleLines defines a number used to scale line length (1 by default)
  44047. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44048. * @param xAxis defines the node hierarchy used to render the x-axis
  44049. * @param yAxis defines the node hierarchy used to render the y-axis
  44050. * @param zAxis defines the node hierarchy used to render the z-axis
  44051. */
  44052. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44053. /**
  44054. * Force the viewer to update
  44055. * @param position defines the position of the viewer
  44056. * @param xaxis defines the x axis of the viewer
  44057. * @param yaxis defines the y axis of the viewer
  44058. * @param zaxis defines the z axis of the viewer
  44059. */
  44060. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44061. /**
  44062. * Creates an instance of this axes viewer.
  44063. * @returns a new axes viewer with instanced meshes
  44064. */
  44065. createInstance(): AxesViewer;
  44066. /** Releases resources */
  44067. dispose(): void;
  44068. private static _SetRenderingGroupId;
  44069. }
  44070. }
  44071. declare module "babylonjs/Debug/boneAxesViewer" {
  44072. import { Nullable } from "babylonjs/types";
  44073. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44074. import { Vector3 } from "babylonjs/Maths/math.vector";
  44075. import { Mesh } from "babylonjs/Meshes/mesh";
  44076. import { Bone } from "babylonjs/Bones/bone";
  44077. import { Scene } from "babylonjs/scene";
  44078. /**
  44079. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44080. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44081. */
  44082. export class BoneAxesViewer extends AxesViewer {
  44083. /**
  44084. * Gets or sets the target mesh where to display the axes viewer
  44085. */
  44086. mesh: Nullable<Mesh>;
  44087. /**
  44088. * Gets or sets the target bone where to display the axes viewer
  44089. */
  44090. bone: Nullable<Bone>;
  44091. /** Gets current position */
  44092. pos: Vector3;
  44093. /** Gets direction of X axis */
  44094. xaxis: Vector3;
  44095. /** Gets direction of Y axis */
  44096. yaxis: Vector3;
  44097. /** Gets direction of Z axis */
  44098. zaxis: Vector3;
  44099. /**
  44100. * Creates a new BoneAxesViewer
  44101. * @param scene defines the hosting scene
  44102. * @param bone defines the target bone
  44103. * @param mesh defines the target mesh
  44104. * @param scaleLines defines a scaling factor for line length (1 by default)
  44105. */
  44106. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44107. /**
  44108. * Force the viewer to update
  44109. */
  44110. update(): void;
  44111. /** Releases resources */
  44112. dispose(): void;
  44113. }
  44114. }
  44115. declare module "babylonjs/Debug/debugLayer" {
  44116. import { Scene } from "babylonjs/scene";
  44117. /**
  44118. * Interface used to define scene explorer extensibility option
  44119. */
  44120. export interface IExplorerExtensibilityOption {
  44121. /**
  44122. * Define the option label
  44123. */
  44124. label: string;
  44125. /**
  44126. * Defines the action to execute on click
  44127. */
  44128. action: (entity: any) => void;
  44129. }
  44130. /**
  44131. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44132. */
  44133. export interface IExplorerExtensibilityGroup {
  44134. /**
  44135. * Defines a predicate to test if a given type mut be extended
  44136. */
  44137. predicate: (entity: any) => boolean;
  44138. /**
  44139. * Gets the list of options added to a type
  44140. */
  44141. entries: IExplorerExtensibilityOption[];
  44142. }
  44143. /**
  44144. * Interface used to define the options to use to create the Inspector
  44145. */
  44146. export interface IInspectorOptions {
  44147. /**
  44148. * Display in overlay mode (default: false)
  44149. */
  44150. overlay?: boolean;
  44151. /**
  44152. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44153. */
  44154. globalRoot?: HTMLElement;
  44155. /**
  44156. * Display the Scene explorer
  44157. */
  44158. showExplorer?: boolean;
  44159. /**
  44160. * Display the property inspector
  44161. */
  44162. showInspector?: boolean;
  44163. /**
  44164. * Display in embed mode (both panes on the right)
  44165. */
  44166. embedMode?: boolean;
  44167. /**
  44168. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44169. */
  44170. handleResize?: boolean;
  44171. /**
  44172. * Allow the panes to popup (default: true)
  44173. */
  44174. enablePopup?: boolean;
  44175. /**
  44176. * Allow the panes to be closed by users (default: true)
  44177. */
  44178. enableClose?: boolean;
  44179. /**
  44180. * Optional list of extensibility entries
  44181. */
  44182. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44183. /**
  44184. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44185. */
  44186. inspectorURL?: string;
  44187. }
  44188. module "babylonjs/scene" {
  44189. interface Scene {
  44190. /**
  44191. * @hidden
  44192. * Backing field
  44193. */
  44194. _debugLayer: DebugLayer;
  44195. /**
  44196. * Gets the debug layer (aka Inspector) associated with the scene
  44197. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44198. */
  44199. debugLayer: DebugLayer;
  44200. }
  44201. }
  44202. /**
  44203. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44204. * what is happening in your scene
  44205. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44206. */
  44207. export class DebugLayer {
  44208. /**
  44209. * Define the url to get the inspector script from.
  44210. * By default it uses the babylonjs CDN.
  44211. * @ignoreNaming
  44212. */
  44213. static InspectorURL: string;
  44214. private _scene;
  44215. private BJSINSPECTOR;
  44216. private _onPropertyChangedObservable?;
  44217. /**
  44218. * Observable triggered when a property is changed through the inspector.
  44219. */
  44220. readonly onPropertyChangedObservable: any;
  44221. /**
  44222. * Instantiates a new debug layer.
  44223. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44224. * what is happening in your scene
  44225. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44226. * @param scene Defines the scene to inspect
  44227. */
  44228. constructor(scene: Scene);
  44229. /** Creates the inspector window. */
  44230. private _createInspector;
  44231. /**
  44232. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44233. * @param entity defines the entity to select
  44234. * @param lineContainerTitle defines the specific block to highlight
  44235. */
  44236. select(entity: any, lineContainerTitle?: string): void;
  44237. /** Get the inspector from bundle or global */
  44238. private _getGlobalInspector;
  44239. /**
  44240. * Get if the inspector is visible or not.
  44241. * @returns true if visible otherwise, false
  44242. */
  44243. isVisible(): boolean;
  44244. /**
  44245. * Hide the inspector and close its window.
  44246. */
  44247. hide(): void;
  44248. /**
  44249. * Launch the debugLayer.
  44250. * @param config Define the configuration of the inspector
  44251. * @return a promise fulfilled when the debug layer is visible
  44252. */
  44253. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44254. }
  44255. }
  44256. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44257. import { Nullable } from "babylonjs/types";
  44258. import { Scene } from "babylonjs/scene";
  44259. import { Vector4 } from "babylonjs/Maths/math.vector";
  44260. import { Color4 } from "babylonjs/Maths/math.color";
  44261. import { Mesh } from "babylonjs/Meshes/mesh";
  44262. /**
  44263. * Class containing static functions to help procedurally build meshes
  44264. */
  44265. export class BoxBuilder {
  44266. /**
  44267. * Creates a box mesh
  44268. * * The parameter `size` sets the size (float) of each box side (default 1)
  44269. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44270. * * 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)
  44271. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44272. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44273. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44274. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44275. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44276. * @param name defines the name of the mesh
  44277. * @param options defines the options used to create the mesh
  44278. * @param scene defines the hosting scene
  44279. * @returns the box mesh
  44280. */
  44281. static CreateBox(name: string, options: {
  44282. size?: number;
  44283. width?: number;
  44284. height?: number;
  44285. depth?: number;
  44286. faceUV?: Vector4[];
  44287. faceColors?: Color4[];
  44288. sideOrientation?: number;
  44289. frontUVs?: Vector4;
  44290. backUVs?: Vector4;
  44291. wrap?: boolean;
  44292. topBaseAt?: number;
  44293. bottomBaseAt?: number;
  44294. updatable?: boolean;
  44295. }, scene?: Nullable<Scene>): Mesh;
  44296. }
  44297. }
  44298. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44299. import { Vector4 } from "babylonjs/Maths/math.vector";
  44300. import { Mesh } from "babylonjs/Meshes/mesh";
  44301. /**
  44302. * Class containing static functions to help procedurally build meshes
  44303. */
  44304. export class SphereBuilder {
  44305. /**
  44306. * Creates a sphere mesh
  44307. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44308. * * 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`)
  44309. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44310. * * 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
  44311. * * 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)
  44312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44315. * @param name defines the name of the mesh
  44316. * @param options defines the options used to create the mesh
  44317. * @param scene defines the hosting scene
  44318. * @returns the sphere mesh
  44319. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44320. */
  44321. static CreateSphere(name: string, options: {
  44322. segments?: number;
  44323. diameter?: number;
  44324. diameterX?: number;
  44325. diameterY?: number;
  44326. diameterZ?: number;
  44327. arc?: number;
  44328. slice?: number;
  44329. sideOrientation?: number;
  44330. frontUVs?: Vector4;
  44331. backUVs?: Vector4;
  44332. updatable?: boolean;
  44333. }, scene: any): Mesh;
  44334. }
  44335. }
  44336. declare module "babylonjs/Debug/physicsViewer" {
  44337. import { Nullable } from "babylonjs/types";
  44338. import { Scene } from "babylonjs/scene";
  44339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44340. import { Mesh } from "babylonjs/Meshes/mesh";
  44341. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44342. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44343. /**
  44344. * Used to show the physics impostor around the specific mesh
  44345. */
  44346. export class PhysicsViewer {
  44347. /** @hidden */
  44348. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44349. /** @hidden */
  44350. protected _meshes: Array<Nullable<AbstractMesh>>;
  44351. /** @hidden */
  44352. protected _scene: Nullable<Scene>;
  44353. /** @hidden */
  44354. protected _numMeshes: number;
  44355. /** @hidden */
  44356. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44357. private _renderFunction;
  44358. private _utilityLayer;
  44359. private _debugBoxMesh;
  44360. private _debugSphereMesh;
  44361. private _debugCylinderMesh;
  44362. private _debugMaterial;
  44363. private _debugMeshMeshes;
  44364. /**
  44365. * Creates a new PhysicsViewer
  44366. * @param scene defines the hosting scene
  44367. */
  44368. constructor(scene: Scene);
  44369. /** @hidden */
  44370. protected _updateDebugMeshes(): void;
  44371. /**
  44372. * Renders a specified physic impostor
  44373. * @param impostor defines the impostor to render
  44374. * @param targetMesh defines the mesh represented by the impostor
  44375. * @returns the new debug mesh used to render the impostor
  44376. */
  44377. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  44378. /**
  44379. * Hides a specified physic impostor
  44380. * @param impostor defines the impostor to hide
  44381. */
  44382. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  44383. private _getDebugMaterial;
  44384. private _getDebugBoxMesh;
  44385. private _getDebugSphereMesh;
  44386. private _getDebugCylinderMesh;
  44387. private _getDebugMeshMesh;
  44388. private _getDebugMesh;
  44389. /** Releases all resources */
  44390. dispose(): void;
  44391. }
  44392. }
  44393. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  44394. import { Vector3 } from "babylonjs/Maths/math.vector";
  44395. import { Color4 } from "babylonjs/Maths/math.color";
  44396. import { Nullable } from "babylonjs/types";
  44397. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44398. import { Scene } from "babylonjs/scene";
  44399. /**
  44400. * Class containing static functions to help procedurally build meshes
  44401. */
  44402. export class LinesBuilder {
  44403. /**
  44404. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44405. * * 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
  44406. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44407. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44408. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44409. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44410. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44411. * * 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
  44412. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44414. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44415. * @param name defines the name of the new line system
  44416. * @param options defines the options used to create the line system
  44417. * @param scene defines the hosting scene
  44418. * @returns a new line system mesh
  44419. */
  44420. static CreateLineSystem(name: string, options: {
  44421. lines: Vector3[][];
  44422. updatable?: boolean;
  44423. instance?: Nullable<LinesMesh>;
  44424. colors?: Nullable<Color4[][]>;
  44425. useVertexAlpha?: boolean;
  44426. }, scene: Nullable<Scene>): LinesMesh;
  44427. /**
  44428. * Creates a line mesh
  44429. * 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
  44430. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44431. * * The parameter `points` is an array successive Vector3
  44432. * * 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
  44433. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44434. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44435. * * When updating an instance, remember that only point positions can change, not the number of points
  44436. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44437. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44438. * @param name defines the name of the new line system
  44439. * @param options defines the options used to create the line system
  44440. * @param scene defines the hosting scene
  44441. * @returns a new line mesh
  44442. */
  44443. static CreateLines(name: string, options: {
  44444. points: Vector3[];
  44445. updatable?: boolean;
  44446. instance?: Nullable<LinesMesh>;
  44447. colors?: Color4[];
  44448. useVertexAlpha?: boolean;
  44449. }, scene?: Nullable<Scene>): LinesMesh;
  44450. /**
  44451. * Creates a dashed line mesh
  44452. * * 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
  44453. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44454. * * The parameter `points` is an array successive Vector3
  44455. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44456. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44457. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44458. * * 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
  44459. * * When updating an instance, remember that only point positions can change, not the number of points
  44460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44461. * @param name defines the name of the mesh
  44462. * @param options defines the options used to create the mesh
  44463. * @param scene defines the hosting scene
  44464. * @returns the dashed line mesh
  44465. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44466. */
  44467. static CreateDashedLines(name: string, options: {
  44468. points: Vector3[];
  44469. dashSize?: number;
  44470. gapSize?: number;
  44471. dashNb?: number;
  44472. updatable?: boolean;
  44473. instance?: LinesMesh;
  44474. }, scene?: Nullable<Scene>): LinesMesh;
  44475. }
  44476. }
  44477. declare module "babylonjs/Debug/rayHelper" {
  44478. import { Nullable } from "babylonjs/types";
  44479. import { Ray } from "babylonjs/Culling/ray";
  44480. import { Vector3 } from "babylonjs/Maths/math.vector";
  44481. import { Color3 } from "babylonjs/Maths/math.color";
  44482. import { Scene } from "babylonjs/scene";
  44483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44484. import "babylonjs/Meshes/Builders/linesBuilder";
  44485. /**
  44486. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44487. * in order to better appreciate the issue one might have.
  44488. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44489. */
  44490. export class RayHelper {
  44491. /**
  44492. * Defines the ray we are currently tryin to visualize.
  44493. */
  44494. ray: Nullable<Ray>;
  44495. private _renderPoints;
  44496. private _renderLine;
  44497. private _renderFunction;
  44498. private _scene;
  44499. private _updateToMeshFunction;
  44500. private _attachedToMesh;
  44501. private _meshSpaceDirection;
  44502. private _meshSpaceOrigin;
  44503. /**
  44504. * Helper function to create a colored helper in a scene in one line.
  44505. * @param ray Defines the ray we are currently tryin to visualize
  44506. * @param scene Defines the scene the ray is used in
  44507. * @param color Defines the color we want to see the ray in
  44508. * @returns The newly created ray helper.
  44509. */
  44510. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  44511. /**
  44512. * Instantiate a new ray helper.
  44513. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  44514. * in order to better appreciate the issue one might have.
  44515. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  44516. * @param ray Defines the ray we are currently tryin to visualize
  44517. */
  44518. constructor(ray: Ray);
  44519. /**
  44520. * Shows the ray we are willing to debug.
  44521. * @param scene Defines the scene the ray needs to be rendered in
  44522. * @param color Defines the color the ray needs to be rendered in
  44523. */
  44524. show(scene: Scene, color?: Color3): void;
  44525. /**
  44526. * Hides the ray we are debugging.
  44527. */
  44528. hide(): void;
  44529. private _render;
  44530. /**
  44531. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  44532. * @param mesh Defines the mesh we want the helper attached to
  44533. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  44534. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  44535. * @param length Defines the length of the ray
  44536. */
  44537. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  44538. /**
  44539. * Detach the ray helper from the mesh it has previously been attached to.
  44540. */
  44541. detachFromMesh(): void;
  44542. private _updateToMesh;
  44543. /**
  44544. * Dispose the helper and release its associated resources.
  44545. */
  44546. dispose(): void;
  44547. }
  44548. }
  44549. declare module "babylonjs/Debug/skeletonViewer" {
  44550. import { Color3 } from "babylonjs/Maths/math.color";
  44551. import { Scene } from "babylonjs/scene";
  44552. import { Nullable } from "babylonjs/types";
  44553. import { Skeleton } from "babylonjs/Bones/skeleton";
  44554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44555. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  44556. /**
  44557. * Class used to render a debug view of a given skeleton
  44558. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  44559. */
  44560. export class SkeletonViewer {
  44561. /** defines the skeleton to render */
  44562. skeleton: Skeleton;
  44563. /** defines the mesh attached to the skeleton */
  44564. mesh: AbstractMesh;
  44565. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44566. autoUpdateBonesMatrices: boolean;
  44567. /** defines the rendering group id to use with the viewer */
  44568. renderingGroupId: number;
  44569. /** Gets or sets the color used to render the skeleton */
  44570. color: Color3;
  44571. private _scene;
  44572. private _debugLines;
  44573. private _debugMesh;
  44574. private _isEnabled;
  44575. private _renderFunction;
  44576. private _utilityLayer;
  44577. /**
  44578. * Returns the mesh used to render the bones
  44579. */
  44580. readonly debugMesh: Nullable<LinesMesh>;
  44581. /**
  44582. * Creates a new SkeletonViewer
  44583. * @param skeleton defines the skeleton to render
  44584. * @param mesh defines the mesh attached to the skeleton
  44585. * @param scene defines the hosting scene
  44586. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  44587. * @param renderingGroupId defines the rendering group id to use with the viewer
  44588. */
  44589. constructor(
  44590. /** defines the skeleton to render */
  44591. skeleton: Skeleton,
  44592. /** defines the mesh attached to the skeleton */
  44593. mesh: AbstractMesh, scene: Scene,
  44594. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  44595. autoUpdateBonesMatrices?: boolean,
  44596. /** defines the rendering group id to use with the viewer */
  44597. renderingGroupId?: number);
  44598. /** Gets or sets a boolean indicating if the viewer is enabled */
  44599. isEnabled: boolean;
  44600. private _getBonePosition;
  44601. private _getLinesForBonesWithLength;
  44602. private _getLinesForBonesNoLength;
  44603. /** Update the viewer to sync with current skeleton state */
  44604. update(): void;
  44605. /** Release associated resources */
  44606. dispose(): void;
  44607. }
  44608. }
  44609. declare module "babylonjs/Debug/index" {
  44610. export * from "babylonjs/Debug/axesViewer";
  44611. export * from "babylonjs/Debug/boneAxesViewer";
  44612. export * from "babylonjs/Debug/debugLayer";
  44613. export * from "babylonjs/Debug/physicsViewer";
  44614. export * from "babylonjs/Debug/rayHelper";
  44615. export * from "babylonjs/Debug/skeletonViewer";
  44616. }
  44617. declare module "babylonjs/Engines/nullEngine" {
  44618. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  44619. import { Scene } from "babylonjs/scene";
  44620. import { Engine } from "babylonjs/Engines/engine";
  44621. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  44622. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  44623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  44624. import { Effect } from "babylonjs/Materials/effect";
  44625. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  44626. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44627. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  44628. /**
  44629. * Options to create the null engine
  44630. */
  44631. export class NullEngineOptions {
  44632. /**
  44633. * Render width (Default: 512)
  44634. */
  44635. renderWidth: number;
  44636. /**
  44637. * Render height (Default: 256)
  44638. */
  44639. renderHeight: number;
  44640. /**
  44641. * Texture size (Default: 512)
  44642. */
  44643. textureSize: number;
  44644. /**
  44645. * If delta time between frames should be constant
  44646. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44647. */
  44648. deterministicLockstep: boolean;
  44649. /**
  44650. * Maximum about of steps between frames (Default: 4)
  44651. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44652. */
  44653. lockstepMaxSteps: number;
  44654. }
  44655. /**
  44656. * The null engine class provides support for headless version of babylon.js.
  44657. * This can be used in server side scenario or for testing purposes
  44658. */
  44659. export class NullEngine extends Engine {
  44660. private _options;
  44661. /**
  44662. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44663. */
  44664. isDeterministicLockStep(): boolean;
  44665. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  44666. getLockstepMaxSteps(): number;
  44667. /**
  44668. * Sets hardware scaling, used to save performance if needed
  44669. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  44670. */
  44671. getHardwareScalingLevel(): number;
  44672. constructor(options?: NullEngineOptions);
  44673. createVertexBuffer(vertices: FloatArray): DataBuffer;
  44674. createIndexBuffer(indices: IndicesArray): DataBuffer;
  44675. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44676. getRenderWidth(useScreen?: boolean): number;
  44677. getRenderHeight(useScreen?: boolean): number;
  44678. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  44679. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  44680. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  44681. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  44682. bindSamplers(effect: Effect): void;
  44683. enableEffect(effect: Effect): void;
  44684. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  44685. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  44686. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  44687. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  44688. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  44689. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  44690. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  44691. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  44692. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  44693. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  44694. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  44695. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  44696. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  44697. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  44698. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44699. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  44700. setFloat(uniform: WebGLUniformLocation, value: number): void;
  44701. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  44702. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  44703. setBool(uniform: WebGLUniformLocation, bool: number): void;
  44704. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  44705. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  44706. bindBuffers(vertexBuffers: {
  44707. [key: string]: VertexBuffer;
  44708. }, indexBuffer: DataBuffer, effect: Effect): void;
  44709. wipeCaches(bruteForce?: boolean): void;
  44710. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  44711. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  44712. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  44713. /** @hidden */
  44714. _createTexture(): WebGLTexture;
  44715. /** @hidden */
  44716. _releaseTexture(texture: InternalTexture): void;
  44717. 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;
  44718. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  44719. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  44720. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  44721. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  44722. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  44723. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  44724. areAllEffectsReady(): boolean;
  44725. /**
  44726. * @hidden
  44727. * Get the current error code of the webGL context
  44728. * @returns the error code
  44729. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  44730. */
  44731. getError(): number;
  44732. /** @hidden */
  44733. _getUnpackAlignement(): number;
  44734. /** @hidden */
  44735. _unpackFlipY(value: boolean): void;
  44736. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  44737. /**
  44738. * Updates a dynamic vertex buffer.
  44739. * @param vertexBuffer the vertex buffer to update
  44740. * @param data the data used to update the vertex buffer
  44741. * @param byteOffset the byte offset of the data (optional)
  44742. * @param byteLength the byte length of the data (optional)
  44743. */
  44744. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  44745. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  44746. /** @hidden */
  44747. _bindTexture(channel: number, texture: InternalTexture): void;
  44748. /** @hidden */
  44749. _releaseBuffer(buffer: DataBuffer): boolean;
  44750. releaseEffects(): void;
  44751. displayLoadingUI(): void;
  44752. hideLoadingUI(): void;
  44753. /** @hidden */
  44754. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44755. /** @hidden */
  44756. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44757. /** @hidden */
  44758. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  44759. /** @hidden */
  44760. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  44761. }
  44762. }
  44763. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  44764. import { Nullable, int } from "babylonjs/types";
  44765. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  44766. /** @hidden */
  44767. export class _OcclusionDataStorage {
  44768. /** @hidden */
  44769. occlusionInternalRetryCounter: number;
  44770. /** @hidden */
  44771. isOcclusionQueryInProgress: boolean;
  44772. /** @hidden */
  44773. isOccluded: boolean;
  44774. /** @hidden */
  44775. occlusionRetryCount: number;
  44776. /** @hidden */
  44777. occlusionType: number;
  44778. /** @hidden */
  44779. occlusionQueryAlgorithmType: number;
  44780. }
  44781. module "babylonjs/Engines/engine" {
  44782. interface Engine {
  44783. /**
  44784. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  44785. * @return the new query
  44786. */
  44787. createQuery(): WebGLQuery;
  44788. /**
  44789. * Delete and release a webGL query
  44790. * @param query defines the query to delete
  44791. * @return the current engine
  44792. */
  44793. deleteQuery(query: WebGLQuery): Engine;
  44794. /**
  44795. * Check if a given query has resolved and got its value
  44796. * @param query defines the query to check
  44797. * @returns true if the query got its value
  44798. */
  44799. isQueryResultAvailable(query: WebGLQuery): boolean;
  44800. /**
  44801. * Gets the value of a given query
  44802. * @param query defines the query to check
  44803. * @returns the value of the query
  44804. */
  44805. getQueryResult(query: WebGLQuery): number;
  44806. /**
  44807. * Initiates an occlusion query
  44808. * @param algorithmType defines the algorithm to use
  44809. * @param query defines the query to use
  44810. * @returns the current engine
  44811. * @see http://doc.babylonjs.com/features/occlusionquery
  44812. */
  44813. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  44814. /**
  44815. * Ends an occlusion query
  44816. * @see http://doc.babylonjs.com/features/occlusionquery
  44817. * @param algorithmType defines the algorithm to use
  44818. * @returns the current engine
  44819. */
  44820. endOcclusionQuery(algorithmType: number): Engine;
  44821. /**
  44822. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  44823. * Please note that only one query can be issued at a time
  44824. * @returns a time token used to track the time span
  44825. */
  44826. startTimeQuery(): Nullable<_TimeToken>;
  44827. /**
  44828. * Ends a time query
  44829. * @param token defines the token used to measure the time span
  44830. * @returns the time spent (in ns)
  44831. */
  44832. endTimeQuery(token: _TimeToken): int;
  44833. /** @hidden */
  44834. _currentNonTimestampToken: Nullable<_TimeToken>;
  44835. /** @hidden */
  44836. _createTimeQuery(): WebGLQuery;
  44837. /** @hidden */
  44838. _deleteTimeQuery(query: WebGLQuery): void;
  44839. /** @hidden */
  44840. _getGlAlgorithmType(algorithmType: number): number;
  44841. /** @hidden */
  44842. _getTimeQueryResult(query: WebGLQuery): any;
  44843. /** @hidden */
  44844. _getTimeQueryAvailability(query: WebGLQuery): any;
  44845. }
  44846. }
  44847. module "babylonjs/Meshes/abstractMesh" {
  44848. interface AbstractMesh {
  44849. /**
  44850. * Backing filed
  44851. * @hidden
  44852. */
  44853. __occlusionDataStorage: _OcclusionDataStorage;
  44854. /**
  44855. * Access property
  44856. * @hidden
  44857. */
  44858. _occlusionDataStorage: _OcclusionDataStorage;
  44859. /**
  44860. * 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.
  44861. * The default value is -1 which means don't break the query and wait till the result
  44862. * @see http://doc.babylonjs.com/features/occlusionquery
  44863. */
  44864. occlusionRetryCount: number;
  44865. /**
  44866. * 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:
  44867. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  44868. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  44869. * * 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.
  44870. * @see http://doc.babylonjs.com/features/occlusionquery
  44871. */
  44872. occlusionType: number;
  44873. /**
  44874. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  44875. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  44876. * * 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.
  44877. * @see http://doc.babylonjs.com/features/occlusionquery
  44878. */
  44879. occlusionQueryAlgorithmType: number;
  44880. /**
  44881. * 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
  44882. * @see http://doc.babylonjs.com/features/occlusionquery
  44883. */
  44884. isOccluded: boolean;
  44885. /**
  44886. * Flag to check the progress status of the query
  44887. * @see http://doc.babylonjs.com/features/occlusionquery
  44888. */
  44889. isOcclusionQueryInProgress: boolean;
  44890. }
  44891. }
  44892. }
  44893. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  44894. import { Nullable } from "babylonjs/types";
  44895. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  44896. /** @hidden */
  44897. export var _forceTransformFeedbackToBundle: boolean;
  44898. module "babylonjs/Engines/engine" {
  44899. interface Engine {
  44900. /**
  44901. * Creates a webGL transform feedback object
  44902. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  44903. * @returns the webGL transform feedback object
  44904. */
  44905. createTransformFeedback(): WebGLTransformFeedback;
  44906. /**
  44907. * Delete a webGL transform feedback object
  44908. * @param value defines the webGL transform feedback object to delete
  44909. */
  44910. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  44911. /**
  44912. * Bind a webGL transform feedback object to the webgl context
  44913. * @param value defines the webGL transform feedback object to bind
  44914. */
  44915. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  44916. /**
  44917. * Begins a transform feedback operation
  44918. * @param usePoints defines if points or triangles must be used
  44919. */
  44920. beginTransformFeedback(usePoints: boolean): void;
  44921. /**
  44922. * Ends a transform feedback operation
  44923. */
  44924. endTransformFeedback(): void;
  44925. /**
  44926. * Specify the varyings to use with transform feedback
  44927. * @param program defines the associated webGL program
  44928. * @param value defines the list of strings representing the varying names
  44929. */
  44930. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  44931. /**
  44932. * Bind a webGL buffer for a transform feedback operation
  44933. * @param value defines the webGL buffer to bind
  44934. */
  44935. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  44936. }
  44937. }
  44938. }
  44939. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  44940. import { Scene } from "babylonjs/scene";
  44941. import { Engine } from "babylonjs/Engines/engine";
  44942. import { Texture } from "babylonjs/Materials/Textures/texture";
  44943. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44944. import "babylonjs/Engines/Extensions/engine.multiRender";
  44945. /**
  44946. * Creation options of the multi render target texture.
  44947. */
  44948. export interface IMultiRenderTargetOptions {
  44949. /**
  44950. * Define if the texture needs to create mip maps after render.
  44951. */
  44952. generateMipMaps?: boolean;
  44953. /**
  44954. * Define the types of all the draw buffers we want to create
  44955. */
  44956. types?: number[];
  44957. /**
  44958. * Define the sampling modes of all the draw buffers we want to create
  44959. */
  44960. samplingModes?: number[];
  44961. /**
  44962. * Define if a depth buffer is required
  44963. */
  44964. generateDepthBuffer?: boolean;
  44965. /**
  44966. * Define if a stencil buffer is required
  44967. */
  44968. generateStencilBuffer?: boolean;
  44969. /**
  44970. * Define if a depth texture is required instead of a depth buffer
  44971. */
  44972. generateDepthTexture?: boolean;
  44973. /**
  44974. * Define the number of desired draw buffers
  44975. */
  44976. textureCount?: number;
  44977. /**
  44978. * Define if aspect ratio should be adapted to the texture or stay the scene one
  44979. */
  44980. doNotChangeAspectRatio?: boolean;
  44981. /**
  44982. * Define the default type of the buffers we are creating
  44983. */
  44984. defaultType?: number;
  44985. }
  44986. /**
  44987. * A multi render target, like a render target provides the ability to render to a texture.
  44988. * Unlike the render target, it can render to several draw buffers in one draw.
  44989. * This is specially interesting in deferred rendering or for any effects requiring more than
  44990. * just one color from a single pass.
  44991. */
  44992. export class MultiRenderTarget extends RenderTargetTexture {
  44993. private _internalTextures;
  44994. private _textures;
  44995. private _multiRenderTargetOptions;
  44996. /**
  44997. * Get if draw buffers are currently supported by the used hardware and browser.
  44998. */
  44999. readonly isSupported: boolean;
  45000. /**
  45001. * Get the list of textures generated by the multi render target.
  45002. */
  45003. readonly textures: Texture[];
  45004. /**
  45005. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45006. */
  45007. readonly depthTexture: Texture;
  45008. /**
  45009. * Set the wrapping mode on U of all the textures we are rendering to.
  45010. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45011. */
  45012. wrapU: number;
  45013. /**
  45014. * Set the wrapping mode on V of all the textures we are rendering to.
  45015. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45016. */
  45017. wrapV: number;
  45018. /**
  45019. * Instantiate a new multi render target texture.
  45020. * A multi render target, like a render target provides the ability to render to a texture.
  45021. * Unlike the render target, it can render to several draw buffers in one draw.
  45022. * This is specially interesting in deferred rendering or for any effects requiring more than
  45023. * just one color from a single pass.
  45024. * @param name Define the name of the texture
  45025. * @param size Define the size of the buffers to render to
  45026. * @param count Define the number of target we are rendering into
  45027. * @param scene Define the scene the texture belongs to
  45028. * @param options Define the options used to create the multi render target
  45029. */
  45030. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45031. /** @hidden */
  45032. _rebuild(): void;
  45033. private _createInternalTextures;
  45034. private _createTextures;
  45035. /**
  45036. * Define the number of samples used if MSAA is enabled.
  45037. */
  45038. samples: number;
  45039. /**
  45040. * Resize all the textures in the multi render target.
  45041. * Be carrefull as it will recreate all the data in the new texture.
  45042. * @param size Define the new size
  45043. */
  45044. resize(size: any): void;
  45045. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45046. /**
  45047. * Dispose the render targets and their associated resources
  45048. */
  45049. dispose(): void;
  45050. /**
  45051. * Release all the underlying texture used as draw buffers.
  45052. */
  45053. releaseInternalTextures(): void;
  45054. }
  45055. }
  45056. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45057. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45058. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45059. import { Nullable } from "babylonjs/types";
  45060. module "babylonjs/Engines/engine" {
  45061. interface Engine {
  45062. /**
  45063. * Unbind a list of render target textures from the webGL context
  45064. * This is used only when drawBuffer extension or webGL2 are active
  45065. * @param textures defines the render target textures to unbind
  45066. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45067. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45068. */
  45069. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45070. /**
  45071. * Create a multi render target texture
  45072. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45073. * @param size defines the size of the texture
  45074. * @param options defines the creation options
  45075. * @returns the cube texture as an InternalTexture
  45076. */
  45077. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45078. /**
  45079. * Update the sample count for a given multiple render target texture
  45080. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45081. * @param textures defines the textures to update
  45082. * @param samples defines the sample count to set
  45083. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45084. */
  45085. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45086. }
  45087. }
  45088. }
  45089. declare module "babylonjs/Engines/Extensions/index" {
  45090. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  45091. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  45092. export * from "babylonjs/Engines/Extensions/engine.multiview";
  45093. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  45094. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  45095. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  45096. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  45097. export * from "babylonjs/Engines/Extensions/engine.webVR";
  45098. }
  45099. declare module "babylonjs/Engines/index" {
  45100. export * from "babylonjs/Engines/constants";
  45101. export * from "babylonjs/Engines/engine";
  45102. export * from "babylonjs/Engines/engineStore";
  45103. export * from "babylonjs/Engines/nullEngine";
  45104. export * from "babylonjs/Engines/Extensions/index";
  45105. export * from "babylonjs/Engines/IPipelineContext";
  45106. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  45107. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  45108. }
  45109. declare module "babylonjs/Events/clipboardEvents" {
  45110. /**
  45111. * Gather the list of clipboard event types as constants.
  45112. */
  45113. export class ClipboardEventTypes {
  45114. /**
  45115. * The clipboard event is fired when a copy command is active (pressed).
  45116. */
  45117. static readonly COPY: number;
  45118. /**
  45119. * The clipboard event is fired when a cut command is active (pressed).
  45120. */
  45121. static readonly CUT: number;
  45122. /**
  45123. * The clipboard event is fired when a paste command is active (pressed).
  45124. */
  45125. static readonly PASTE: number;
  45126. }
  45127. /**
  45128. * This class is used to store clipboard related info for the onClipboardObservable event.
  45129. */
  45130. export class ClipboardInfo {
  45131. /**
  45132. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45133. */
  45134. type: number;
  45135. /**
  45136. * Defines the related dom event
  45137. */
  45138. event: ClipboardEvent;
  45139. /**
  45140. *Creates an instance of ClipboardInfo.
  45141. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  45142. * @param event Defines the related dom event
  45143. */
  45144. constructor(
  45145. /**
  45146. * Defines the type of event (BABYLON.ClipboardEventTypes)
  45147. */
  45148. type: number,
  45149. /**
  45150. * Defines the related dom event
  45151. */
  45152. event: ClipboardEvent);
  45153. /**
  45154. * Get the clipboard event's type from the keycode.
  45155. * @param keyCode Defines the keyCode for the current keyboard event.
  45156. * @return {number}
  45157. */
  45158. static GetTypeFromCharacter(keyCode: number): number;
  45159. }
  45160. }
  45161. declare module "babylonjs/Events/index" {
  45162. export * from "babylonjs/Events/keyboardEvents";
  45163. export * from "babylonjs/Events/pointerEvents";
  45164. export * from "babylonjs/Events/clipboardEvents";
  45165. }
  45166. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  45167. import { Scene } from "babylonjs/scene";
  45168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45169. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45170. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45171. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45172. /**
  45173. * Google Daydream controller
  45174. */
  45175. export class DaydreamController extends WebVRController {
  45176. /**
  45177. * Base Url for the controller model.
  45178. */
  45179. static MODEL_BASE_URL: string;
  45180. /**
  45181. * File name for the controller model.
  45182. */
  45183. static MODEL_FILENAME: string;
  45184. /**
  45185. * Gamepad Id prefix used to identify Daydream Controller.
  45186. */
  45187. static readonly GAMEPAD_ID_PREFIX: string;
  45188. /**
  45189. * Creates a new DaydreamController from a gamepad
  45190. * @param vrGamepad the gamepad that the controller should be created from
  45191. */
  45192. constructor(vrGamepad: any);
  45193. /**
  45194. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45195. * @param scene scene in which to add meshes
  45196. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45197. */
  45198. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45199. /**
  45200. * Called once for each button that changed state since the last frame
  45201. * @param buttonIdx Which button index changed
  45202. * @param state New state of the button
  45203. * @param changes Which properties on the state changed since last frame
  45204. */
  45205. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45206. }
  45207. }
  45208. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  45209. import { Scene } from "babylonjs/scene";
  45210. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45211. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  45212. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  45213. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45214. /**
  45215. * Gear VR Controller
  45216. */
  45217. export class GearVRController extends WebVRController {
  45218. /**
  45219. * Base Url for the controller model.
  45220. */
  45221. static MODEL_BASE_URL: string;
  45222. /**
  45223. * File name for the controller model.
  45224. */
  45225. static MODEL_FILENAME: string;
  45226. /**
  45227. * Gamepad Id prefix used to identify this controller.
  45228. */
  45229. static readonly GAMEPAD_ID_PREFIX: string;
  45230. private readonly _buttonIndexToObservableNameMap;
  45231. /**
  45232. * Creates a new GearVRController from a gamepad
  45233. * @param vrGamepad the gamepad that the controller should be created from
  45234. */
  45235. constructor(vrGamepad: any);
  45236. /**
  45237. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  45238. * @param scene scene in which to add meshes
  45239. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  45240. */
  45241. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  45242. /**
  45243. * Called once for each button that changed state since the last frame
  45244. * @param buttonIdx Which button index changed
  45245. * @param state New state of the button
  45246. * @param changes Which properties on the state changed since last frame
  45247. */
  45248. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Gamepads/Controllers/index" {
  45252. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  45253. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  45254. export * from "babylonjs/Gamepads/Controllers/genericController";
  45255. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  45256. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  45257. export * from "babylonjs/Gamepads/Controllers/viveController";
  45258. export * from "babylonjs/Gamepads/Controllers/webVRController";
  45259. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  45260. }
  45261. declare module "babylonjs/Gamepads/index" {
  45262. export * from "babylonjs/Gamepads/Controllers/index";
  45263. export * from "babylonjs/Gamepads/gamepad";
  45264. export * from "babylonjs/Gamepads/gamepadManager";
  45265. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  45266. export * from "babylonjs/Gamepads/xboxGamepad";
  45267. }
  45268. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  45269. import { Scene } from "babylonjs/scene";
  45270. import { Vector4 } from "babylonjs/Maths/math.vector";
  45271. import { Color4 } from "babylonjs/Maths/math.color";
  45272. import { Mesh } from "babylonjs/Meshes/mesh";
  45273. import { Nullable } from "babylonjs/types";
  45274. /**
  45275. * Class containing static functions to help procedurally build meshes
  45276. */
  45277. export class PolyhedronBuilder {
  45278. /**
  45279. * Creates a polyhedron mesh
  45280. * * 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
  45281. * * The parameter `size` (positive float, default 1) sets the polygon size
  45282. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  45283. * * 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`
  45284. * * 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
  45285. * * 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)`)
  45286. * * 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
  45287. * * 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
  45288. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45289. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45291. * @param name defines the name of the mesh
  45292. * @param options defines the options used to create the mesh
  45293. * @param scene defines the hosting scene
  45294. * @returns the polyhedron mesh
  45295. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  45296. */
  45297. static CreatePolyhedron(name: string, options: {
  45298. type?: number;
  45299. size?: number;
  45300. sizeX?: number;
  45301. sizeY?: number;
  45302. sizeZ?: number;
  45303. custom?: any;
  45304. faceUV?: Vector4[];
  45305. faceColors?: Color4[];
  45306. flat?: boolean;
  45307. updatable?: boolean;
  45308. sideOrientation?: number;
  45309. frontUVs?: Vector4;
  45310. backUVs?: Vector4;
  45311. }, scene?: Nullable<Scene>): Mesh;
  45312. }
  45313. }
  45314. declare module "babylonjs/Gizmos/scaleGizmo" {
  45315. import { Observable } from "babylonjs/Misc/observable";
  45316. import { Nullable } from "babylonjs/types";
  45317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45318. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45319. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  45320. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45321. /**
  45322. * Gizmo that enables scaling a mesh along 3 axis
  45323. */
  45324. export class ScaleGizmo extends Gizmo {
  45325. /**
  45326. * Internal gizmo used for interactions on the x axis
  45327. */
  45328. xGizmo: AxisScaleGizmo;
  45329. /**
  45330. * Internal gizmo used for interactions on the y axis
  45331. */
  45332. yGizmo: AxisScaleGizmo;
  45333. /**
  45334. * Internal gizmo used for interactions on the z axis
  45335. */
  45336. zGizmo: AxisScaleGizmo;
  45337. /**
  45338. * Internal gizmo used to scale all axis equally
  45339. */
  45340. uniformScaleGizmo: AxisScaleGizmo;
  45341. private _meshAttached;
  45342. private _updateGizmoRotationToMatchAttachedMesh;
  45343. private _snapDistance;
  45344. private _scaleRatio;
  45345. private _uniformScalingMesh;
  45346. private _octahedron;
  45347. /** Fires an event when any of it's sub gizmos are dragged */
  45348. onDragStartObservable: Observable<unknown>;
  45349. /** Fires an event when any of it's sub gizmos are released from dragging */
  45350. onDragEndObservable: Observable<unknown>;
  45351. attachedMesh: Nullable<AbstractMesh>;
  45352. /**
  45353. * Creates a ScaleGizmo
  45354. * @param gizmoLayer The utility layer the gizmo will be added to
  45355. */
  45356. constructor(gizmoLayer?: UtilityLayerRenderer);
  45357. updateGizmoRotationToMatchAttachedMesh: boolean;
  45358. /**
  45359. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45360. */
  45361. snapDistance: number;
  45362. /**
  45363. * Ratio for the scale of the gizmo (Default: 1)
  45364. */
  45365. scaleRatio: number;
  45366. /**
  45367. * Disposes of the gizmo
  45368. */
  45369. dispose(): void;
  45370. }
  45371. }
  45372. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  45373. import { Observable } from "babylonjs/Misc/observable";
  45374. import { Nullable } from "babylonjs/types";
  45375. import { Vector3 } from "babylonjs/Maths/math.vector";
  45376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45377. import { Mesh } from "babylonjs/Meshes/mesh";
  45378. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45379. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45380. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45381. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45382. import { Color3 } from "babylonjs/Maths/math.color";
  45383. /**
  45384. * Single axis scale gizmo
  45385. */
  45386. export class AxisScaleGizmo extends Gizmo {
  45387. /**
  45388. * Drag behavior responsible for the gizmos dragging interactions
  45389. */
  45390. dragBehavior: PointerDragBehavior;
  45391. private _pointerObserver;
  45392. /**
  45393. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45394. */
  45395. snapDistance: number;
  45396. /**
  45397. * Event that fires each time the gizmo snaps to a new location.
  45398. * * snapDistance is the the change in distance
  45399. */
  45400. onSnapObservable: Observable<{
  45401. snapDistance: number;
  45402. }>;
  45403. /**
  45404. * If the scaling operation should be done on all axis (default: false)
  45405. */
  45406. uniformScaling: boolean;
  45407. private _isEnabled;
  45408. private _parent;
  45409. private _arrow;
  45410. private _coloredMaterial;
  45411. private _hoverMaterial;
  45412. /**
  45413. * Creates an AxisScaleGizmo
  45414. * @param gizmoLayer The utility layer the gizmo will be added to
  45415. * @param dragAxis The axis which the gizmo will be able to scale on
  45416. * @param color The color of the gizmo
  45417. */
  45418. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  45419. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45420. /**
  45421. * If the gizmo is enabled
  45422. */
  45423. isEnabled: boolean;
  45424. /**
  45425. * Disposes of the gizmo
  45426. */
  45427. dispose(): void;
  45428. /**
  45429. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45430. * @param mesh The mesh to replace the default mesh of the gizmo
  45431. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  45432. */
  45433. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  45434. }
  45435. }
  45436. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  45437. import { Observable } from "babylonjs/Misc/observable";
  45438. import { Nullable } from "babylonjs/types";
  45439. import { Vector3 } from "babylonjs/Maths/math.vector";
  45440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45441. import { Mesh } from "babylonjs/Meshes/mesh";
  45442. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45443. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45444. import { Color3 } from "babylonjs/Maths/math.color";
  45445. import "babylonjs/Meshes/Builders/boxBuilder";
  45446. /**
  45447. * Bounding box gizmo
  45448. */
  45449. export class BoundingBoxGizmo extends Gizmo {
  45450. private _lineBoundingBox;
  45451. private _rotateSpheresParent;
  45452. private _scaleBoxesParent;
  45453. private _boundingDimensions;
  45454. private _renderObserver;
  45455. private _pointerObserver;
  45456. private _scaleDragSpeed;
  45457. private _tmpQuaternion;
  45458. private _tmpVector;
  45459. private _tmpRotationMatrix;
  45460. /**
  45461. * 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)
  45462. */
  45463. ignoreChildren: boolean;
  45464. /**
  45465. * 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)
  45466. */
  45467. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  45468. /**
  45469. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  45470. */
  45471. rotationSphereSize: number;
  45472. /**
  45473. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45474. */
  45475. scaleBoxSize: number;
  45476. /**
  45477. * 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)
  45478. */
  45479. fixedDragMeshScreenSize: boolean;
  45480. /**
  45481. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45482. */
  45483. fixedDragMeshScreenSizeDistanceFactor: number;
  45484. /**
  45485. * Fired when a rotation sphere or scale box is dragged
  45486. */
  45487. onDragStartObservable: Observable<{}>;
  45488. /**
  45489. * Fired when a scale box is dragged
  45490. */
  45491. onScaleBoxDragObservable: Observable<{}>;
  45492. /**
  45493. * Fired when a scale box drag is ended
  45494. */
  45495. onScaleBoxDragEndObservable: Observable<{}>;
  45496. /**
  45497. * Fired when a rotation sphere is dragged
  45498. */
  45499. onRotationSphereDragObservable: Observable<{}>;
  45500. /**
  45501. * Fired when a rotation sphere drag is ended
  45502. */
  45503. onRotationSphereDragEndObservable: Observable<{}>;
  45504. /**
  45505. * 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)
  45506. */
  45507. scalePivot: Nullable<Vector3>;
  45508. /**
  45509. * Mesh used as a pivot to rotate the attached mesh
  45510. */
  45511. private _anchorMesh;
  45512. private _existingMeshScale;
  45513. private _dragMesh;
  45514. private pointerDragBehavior;
  45515. private coloredMaterial;
  45516. private hoverColoredMaterial;
  45517. /**
  45518. * Sets the color of the bounding box gizmo
  45519. * @param color the color to set
  45520. */
  45521. setColor(color: Color3): void;
  45522. /**
  45523. * Creates an BoundingBoxGizmo
  45524. * @param gizmoLayer The utility layer the gizmo will be added to
  45525. * @param color The color of the gizmo
  45526. */
  45527. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45528. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45529. private _selectNode;
  45530. /**
  45531. * Updates the bounding box information for the Gizmo
  45532. */
  45533. updateBoundingBox(): void;
  45534. private _updateRotationSpheres;
  45535. private _updateScaleBoxes;
  45536. /**
  45537. * Enables rotation on the specified axis and disables rotation on the others
  45538. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45539. */
  45540. setEnabledRotationAxis(axis: string): void;
  45541. /**
  45542. * Enables/disables scaling
  45543. * @param enable if scaling should be enabled
  45544. */
  45545. setEnabledScaling(enable: boolean): void;
  45546. private _updateDummy;
  45547. /**
  45548. * Enables a pointer drag behavior on the bounding box of the gizmo
  45549. */
  45550. enableDragBehavior(): void;
  45551. /**
  45552. * Disposes of the gizmo
  45553. */
  45554. dispose(): void;
  45555. /**
  45556. * 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)
  45557. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45558. * @returns the bounding box mesh with the passed in mesh as a child
  45559. */
  45560. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45561. /**
  45562. * CustomMeshes are not supported by this gizmo
  45563. * @param mesh The mesh to replace the default mesh of the gizmo
  45564. */
  45565. setCustomMesh(mesh: Mesh): void;
  45566. }
  45567. }
  45568. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45569. import { Observable } from "babylonjs/Misc/observable";
  45570. import { Nullable } from "babylonjs/types";
  45571. import { Vector3 } from "babylonjs/Maths/math.vector";
  45572. import { Color3 } from "babylonjs/Maths/math.color";
  45573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45574. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45575. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45576. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45577. import "babylonjs/Meshes/Builders/linesBuilder";
  45578. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45579. /**
  45580. * Single plane rotation gizmo
  45581. */
  45582. export class PlaneRotationGizmo extends Gizmo {
  45583. /**
  45584. * Drag behavior responsible for the gizmos dragging interactions
  45585. */
  45586. dragBehavior: PointerDragBehavior;
  45587. private _pointerObserver;
  45588. /**
  45589. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45590. */
  45591. snapDistance: number;
  45592. /**
  45593. * Event that fires each time the gizmo snaps to a new location.
  45594. * * snapDistance is the the change in distance
  45595. */
  45596. onSnapObservable: Observable<{
  45597. snapDistance: number;
  45598. }>;
  45599. private _isEnabled;
  45600. private _parent;
  45601. /**
  45602. * Creates a PlaneRotationGizmo
  45603. * @param gizmoLayer The utility layer the gizmo will be added to
  45604. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45605. * @param color The color of the gizmo
  45606. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45607. */
  45608. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45609. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45610. /**
  45611. * If the gizmo is enabled
  45612. */
  45613. isEnabled: boolean;
  45614. /**
  45615. * Disposes of the gizmo
  45616. */
  45617. dispose(): void;
  45618. }
  45619. }
  45620. declare module "babylonjs/Gizmos/rotationGizmo" {
  45621. import { Observable } from "babylonjs/Misc/observable";
  45622. import { Nullable } from "babylonjs/types";
  45623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45624. import { Mesh } from "babylonjs/Meshes/mesh";
  45625. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45626. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45627. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45628. /**
  45629. * Gizmo that enables rotating a mesh along 3 axis
  45630. */
  45631. export class RotationGizmo extends Gizmo {
  45632. /**
  45633. * Internal gizmo used for interactions on the x axis
  45634. */
  45635. xGizmo: PlaneRotationGizmo;
  45636. /**
  45637. * Internal gizmo used for interactions on the y axis
  45638. */
  45639. yGizmo: PlaneRotationGizmo;
  45640. /**
  45641. * Internal gizmo used for interactions on the z axis
  45642. */
  45643. zGizmo: PlaneRotationGizmo;
  45644. /** Fires an event when any of it's sub gizmos are dragged */
  45645. onDragStartObservable: Observable<unknown>;
  45646. /** Fires an event when any of it's sub gizmos are released from dragging */
  45647. onDragEndObservable: Observable<unknown>;
  45648. private _meshAttached;
  45649. attachedMesh: Nullable<AbstractMesh>;
  45650. /**
  45651. * Creates a RotationGizmo
  45652. * @param gizmoLayer The utility layer the gizmo will be added to
  45653. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45654. */
  45655. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45656. updateGizmoRotationToMatchAttachedMesh: boolean;
  45657. /**
  45658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45659. */
  45660. snapDistance: number;
  45661. /**
  45662. * Ratio for the scale of the gizmo (Default: 1)
  45663. */
  45664. scaleRatio: number;
  45665. /**
  45666. * Disposes of the gizmo
  45667. */
  45668. dispose(): void;
  45669. /**
  45670. * CustomMeshes are not supported by this gizmo
  45671. * @param mesh The mesh to replace the default mesh of the gizmo
  45672. */
  45673. setCustomMesh(mesh: Mesh): void;
  45674. }
  45675. }
  45676. declare module "babylonjs/Gizmos/gizmoManager" {
  45677. import { Observable } from "babylonjs/Misc/observable";
  45678. import { Nullable } from "babylonjs/types";
  45679. import { Scene, IDisposable } from "babylonjs/scene";
  45680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45681. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45682. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45683. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45684. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45685. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45686. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45687. /**
  45688. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45689. */
  45690. export class GizmoManager implements IDisposable {
  45691. private scene;
  45692. /**
  45693. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45694. */
  45695. gizmos: {
  45696. positionGizmo: Nullable<PositionGizmo>;
  45697. rotationGizmo: Nullable<RotationGizmo>;
  45698. scaleGizmo: Nullable<ScaleGizmo>;
  45699. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45700. };
  45701. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45702. clearGizmoOnEmptyPointerEvent: boolean;
  45703. /** Fires an event when the manager is attached to a mesh */
  45704. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45705. private _gizmosEnabled;
  45706. private _pointerObserver;
  45707. private _attachedMesh;
  45708. private _boundingBoxColor;
  45709. private _defaultUtilityLayer;
  45710. private _defaultKeepDepthUtilityLayer;
  45711. /**
  45712. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45713. */
  45714. boundingBoxDragBehavior: SixDofDragBehavior;
  45715. /**
  45716. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45717. */
  45718. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45719. /**
  45720. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45721. */
  45722. usePointerToAttachGizmos: boolean;
  45723. /**
  45724. * Utility layer that the bounding box gizmo belongs to
  45725. */
  45726. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45727. /**
  45728. * Utility layer that all gizmos besides bounding box belong to
  45729. */
  45730. readonly utilityLayer: UtilityLayerRenderer;
  45731. /**
  45732. * Instatiates a gizmo manager
  45733. * @param scene the scene to overlay the gizmos on top of
  45734. */
  45735. constructor(scene: Scene);
  45736. /**
  45737. * Attaches a set of gizmos to the specified mesh
  45738. * @param mesh The mesh the gizmo's should be attached to
  45739. */
  45740. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45741. /**
  45742. * If the position gizmo is enabled
  45743. */
  45744. positionGizmoEnabled: boolean;
  45745. /**
  45746. * If the rotation gizmo is enabled
  45747. */
  45748. rotationGizmoEnabled: boolean;
  45749. /**
  45750. * If the scale gizmo is enabled
  45751. */
  45752. scaleGizmoEnabled: boolean;
  45753. /**
  45754. * If the boundingBox gizmo is enabled
  45755. */
  45756. boundingBoxGizmoEnabled: boolean;
  45757. /**
  45758. * Disposes of the gizmo manager
  45759. */
  45760. dispose(): void;
  45761. }
  45762. }
  45763. declare module "babylonjs/Lights/directionalLight" {
  45764. import { Camera } from "babylonjs/Cameras/camera";
  45765. import { Scene } from "babylonjs/scene";
  45766. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45767. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45768. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45769. import { Effect } from "babylonjs/Materials/effect";
  45770. /**
  45771. * A directional light is defined by a direction (what a surprise!).
  45772. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45773. * 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.
  45774. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45775. */
  45776. export class DirectionalLight extends ShadowLight {
  45777. private _shadowFrustumSize;
  45778. /**
  45779. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45780. */
  45781. /**
  45782. * Specifies a fix frustum size for the shadow generation.
  45783. */
  45784. shadowFrustumSize: number;
  45785. private _shadowOrthoScale;
  45786. /**
  45787. * Gets the shadow projection scale against the optimal computed one.
  45788. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45789. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45790. */
  45791. /**
  45792. * Sets the shadow projection scale against the optimal computed one.
  45793. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45794. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45795. */
  45796. shadowOrthoScale: number;
  45797. /**
  45798. * Automatically compute the projection matrix to best fit (including all the casters)
  45799. * on each frame.
  45800. */
  45801. autoUpdateExtends: boolean;
  45802. private _orthoLeft;
  45803. private _orthoRight;
  45804. private _orthoTop;
  45805. private _orthoBottom;
  45806. /**
  45807. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45808. * The directional light is emitted from everywhere in the given direction.
  45809. * It can cast shadows.
  45810. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45811. * @param name The friendly name of the light
  45812. * @param direction The direction of the light
  45813. * @param scene The scene the light belongs to
  45814. */
  45815. constructor(name: string, direction: Vector3, scene: Scene);
  45816. /**
  45817. * Returns the string "DirectionalLight".
  45818. * @return The class name
  45819. */
  45820. getClassName(): string;
  45821. /**
  45822. * Returns the integer 1.
  45823. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45824. */
  45825. getTypeID(): number;
  45826. /**
  45827. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45828. * Returns the DirectionalLight Shadow projection matrix.
  45829. */
  45830. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45831. /**
  45832. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45833. * Returns the DirectionalLight Shadow projection matrix.
  45834. */
  45835. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45836. /**
  45837. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45838. * Returns the DirectionalLight Shadow projection matrix.
  45839. */
  45840. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45841. protected _buildUniformLayout(): void;
  45842. /**
  45843. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45844. * @param effect The effect to update
  45845. * @param lightIndex The index of the light in the effect to update
  45846. * @returns The directional light
  45847. */
  45848. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45849. /**
  45850. * Gets the minZ used for shadow according to both the scene and the light.
  45851. *
  45852. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45853. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45854. * @param activeCamera The camera we are returning the min for
  45855. * @returns the depth min z
  45856. */
  45857. getDepthMinZ(activeCamera: Camera): number;
  45858. /**
  45859. * Gets the maxZ used for shadow according to both the scene and the light.
  45860. *
  45861. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45862. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45863. * @param activeCamera The camera we are returning the max for
  45864. * @returns the depth max z
  45865. */
  45866. getDepthMaxZ(activeCamera: Camera): number;
  45867. /**
  45868. * Prepares the list of defines specific to the light type.
  45869. * @param defines the list of defines
  45870. * @param lightIndex defines the index of the light for the effect
  45871. */
  45872. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45873. }
  45874. }
  45875. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45876. import { Mesh } from "babylonjs/Meshes/mesh";
  45877. /**
  45878. * Class containing static functions to help procedurally build meshes
  45879. */
  45880. export class HemisphereBuilder {
  45881. /**
  45882. * Creates a hemisphere mesh
  45883. * @param name defines the name of the mesh
  45884. * @param options defines the options used to create the mesh
  45885. * @param scene defines the hosting scene
  45886. * @returns the hemisphere mesh
  45887. */
  45888. static CreateHemisphere(name: string, options: {
  45889. segments?: number;
  45890. diameter?: number;
  45891. sideOrientation?: number;
  45892. }, scene: any): Mesh;
  45893. }
  45894. }
  45895. declare module "babylonjs/Lights/spotLight" {
  45896. import { Nullable } from "babylonjs/types";
  45897. import { Scene } from "babylonjs/scene";
  45898. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  45899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45900. import { Effect } from "babylonjs/Materials/effect";
  45901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45902. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45903. /**
  45904. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45905. * These values define a cone of light starting from the position, emitting toward the direction.
  45906. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45907. * and the exponent defines the speed of the decay of the light with distance (reach).
  45908. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45909. */
  45910. export class SpotLight extends ShadowLight {
  45911. private _angle;
  45912. private _innerAngle;
  45913. private _cosHalfAngle;
  45914. private _lightAngleScale;
  45915. private _lightAngleOffset;
  45916. /**
  45917. * Gets the cone angle of the spot light in Radians.
  45918. */
  45919. /**
  45920. * Sets the cone angle of the spot light in Radians.
  45921. */
  45922. angle: number;
  45923. /**
  45924. * Only used in gltf falloff mode, this defines the angle where
  45925. * the directional falloff will start before cutting at angle which could be seen
  45926. * as outer angle.
  45927. */
  45928. /**
  45929. * Only used in gltf falloff mode, this defines the angle where
  45930. * the directional falloff will start before cutting at angle which could be seen
  45931. * as outer angle.
  45932. */
  45933. innerAngle: number;
  45934. private _shadowAngleScale;
  45935. /**
  45936. * Allows scaling the angle of the light for shadow generation only.
  45937. */
  45938. /**
  45939. * Allows scaling the angle of the light for shadow generation only.
  45940. */
  45941. shadowAngleScale: number;
  45942. /**
  45943. * The light decay speed with the distance from the emission spot.
  45944. */
  45945. exponent: number;
  45946. private _projectionTextureMatrix;
  45947. /**
  45948. * Allows reading the projecton texture
  45949. */
  45950. readonly projectionTextureMatrix: Matrix;
  45951. protected _projectionTextureLightNear: number;
  45952. /**
  45953. * Gets the near clip of the Spotlight for texture projection.
  45954. */
  45955. /**
  45956. * Sets the near clip of the Spotlight for texture projection.
  45957. */
  45958. projectionTextureLightNear: number;
  45959. protected _projectionTextureLightFar: number;
  45960. /**
  45961. * Gets the far clip of the Spotlight for texture projection.
  45962. */
  45963. /**
  45964. * Sets the far clip of the Spotlight for texture projection.
  45965. */
  45966. projectionTextureLightFar: number;
  45967. protected _projectionTextureUpDirection: Vector3;
  45968. /**
  45969. * Gets the Up vector of the Spotlight for texture projection.
  45970. */
  45971. /**
  45972. * Sets the Up vector of the Spotlight for texture projection.
  45973. */
  45974. projectionTextureUpDirection: Vector3;
  45975. private _projectionTexture;
  45976. /**
  45977. * Gets the projection texture of the light.
  45978. */
  45979. /**
  45980. * Sets the projection texture of the light.
  45981. */
  45982. projectionTexture: Nullable<BaseTexture>;
  45983. private _projectionTextureViewLightDirty;
  45984. private _projectionTextureProjectionLightDirty;
  45985. private _projectionTextureDirty;
  45986. private _projectionTextureViewTargetVector;
  45987. private _projectionTextureViewLightMatrix;
  45988. private _projectionTextureProjectionLightMatrix;
  45989. private _projectionTextureScalingMatrix;
  45990. /**
  45991. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45992. * It can cast shadows.
  45993. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45994. * @param name The light friendly name
  45995. * @param position The position of the spot light in the scene
  45996. * @param direction The direction of the light in the scene
  45997. * @param angle The cone angle of the light in Radians
  45998. * @param exponent The light decay speed with the distance from the emission spot
  45999. * @param scene The scene the lights belongs to
  46000. */
  46001. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46002. /**
  46003. * Returns the string "SpotLight".
  46004. * @returns the class name
  46005. */
  46006. getClassName(): string;
  46007. /**
  46008. * Returns the integer 2.
  46009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46010. */
  46011. getTypeID(): number;
  46012. /**
  46013. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46014. */
  46015. protected _setDirection(value: Vector3): void;
  46016. /**
  46017. * Overrides the position setter to recompute the projection texture view light Matrix.
  46018. */
  46019. protected _setPosition(value: Vector3): void;
  46020. /**
  46021. * 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.
  46022. * Returns the SpotLight.
  46023. */
  46024. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46025. protected _computeProjectionTextureViewLightMatrix(): void;
  46026. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46027. /**
  46028. * Main function for light texture projection matrix computing.
  46029. */
  46030. protected _computeProjectionTextureMatrix(): void;
  46031. protected _buildUniformLayout(): void;
  46032. private _computeAngleValues;
  46033. /**
  46034. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46035. * @param effect The effect to update
  46036. * @param lightIndex The index of the light in the effect to update
  46037. * @returns The spot light
  46038. */
  46039. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46040. /**
  46041. * Disposes the light and the associated resources.
  46042. */
  46043. dispose(): void;
  46044. /**
  46045. * Prepares the list of defines specific to the light type.
  46046. * @param defines the list of defines
  46047. * @param lightIndex defines the index of the light for the effect
  46048. */
  46049. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46050. }
  46051. }
  46052. declare module "babylonjs/Gizmos/lightGizmo" {
  46053. import { Nullable } from "babylonjs/types";
  46054. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46055. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46056. import { Light } from "babylonjs/Lights/light";
  46057. /**
  46058. * Gizmo that enables viewing a light
  46059. */
  46060. export class LightGizmo extends Gizmo {
  46061. private _lightMesh;
  46062. private _material;
  46063. private cachedPosition;
  46064. private cachedForward;
  46065. /**
  46066. * Creates a LightGizmo
  46067. * @param gizmoLayer The utility layer the gizmo will be added to
  46068. */
  46069. constructor(gizmoLayer?: UtilityLayerRenderer);
  46070. private _light;
  46071. /**
  46072. * The light that the gizmo is attached to
  46073. */
  46074. light: Nullable<Light>;
  46075. /**
  46076. * @hidden
  46077. * Updates the gizmo to match the attached mesh's position/rotation
  46078. */
  46079. protected _update(): void;
  46080. private static _Scale;
  46081. /**
  46082. * Creates the lines for a light mesh
  46083. */
  46084. private static _createLightLines;
  46085. /**
  46086. * Disposes of the light gizmo
  46087. */
  46088. dispose(): void;
  46089. private static _CreateHemisphericLightMesh;
  46090. private static _CreatePointLightMesh;
  46091. private static _CreateSpotLightMesh;
  46092. private static _CreateDirectionalLightMesh;
  46093. }
  46094. }
  46095. declare module "babylonjs/Gizmos/index" {
  46096. export * from "babylonjs/Gizmos/axisDragGizmo";
  46097. export * from "babylonjs/Gizmos/axisScaleGizmo";
  46098. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  46099. export * from "babylonjs/Gizmos/gizmo";
  46100. export * from "babylonjs/Gizmos/gizmoManager";
  46101. export * from "babylonjs/Gizmos/planeRotationGizmo";
  46102. export * from "babylonjs/Gizmos/positionGizmo";
  46103. export * from "babylonjs/Gizmos/rotationGizmo";
  46104. export * from "babylonjs/Gizmos/scaleGizmo";
  46105. export * from "babylonjs/Gizmos/lightGizmo";
  46106. export * from "babylonjs/Gizmos/planeDragGizmo";
  46107. }
  46108. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  46109. /** @hidden */
  46110. export var backgroundFragmentDeclaration: {
  46111. name: string;
  46112. shader: string;
  46113. };
  46114. }
  46115. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  46116. /** @hidden */
  46117. export var backgroundUboDeclaration: {
  46118. name: string;
  46119. shader: string;
  46120. };
  46121. }
  46122. declare module "babylonjs/Shaders/background.fragment" {
  46123. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  46124. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46125. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46126. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46127. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46128. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46130. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  46131. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46132. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46134. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46135. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46136. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46137. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46138. /** @hidden */
  46139. export var backgroundPixelShader: {
  46140. name: string;
  46141. shader: string;
  46142. };
  46143. }
  46144. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  46145. /** @hidden */
  46146. export var backgroundVertexDeclaration: {
  46147. name: string;
  46148. shader: string;
  46149. };
  46150. }
  46151. declare module "babylonjs/Shaders/background.vertex" {
  46152. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  46153. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  46154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46155. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46156. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46158. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46159. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46160. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46161. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46162. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46164. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46165. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46166. /** @hidden */
  46167. export var backgroundVertexShader: {
  46168. name: string;
  46169. shader: string;
  46170. };
  46171. }
  46172. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  46173. import { Nullable, int, float } from "babylonjs/types";
  46174. import { Scene } from "babylonjs/scene";
  46175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  46176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46178. import { Mesh } from "babylonjs/Meshes/mesh";
  46179. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46180. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  46181. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  46182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46183. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  46184. import { Color3 } from "babylonjs/Maths/math.color";
  46185. import "babylonjs/Shaders/background.fragment";
  46186. import "babylonjs/Shaders/background.vertex";
  46187. /**
  46188. * Background material used to create an efficient environement around your scene.
  46189. */
  46190. export class BackgroundMaterial extends PushMaterial {
  46191. /**
  46192. * Standard reflectance value at parallel view angle.
  46193. */
  46194. static StandardReflectance0: number;
  46195. /**
  46196. * Standard reflectance value at grazing angle.
  46197. */
  46198. static StandardReflectance90: number;
  46199. protected _primaryColor: Color3;
  46200. /**
  46201. * Key light Color (multiply against the environement texture)
  46202. */
  46203. primaryColor: Color3;
  46204. protected __perceptualColor: Nullable<Color3>;
  46205. /**
  46206. * Experimental Internal Use Only.
  46207. *
  46208. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  46209. * This acts as a helper to set the primary color to a more "human friendly" value.
  46210. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  46211. * output color as close as possible from the chosen value.
  46212. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  46213. * part of lighting setup.)
  46214. */
  46215. _perceptualColor: Nullable<Color3>;
  46216. protected _primaryColorShadowLevel: float;
  46217. /**
  46218. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  46219. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  46220. */
  46221. primaryColorShadowLevel: float;
  46222. protected _primaryColorHighlightLevel: float;
  46223. /**
  46224. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  46225. * The primary color is used at the level chosen to define what the white area would look.
  46226. */
  46227. primaryColorHighlightLevel: float;
  46228. protected _reflectionTexture: Nullable<BaseTexture>;
  46229. /**
  46230. * Reflection Texture used in the material.
  46231. * Should be author in a specific way for the best result (refer to the documentation).
  46232. */
  46233. reflectionTexture: Nullable<BaseTexture>;
  46234. protected _reflectionBlur: float;
  46235. /**
  46236. * Reflection Texture level of blur.
  46237. *
  46238. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  46239. * texture twice.
  46240. */
  46241. reflectionBlur: float;
  46242. protected _diffuseTexture: Nullable<BaseTexture>;
  46243. /**
  46244. * Diffuse Texture used in the material.
  46245. * Should be author in a specific way for the best result (refer to the documentation).
  46246. */
  46247. diffuseTexture: Nullable<BaseTexture>;
  46248. protected _shadowLights: Nullable<IShadowLight[]>;
  46249. /**
  46250. * Specify the list of lights casting shadow on the material.
  46251. * All scene shadow lights will be included if null.
  46252. */
  46253. shadowLights: Nullable<IShadowLight[]>;
  46254. protected _shadowLevel: float;
  46255. /**
  46256. * Helps adjusting the shadow to a softer level if required.
  46257. * 0 means black shadows and 1 means no shadows.
  46258. */
  46259. shadowLevel: float;
  46260. protected _sceneCenter: Vector3;
  46261. /**
  46262. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  46263. * It is usually zero but might be interesting to modify according to your setup.
  46264. */
  46265. sceneCenter: Vector3;
  46266. protected _opacityFresnel: boolean;
  46267. /**
  46268. * This helps specifying that the material is falling off to the sky box at grazing angle.
  46269. * This helps ensuring a nice transition when the camera goes under the ground.
  46270. */
  46271. opacityFresnel: boolean;
  46272. protected _reflectionFresnel: boolean;
  46273. /**
  46274. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  46275. * This helps adding a mirror texture on the ground.
  46276. */
  46277. reflectionFresnel: boolean;
  46278. protected _reflectionFalloffDistance: number;
  46279. /**
  46280. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  46281. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  46282. */
  46283. reflectionFalloffDistance: number;
  46284. protected _reflectionAmount: number;
  46285. /**
  46286. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  46287. */
  46288. reflectionAmount: number;
  46289. protected _reflectionReflectance0: number;
  46290. /**
  46291. * This specifies the weight of the reflection at grazing angle.
  46292. */
  46293. reflectionReflectance0: number;
  46294. protected _reflectionReflectance90: number;
  46295. /**
  46296. * This specifies the weight of the reflection at a perpendicular point of view.
  46297. */
  46298. reflectionReflectance90: number;
  46299. /**
  46300. * Sets the reflection reflectance fresnel values according to the default standard
  46301. * empirically know to work well :-)
  46302. */
  46303. reflectionStandardFresnelWeight: number;
  46304. protected _useRGBColor: boolean;
  46305. /**
  46306. * Helps to directly use the maps channels instead of their level.
  46307. */
  46308. useRGBColor: boolean;
  46309. protected _enableNoise: boolean;
  46310. /**
  46311. * This helps reducing the banding effect that could occur on the background.
  46312. */
  46313. enableNoise: boolean;
  46314. /**
  46315. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46316. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  46317. * Recommended to be keep at 1.0 except for special cases.
  46318. */
  46319. fovMultiplier: number;
  46320. private _fovMultiplier;
  46321. /**
  46322. * Enable the FOV adjustment feature controlled by fovMultiplier.
  46323. */
  46324. useEquirectangularFOV: boolean;
  46325. private _maxSimultaneousLights;
  46326. /**
  46327. * Number of Simultaneous lights allowed on the material.
  46328. */
  46329. maxSimultaneousLights: int;
  46330. /**
  46331. * Default configuration related to image processing available in the Background Material.
  46332. */
  46333. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46334. /**
  46335. * Keep track of the image processing observer to allow dispose and replace.
  46336. */
  46337. private _imageProcessingObserver;
  46338. /**
  46339. * Attaches a new image processing configuration to the PBR Material.
  46340. * @param configuration (if null the scene configuration will be use)
  46341. */
  46342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46343. /**
  46344. * Gets the image processing configuration used either in this material.
  46345. */
  46346. /**
  46347. * Sets the Default image processing configuration used either in the this material.
  46348. *
  46349. * If sets to null, the scene one is in use.
  46350. */
  46351. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  46352. /**
  46353. * Gets wether the color curves effect is enabled.
  46354. */
  46355. /**
  46356. * Sets wether the color curves effect is enabled.
  46357. */
  46358. cameraColorCurvesEnabled: boolean;
  46359. /**
  46360. * Gets wether the color grading effect is enabled.
  46361. */
  46362. /**
  46363. * Gets wether the color grading effect is enabled.
  46364. */
  46365. cameraColorGradingEnabled: boolean;
  46366. /**
  46367. * Gets wether tonemapping is enabled or not.
  46368. */
  46369. /**
  46370. * Sets wether tonemapping is enabled or not
  46371. */
  46372. cameraToneMappingEnabled: boolean;
  46373. /**
  46374. * The camera exposure used on this material.
  46375. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46376. * This corresponds to a photographic exposure.
  46377. */
  46378. /**
  46379. * The camera exposure used on this material.
  46380. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46381. * This corresponds to a photographic exposure.
  46382. */
  46383. cameraExposure: float;
  46384. /**
  46385. * Gets The camera contrast used on this material.
  46386. */
  46387. /**
  46388. * Sets The camera contrast used on this material.
  46389. */
  46390. cameraContrast: float;
  46391. /**
  46392. * Gets the Color Grading 2D Lookup Texture.
  46393. */
  46394. /**
  46395. * Sets the Color Grading 2D Lookup Texture.
  46396. */
  46397. cameraColorGradingTexture: Nullable<BaseTexture>;
  46398. /**
  46399. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46400. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46401. * 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;
  46402. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46403. */
  46404. /**
  46405. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46406. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46407. * 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;
  46408. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46409. */
  46410. cameraColorCurves: Nullable<ColorCurves>;
  46411. /**
  46412. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  46413. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  46414. */
  46415. switchToBGR: boolean;
  46416. private _renderTargets;
  46417. private _reflectionControls;
  46418. private _white;
  46419. private _primaryShadowColor;
  46420. private _primaryHighlightColor;
  46421. /**
  46422. * Instantiates a Background Material in the given scene
  46423. * @param name The friendly name of the material
  46424. * @param scene The scene to add the material to
  46425. */
  46426. constructor(name: string, scene: Scene);
  46427. /**
  46428. * Gets a boolean indicating that current material needs to register RTT
  46429. */
  46430. readonly hasRenderTargetTextures: boolean;
  46431. /**
  46432. * The entire material has been created in order to prevent overdraw.
  46433. * @returns false
  46434. */
  46435. needAlphaTesting(): boolean;
  46436. /**
  46437. * The entire material has been created in order to prevent overdraw.
  46438. * @returns true if blending is enable
  46439. */
  46440. needAlphaBlending(): boolean;
  46441. /**
  46442. * Checks wether the material is ready to be rendered for a given mesh.
  46443. * @param mesh The mesh to render
  46444. * @param subMesh The submesh to check against
  46445. * @param useInstances Specify wether or not the material is used with instances
  46446. * @returns true if all the dependencies are ready (Textures, Effects...)
  46447. */
  46448. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46449. /**
  46450. * Compute the primary color according to the chosen perceptual color.
  46451. */
  46452. private _computePrimaryColorFromPerceptualColor;
  46453. /**
  46454. * Compute the highlights and shadow colors according to their chosen levels.
  46455. */
  46456. private _computePrimaryColors;
  46457. /**
  46458. * Build the uniform buffer used in the material.
  46459. */
  46460. buildUniformLayout(): void;
  46461. /**
  46462. * Unbind the material.
  46463. */
  46464. unbind(): void;
  46465. /**
  46466. * Bind only the world matrix to the material.
  46467. * @param world The world matrix to bind.
  46468. */
  46469. bindOnlyWorldMatrix(world: Matrix): void;
  46470. /**
  46471. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  46472. * @param world The world matrix to bind.
  46473. * @param subMesh The submesh to bind for.
  46474. */
  46475. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46476. /**
  46477. * Dispose the material.
  46478. * @param forceDisposeEffect Force disposal of the associated effect.
  46479. * @param forceDisposeTextures Force disposal of the associated textures.
  46480. */
  46481. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46482. /**
  46483. * Clones the material.
  46484. * @param name The cloned name.
  46485. * @returns The cloned material.
  46486. */
  46487. clone(name: string): BackgroundMaterial;
  46488. /**
  46489. * Serializes the current material to its JSON representation.
  46490. * @returns The JSON representation.
  46491. */
  46492. serialize(): any;
  46493. /**
  46494. * Gets the class name of the material
  46495. * @returns "BackgroundMaterial"
  46496. */
  46497. getClassName(): string;
  46498. /**
  46499. * Parse a JSON input to create back a background material.
  46500. * @param source The JSON data to parse
  46501. * @param scene The scene to create the parsed material in
  46502. * @param rootUrl The root url of the assets the material depends upon
  46503. * @returns the instantiated BackgroundMaterial.
  46504. */
  46505. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46506. }
  46507. }
  46508. declare module "babylonjs/Helpers/environmentHelper" {
  46509. import { Observable } from "babylonjs/Misc/observable";
  46510. import { Nullable } from "babylonjs/types";
  46511. import { Scene } from "babylonjs/scene";
  46512. import { Vector3 } from "babylonjs/Maths/math.vector";
  46513. import { Color3 } from "babylonjs/Maths/math.color";
  46514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46515. import { Mesh } from "babylonjs/Meshes/mesh";
  46516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46517. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46518. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46519. import "babylonjs/Meshes/Builders/planeBuilder";
  46520. import "babylonjs/Meshes/Builders/boxBuilder";
  46521. /**
  46522. * Represents the different options available during the creation of
  46523. * a Environment helper.
  46524. *
  46525. * This can control the default ground, skybox and image processing setup of your scene.
  46526. */
  46527. export interface IEnvironmentHelperOptions {
  46528. /**
  46529. * Specifies wether or not to create a ground.
  46530. * True by default.
  46531. */
  46532. createGround: boolean;
  46533. /**
  46534. * Specifies the ground size.
  46535. * 15 by default.
  46536. */
  46537. groundSize: number;
  46538. /**
  46539. * The texture used on the ground for the main color.
  46540. * Comes from the BabylonJS CDN by default.
  46541. *
  46542. * Remarks: Can be either a texture or a url.
  46543. */
  46544. groundTexture: string | BaseTexture;
  46545. /**
  46546. * The color mixed in the ground texture by default.
  46547. * BabylonJS clearColor by default.
  46548. */
  46549. groundColor: Color3;
  46550. /**
  46551. * Specifies the ground opacity.
  46552. * 1 by default.
  46553. */
  46554. groundOpacity: number;
  46555. /**
  46556. * Enables the ground to receive shadows.
  46557. * True by default.
  46558. */
  46559. enableGroundShadow: boolean;
  46560. /**
  46561. * Helps preventing the shadow to be fully black on the ground.
  46562. * 0.5 by default.
  46563. */
  46564. groundShadowLevel: number;
  46565. /**
  46566. * Creates a mirror texture attach to the ground.
  46567. * false by default.
  46568. */
  46569. enableGroundMirror: boolean;
  46570. /**
  46571. * Specifies the ground mirror size ratio.
  46572. * 0.3 by default as the default kernel is 64.
  46573. */
  46574. groundMirrorSizeRatio: number;
  46575. /**
  46576. * Specifies the ground mirror blur kernel size.
  46577. * 64 by default.
  46578. */
  46579. groundMirrorBlurKernel: number;
  46580. /**
  46581. * Specifies the ground mirror visibility amount.
  46582. * 1 by default
  46583. */
  46584. groundMirrorAmount: number;
  46585. /**
  46586. * Specifies the ground mirror reflectance weight.
  46587. * This uses the standard weight of the background material to setup the fresnel effect
  46588. * of the mirror.
  46589. * 1 by default.
  46590. */
  46591. groundMirrorFresnelWeight: number;
  46592. /**
  46593. * Specifies the ground mirror Falloff distance.
  46594. * This can helps reducing the size of the reflection.
  46595. * 0 by Default.
  46596. */
  46597. groundMirrorFallOffDistance: number;
  46598. /**
  46599. * Specifies the ground mirror texture type.
  46600. * Unsigned Int by Default.
  46601. */
  46602. groundMirrorTextureType: number;
  46603. /**
  46604. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46605. * the shown objects.
  46606. */
  46607. groundYBias: number;
  46608. /**
  46609. * Specifies wether or not to create a skybox.
  46610. * True by default.
  46611. */
  46612. createSkybox: boolean;
  46613. /**
  46614. * Specifies the skybox size.
  46615. * 20 by default.
  46616. */
  46617. skyboxSize: number;
  46618. /**
  46619. * The texture used on the skybox for the main color.
  46620. * Comes from the BabylonJS CDN by default.
  46621. *
  46622. * Remarks: Can be either a texture or a url.
  46623. */
  46624. skyboxTexture: string | BaseTexture;
  46625. /**
  46626. * The color mixed in the skybox texture by default.
  46627. * BabylonJS clearColor by default.
  46628. */
  46629. skyboxColor: Color3;
  46630. /**
  46631. * The background rotation around the Y axis of the scene.
  46632. * This helps aligning the key lights of your scene with the background.
  46633. * 0 by default.
  46634. */
  46635. backgroundYRotation: number;
  46636. /**
  46637. * Compute automatically the size of the elements to best fit with the scene.
  46638. */
  46639. sizeAuto: boolean;
  46640. /**
  46641. * Default position of the rootMesh if autoSize is not true.
  46642. */
  46643. rootPosition: Vector3;
  46644. /**
  46645. * Sets up the image processing in the scene.
  46646. * true by default.
  46647. */
  46648. setupImageProcessing: boolean;
  46649. /**
  46650. * The texture used as your environment texture in the scene.
  46651. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46652. *
  46653. * Remarks: Can be either a texture or a url.
  46654. */
  46655. environmentTexture: string | BaseTexture;
  46656. /**
  46657. * The value of the exposure to apply to the scene.
  46658. * 0.6 by default if setupImageProcessing is true.
  46659. */
  46660. cameraExposure: number;
  46661. /**
  46662. * The value of the contrast to apply to the scene.
  46663. * 1.6 by default if setupImageProcessing is true.
  46664. */
  46665. cameraContrast: number;
  46666. /**
  46667. * Specifies wether or not tonemapping should be enabled in the scene.
  46668. * true by default if setupImageProcessing is true.
  46669. */
  46670. toneMappingEnabled: boolean;
  46671. }
  46672. /**
  46673. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46674. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46675. * It also helps with the default setup of your imageProcessing configuration.
  46676. */
  46677. export class EnvironmentHelper {
  46678. /**
  46679. * Default ground texture URL.
  46680. */
  46681. private static _groundTextureCDNUrl;
  46682. /**
  46683. * Default skybox texture URL.
  46684. */
  46685. private static _skyboxTextureCDNUrl;
  46686. /**
  46687. * Default environment texture URL.
  46688. */
  46689. private static _environmentTextureCDNUrl;
  46690. /**
  46691. * Creates the default options for the helper.
  46692. */
  46693. private static _getDefaultOptions;
  46694. private _rootMesh;
  46695. /**
  46696. * Gets the root mesh created by the helper.
  46697. */
  46698. readonly rootMesh: Mesh;
  46699. private _skybox;
  46700. /**
  46701. * Gets the skybox created by the helper.
  46702. */
  46703. readonly skybox: Nullable<Mesh>;
  46704. private _skyboxTexture;
  46705. /**
  46706. * Gets the skybox texture created by the helper.
  46707. */
  46708. readonly skyboxTexture: Nullable<BaseTexture>;
  46709. private _skyboxMaterial;
  46710. /**
  46711. * Gets the skybox material created by the helper.
  46712. */
  46713. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46714. private _ground;
  46715. /**
  46716. * Gets the ground mesh created by the helper.
  46717. */
  46718. readonly ground: Nullable<Mesh>;
  46719. private _groundTexture;
  46720. /**
  46721. * Gets the ground texture created by the helper.
  46722. */
  46723. readonly groundTexture: Nullable<BaseTexture>;
  46724. private _groundMirror;
  46725. /**
  46726. * Gets the ground mirror created by the helper.
  46727. */
  46728. readonly groundMirror: Nullable<MirrorTexture>;
  46729. /**
  46730. * Gets the ground mirror render list to helps pushing the meshes
  46731. * you wish in the ground reflection.
  46732. */
  46733. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46734. private _groundMaterial;
  46735. /**
  46736. * Gets the ground material created by the helper.
  46737. */
  46738. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46739. /**
  46740. * Stores the creation options.
  46741. */
  46742. private readonly _scene;
  46743. private _options;
  46744. /**
  46745. * This observable will be notified with any error during the creation of the environment,
  46746. * mainly texture creation errors.
  46747. */
  46748. onErrorObservable: Observable<{
  46749. message?: string;
  46750. exception?: any;
  46751. }>;
  46752. /**
  46753. * constructor
  46754. * @param options Defines the options we want to customize the helper
  46755. * @param scene The scene to add the material to
  46756. */
  46757. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46758. /**
  46759. * Updates the background according to the new options
  46760. * @param options
  46761. */
  46762. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46763. /**
  46764. * Sets the primary color of all the available elements.
  46765. * @param color the main color to affect to the ground and the background
  46766. */
  46767. setMainColor(color: Color3): void;
  46768. /**
  46769. * Setup the image processing according to the specified options.
  46770. */
  46771. private _setupImageProcessing;
  46772. /**
  46773. * Setup the environment texture according to the specified options.
  46774. */
  46775. private _setupEnvironmentTexture;
  46776. /**
  46777. * Setup the background according to the specified options.
  46778. */
  46779. private _setupBackground;
  46780. /**
  46781. * Get the scene sizes according to the setup.
  46782. */
  46783. private _getSceneSize;
  46784. /**
  46785. * Setup the ground according to the specified options.
  46786. */
  46787. private _setupGround;
  46788. /**
  46789. * Setup the ground material according to the specified options.
  46790. */
  46791. private _setupGroundMaterial;
  46792. /**
  46793. * Setup the ground diffuse texture according to the specified options.
  46794. */
  46795. private _setupGroundDiffuseTexture;
  46796. /**
  46797. * Setup the ground mirror texture according to the specified options.
  46798. */
  46799. private _setupGroundMirrorTexture;
  46800. /**
  46801. * Setup the ground to receive the mirror texture.
  46802. */
  46803. private _setupMirrorInGroundMaterial;
  46804. /**
  46805. * Setup the skybox according to the specified options.
  46806. */
  46807. private _setupSkybox;
  46808. /**
  46809. * Setup the skybox material according to the specified options.
  46810. */
  46811. private _setupSkyboxMaterial;
  46812. /**
  46813. * Setup the skybox reflection texture according to the specified options.
  46814. */
  46815. private _setupSkyboxReflectionTexture;
  46816. private _errorHandler;
  46817. /**
  46818. * Dispose all the elements created by the Helper.
  46819. */
  46820. dispose(): void;
  46821. }
  46822. }
  46823. declare module "babylonjs/Helpers/photoDome" {
  46824. import { Observable } from "babylonjs/Misc/observable";
  46825. import { Nullable } from "babylonjs/types";
  46826. import { Scene } from "babylonjs/scene";
  46827. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46828. import { Mesh } from "babylonjs/Meshes/mesh";
  46829. import { Texture } from "babylonjs/Materials/Textures/texture";
  46830. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46831. import "babylonjs/Meshes/Builders/sphereBuilder";
  46832. /**
  46833. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46834. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46835. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46836. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46837. */
  46838. export class PhotoDome extends TransformNode {
  46839. /**
  46840. * Define the image as a Monoscopic panoramic 360 image.
  46841. */
  46842. static readonly MODE_MONOSCOPIC: number;
  46843. /**
  46844. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46845. */
  46846. static readonly MODE_TOPBOTTOM: number;
  46847. /**
  46848. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46849. */
  46850. static readonly MODE_SIDEBYSIDE: number;
  46851. private _useDirectMapping;
  46852. /**
  46853. * The texture being displayed on the sphere
  46854. */
  46855. protected _photoTexture: Texture;
  46856. /**
  46857. * Gets or sets the texture being displayed on the sphere
  46858. */
  46859. photoTexture: Texture;
  46860. /**
  46861. * Observable raised when an error occured while loading the 360 image
  46862. */
  46863. onLoadErrorObservable: Observable<string>;
  46864. /**
  46865. * The skybox material
  46866. */
  46867. protected _material: BackgroundMaterial;
  46868. /**
  46869. * The surface used for the skybox
  46870. */
  46871. protected _mesh: Mesh;
  46872. /**
  46873. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46874. * Also see the options.resolution property.
  46875. */
  46876. fovMultiplier: number;
  46877. private _imageMode;
  46878. /**
  46879. * Gets or set the current video mode for the video. It can be:
  46880. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46881. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46882. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46883. */
  46884. imageMode: number;
  46885. /**
  46886. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46887. * @param name Element's name, child elements will append suffixes for their own names.
  46888. * @param urlsOfPhoto defines the url of the photo to display
  46889. * @param options defines an object containing optional or exposed sub element properties
  46890. * @param onError defines a callback called when an error occured while loading the texture
  46891. */
  46892. constructor(name: string, urlOfPhoto: string, options: {
  46893. resolution?: number;
  46894. size?: number;
  46895. useDirectMapping?: boolean;
  46896. faceForward?: boolean;
  46897. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46898. private _onBeforeCameraRenderObserver;
  46899. private _changeImageMode;
  46900. /**
  46901. * Releases resources associated with this node.
  46902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46904. */
  46905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46906. }
  46907. }
  46908. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46909. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46910. /** @hidden */
  46911. export var rgbdDecodePixelShader: {
  46912. name: string;
  46913. shader: string;
  46914. };
  46915. }
  46916. declare module "babylonjs/Misc/brdfTextureTools" {
  46917. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46918. import { Scene } from "babylonjs/scene";
  46919. import "babylonjs/Shaders/rgbdDecode.fragment";
  46920. /**
  46921. * Class used to host texture specific utilities
  46922. */
  46923. export class BRDFTextureTools {
  46924. /**
  46925. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46926. * @param texture the texture to expand.
  46927. */
  46928. private static _ExpandDefaultBRDFTexture;
  46929. /**
  46930. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46931. * @param scene defines the hosting scene
  46932. * @returns the environment BRDF texture
  46933. */
  46934. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46935. private static _environmentBRDFBase64Texture;
  46936. }
  46937. }
  46938. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46939. import { Nullable } from "babylonjs/types";
  46940. import { Color3 } from "babylonjs/Maths/math.color";
  46941. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46942. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46943. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46944. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  46945. import { Engine } from "babylonjs/Engines/engine";
  46946. import { Scene } from "babylonjs/scene";
  46947. /**
  46948. * @hidden
  46949. */
  46950. export interface IMaterialClearCoatDefines {
  46951. CLEARCOAT: boolean;
  46952. CLEARCOAT_DEFAULTIOR: boolean;
  46953. CLEARCOAT_TEXTURE: boolean;
  46954. CLEARCOAT_TEXTUREDIRECTUV: number;
  46955. CLEARCOAT_BUMP: boolean;
  46956. CLEARCOAT_BUMPDIRECTUV: number;
  46957. CLEARCOAT_TINT: boolean;
  46958. CLEARCOAT_TINT_TEXTURE: boolean;
  46959. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46960. /** @hidden */
  46961. _areTexturesDirty: boolean;
  46962. }
  46963. /**
  46964. * Define the code related to the clear coat parameters of the pbr material.
  46965. */
  46966. export class PBRClearCoatConfiguration {
  46967. /**
  46968. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46969. * The default fits with a polyurethane material.
  46970. */
  46971. private static readonly _DefaultIndexOfRefraction;
  46972. private _isEnabled;
  46973. /**
  46974. * Defines if the clear coat is enabled in the material.
  46975. */
  46976. isEnabled: boolean;
  46977. /**
  46978. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46979. */
  46980. intensity: number;
  46981. /**
  46982. * Defines the clear coat layer roughness.
  46983. */
  46984. roughness: number;
  46985. private _indexOfRefraction;
  46986. /**
  46987. * Defines the index of refraction of the clear coat.
  46988. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46989. * The default fits with a polyurethane material.
  46990. * Changing the default value is more performance intensive.
  46991. */
  46992. indexOfRefraction: number;
  46993. private _texture;
  46994. /**
  46995. * Stores the clear coat values in a texture.
  46996. */
  46997. texture: Nullable<BaseTexture>;
  46998. private _bumpTexture;
  46999. /**
  47000. * Define the clear coat specific bump texture.
  47001. */
  47002. bumpTexture: Nullable<BaseTexture>;
  47003. private _isTintEnabled;
  47004. /**
  47005. * Defines if the clear coat tint is enabled in the material.
  47006. */
  47007. isTintEnabled: boolean;
  47008. /**
  47009. * Defines the clear coat tint of the material.
  47010. * This is only use if tint is enabled
  47011. */
  47012. tintColor: Color3;
  47013. /**
  47014. * Defines the distance at which the tint color should be found in the
  47015. * clear coat media.
  47016. * This is only use if tint is enabled
  47017. */
  47018. tintColorAtDistance: number;
  47019. /**
  47020. * Defines the clear coat layer thickness.
  47021. * This is only use if tint is enabled
  47022. */
  47023. tintThickness: number;
  47024. private _tintTexture;
  47025. /**
  47026. * Stores the clear tint values in a texture.
  47027. * rgb is tint
  47028. * a is a thickness factor
  47029. */
  47030. tintTexture: Nullable<BaseTexture>;
  47031. /** @hidden */
  47032. private _internalMarkAllSubMeshesAsTexturesDirty;
  47033. /** @hidden */
  47034. _markAllSubMeshesAsTexturesDirty(): void;
  47035. /**
  47036. * Instantiate a new istance of clear coat configuration.
  47037. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47038. */
  47039. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47040. /**
  47041. * Gets wehter the submesh is ready to be used or not.
  47042. * @param defines the list of "defines" to update.
  47043. * @param scene defines the scene the material belongs to.
  47044. * @param engine defines the engine the material belongs to.
  47045. * @param disableBumpMap defines wether the material disables bump or not.
  47046. * @returns - boolean indicating that the submesh is ready or not.
  47047. */
  47048. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  47049. /**
  47050. * Checks to see if a texture is used in the material.
  47051. * @param defines the list of "defines" to update.
  47052. * @param scene defines the scene to the material belongs to.
  47053. */
  47054. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  47055. /**
  47056. * Binds the material data.
  47057. * @param uniformBuffer defines the Uniform buffer to fill in.
  47058. * @param scene defines the scene the material belongs to.
  47059. * @param engine defines the engine the material belongs to.
  47060. * @param disableBumpMap defines wether the material disables bump or not.
  47061. * @param isFrozen defines wether the material is frozen or not.
  47062. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47063. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47064. */
  47065. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  47066. /**
  47067. * Checks to see if a texture is used in the material.
  47068. * @param texture - Base texture to use.
  47069. * @returns - Boolean specifying if a texture is used in the material.
  47070. */
  47071. hasTexture(texture: BaseTexture): boolean;
  47072. /**
  47073. * Returns an array of the actively used textures.
  47074. * @param activeTextures Array of BaseTextures
  47075. */
  47076. getActiveTextures(activeTextures: BaseTexture[]): void;
  47077. /**
  47078. * Returns the animatable textures.
  47079. * @param animatables Array of animatable textures.
  47080. */
  47081. getAnimatables(animatables: IAnimatable[]): void;
  47082. /**
  47083. * Disposes the resources of the material.
  47084. * @param forceDisposeTextures - Forces the disposal of all textures.
  47085. */
  47086. dispose(forceDisposeTextures?: boolean): void;
  47087. /**
  47088. * Get the current class name of the texture useful for serialization or dynamic coding.
  47089. * @returns "PBRClearCoatConfiguration"
  47090. */
  47091. getClassName(): string;
  47092. /**
  47093. * Add fallbacks to the effect fallbacks list.
  47094. * @param defines defines the Base texture to use.
  47095. * @param fallbacks defines the current fallback list.
  47096. * @param currentRank defines the current fallback rank.
  47097. * @returns the new fallback rank.
  47098. */
  47099. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47100. /**
  47101. * Add the required uniforms to the current list.
  47102. * @param uniforms defines the current uniform list.
  47103. */
  47104. static AddUniforms(uniforms: string[]): void;
  47105. /**
  47106. * Add the required samplers to the current list.
  47107. * @param samplers defines the current sampler list.
  47108. */
  47109. static AddSamplers(samplers: string[]): void;
  47110. /**
  47111. * Add the required uniforms to the current buffer.
  47112. * @param uniformBuffer defines the current uniform buffer.
  47113. */
  47114. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47115. /**
  47116. * Makes a duplicate of the current configuration into another one.
  47117. * @param clearCoatConfiguration define the config where to copy the info
  47118. */
  47119. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  47120. /**
  47121. * Serializes this clear coat configuration.
  47122. * @returns - An object with the serialized config.
  47123. */
  47124. serialize(): any;
  47125. /**
  47126. * Parses a anisotropy Configuration from a serialized object.
  47127. * @param source - Serialized object.
  47128. * @param scene Defines the scene we are parsing for
  47129. * @param rootUrl Defines the rootUrl to load from
  47130. */
  47131. parse(source: any, scene: Scene, rootUrl: string): void;
  47132. }
  47133. }
  47134. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  47135. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47136. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47138. import { Vector2 } from "babylonjs/Maths/math.vector";
  47139. import { Scene } from "babylonjs/scene";
  47140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47141. import { Nullable } from "babylonjs/types";
  47142. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47143. /**
  47144. * @hidden
  47145. */
  47146. export interface IMaterialAnisotropicDefines {
  47147. ANISOTROPIC: boolean;
  47148. ANISOTROPIC_TEXTURE: boolean;
  47149. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47150. MAINUV1: boolean;
  47151. _areTexturesDirty: boolean;
  47152. _needUVs: boolean;
  47153. }
  47154. /**
  47155. * Define the code related to the anisotropic parameters of the pbr material.
  47156. */
  47157. export class PBRAnisotropicConfiguration {
  47158. private _isEnabled;
  47159. /**
  47160. * Defines if the anisotropy is enabled in the material.
  47161. */
  47162. isEnabled: boolean;
  47163. /**
  47164. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  47165. */
  47166. intensity: number;
  47167. /**
  47168. * Defines if the effect is along the tangents, bitangents or in between.
  47169. * By default, the effect is "strectching" the highlights along the tangents.
  47170. */
  47171. direction: Vector2;
  47172. private _texture;
  47173. /**
  47174. * Stores the anisotropy values in a texture.
  47175. * rg is direction (like normal from -1 to 1)
  47176. * b is a intensity
  47177. */
  47178. texture: Nullable<BaseTexture>;
  47179. /** @hidden */
  47180. private _internalMarkAllSubMeshesAsTexturesDirty;
  47181. /** @hidden */
  47182. _markAllSubMeshesAsTexturesDirty(): void;
  47183. /**
  47184. * Instantiate a new istance of anisotropy configuration.
  47185. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47186. */
  47187. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47188. /**
  47189. * Specifies that the submesh is ready to be used.
  47190. * @param defines the list of "defines" to update.
  47191. * @param scene defines the scene the material belongs to.
  47192. * @returns - boolean indicating that the submesh is ready or not.
  47193. */
  47194. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  47195. /**
  47196. * Checks to see if a texture is used in the material.
  47197. * @param defines the list of "defines" to update.
  47198. * @param mesh the mesh we are preparing the defines for.
  47199. * @param scene defines the scene the material belongs to.
  47200. */
  47201. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  47202. /**
  47203. * Binds the material data.
  47204. * @param uniformBuffer defines the Uniform buffer to fill in.
  47205. * @param scene defines the scene the material belongs to.
  47206. * @param isFrozen defines wether the material is frozen or not.
  47207. */
  47208. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47209. /**
  47210. * Checks to see if a texture is used in the material.
  47211. * @param texture - Base texture to use.
  47212. * @returns - Boolean specifying if a texture is used in the material.
  47213. */
  47214. hasTexture(texture: BaseTexture): boolean;
  47215. /**
  47216. * Returns an array of the actively used textures.
  47217. * @param activeTextures Array of BaseTextures
  47218. */
  47219. getActiveTextures(activeTextures: BaseTexture[]): void;
  47220. /**
  47221. * Returns the animatable textures.
  47222. * @param animatables Array of animatable textures.
  47223. */
  47224. getAnimatables(animatables: IAnimatable[]): void;
  47225. /**
  47226. * Disposes the resources of the material.
  47227. * @param forceDisposeTextures - Forces the disposal of all textures.
  47228. */
  47229. dispose(forceDisposeTextures?: boolean): void;
  47230. /**
  47231. * Get the current class name of the texture useful for serialization or dynamic coding.
  47232. * @returns "PBRAnisotropicConfiguration"
  47233. */
  47234. getClassName(): string;
  47235. /**
  47236. * Add fallbacks to the effect fallbacks list.
  47237. * @param defines defines the Base texture to use.
  47238. * @param fallbacks defines the current fallback list.
  47239. * @param currentRank defines the current fallback rank.
  47240. * @returns the new fallback rank.
  47241. */
  47242. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47243. /**
  47244. * Add the required uniforms to the current list.
  47245. * @param uniforms defines the current uniform list.
  47246. */
  47247. static AddUniforms(uniforms: string[]): void;
  47248. /**
  47249. * Add the required uniforms to the current buffer.
  47250. * @param uniformBuffer defines the current uniform buffer.
  47251. */
  47252. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47253. /**
  47254. * Add the required samplers to the current list.
  47255. * @param samplers defines the current sampler list.
  47256. */
  47257. static AddSamplers(samplers: string[]): void;
  47258. /**
  47259. * Makes a duplicate of the current configuration into another one.
  47260. * @param anisotropicConfiguration define the config where to copy the info
  47261. */
  47262. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  47263. /**
  47264. * Serializes this anisotropy configuration.
  47265. * @returns - An object with the serialized config.
  47266. */
  47267. serialize(): any;
  47268. /**
  47269. * Parses a anisotropy Configuration from a serialized object.
  47270. * @param source - Serialized object.
  47271. * @param scene Defines the scene we are parsing for
  47272. * @param rootUrl Defines the rootUrl to load from
  47273. */
  47274. parse(source: any, scene: Scene, rootUrl: string): void;
  47275. }
  47276. }
  47277. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  47278. import { Scene } from "babylonjs/scene";
  47279. /**
  47280. * @hidden
  47281. */
  47282. export interface IMaterialBRDFDefines {
  47283. BRDF_V_HEIGHT_CORRELATED: boolean;
  47284. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47285. SPHERICAL_HARMONICS: boolean;
  47286. /** @hidden */
  47287. _areMiscDirty: boolean;
  47288. }
  47289. /**
  47290. * Define the code related to the BRDF parameters of the pbr material.
  47291. */
  47292. export class PBRBRDFConfiguration {
  47293. /**
  47294. * Default value used for the energy conservation.
  47295. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47296. */
  47297. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  47298. /**
  47299. * Default value used for the Smith Visibility Height Correlated mode.
  47300. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  47301. */
  47302. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  47303. /**
  47304. * Default value used for the IBL diffuse part.
  47305. * This can help switching back to the polynomials mode globally which is a tiny bit
  47306. * less GPU intensive at the drawback of a lower quality.
  47307. */
  47308. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  47309. private _useEnergyConservation;
  47310. /**
  47311. * Defines if the material uses energy conservation.
  47312. */
  47313. useEnergyConservation: boolean;
  47314. private _useSmithVisibilityHeightCorrelated;
  47315. /**
  47316. * LEGACY Mode set to false
  47317. * Defines if the material uses height smith correlated visibility term.
  47318. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  47319. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47320. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  47321. * Not relying on height correlated will also disable energy conservation.
  47322. */
  47323. useSmithVisibilityHeightCorrelated: boolean;
  47324. private _useSphericalHarmonics;
  47325. /**
  47326. * LEGACY Mode set to false
  47327. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  47328. * diffuse part of the IBL.
  47329. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  47330. * to the ground truth.
  47331. */
  47332. useSphericalHarmonics: boolean;
  47333. /** @hidden */
  47334. private _internalMarkAllSubMeshesAsMiscDirty;
  47335. /** @hidden */
  47336. _markAllSubMeshesAsMiscDirty(): void;
  47337. /**
  47338. * Instantiate a new istance of clear coat configuration.
  47339. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  47340. */
  47341. constructor(markAllSubMeshesAsMiscDirty: () => void);
  47342. /**
  47343. * Checks to see if a texture is used in the material.
  47344. * @param defines the list of "defines" to update.
  47345. */
  47346. prepareDefines(defines: IMaterialBRDFDefines): void;
  47347. /**
  47348. * Get the current class name of the texture useful for serialization or dynamic coding.
  47349. * @returns "PBRClearCoatConfiguration"
  47350. */
  47351. getClassName(): string;
  47352. /**
  47353. * Makes a duplicate of the current configuration into another one.
  47354. * @param brdfConfiguration define the config where to copy the info
  47355. */
  47356. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  47357. /**
  47358. * Serializes this BRDF configuration.
  47359. * @returns - An object with the serialized config.
  47360. */
  47361. serialize(): any;
  47362. /**
  47363. * Parses a anisotropy Configuration from a serialized object.
  47364. * @param source - Serialized object.
  47365. * @param scene Defines the scene we are parsing for
  47366. * @param rootUrl Defines the rootUrl to load from
  47367. */
  47368. parse(source: any, scene: Scene, rootUrl: string): void;
  47369. }
  47370. }
  47371. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  47372. import { EffectFallbacks } from "babylonjs/Materials/effect";
  47373. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47374. import { Color3 } from "babylonjs/Maths/math.color";
  47375. import { Scene } from "babylonjs/scene";
  47376. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47377. import { Nullable } from "babylonjs/types";
  47378. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47379. /**
  47380. * @hidden
  47381. */
  47382. export interface IMaterialSheenDefines {
  47383. SHEEN: boolean;
  47384. SHEEN_TEXTURE: boolean;
  47385. SHEEN_TEXTUREDIRECTUV: number;
  47386. SHEEN_LINKWITHALBEDO: boolean;
  47387. /** @hidden */
  47388. _areTexturesDirty: boolean;
  47389. }
  47390. /**
  47391. * Define the code related to the Sheen parameters of the pbr material.
  47392. */
  47393. export class PBRSheenConfiguration {
  47394. private _isEnabled;
  47395. /**
  47396. * Defines if the material uses sheen.
  47397. */
  47398. isEnabled: boolean;
  47399. private _linkSheenWithAlbedo;
  47400. /**
  47401. * Defines if the sheen is linked to the sheen color.
  47402. */
  47403. linkSheenWithAlbedo: boolean;
  47404. /**
  47405. * Defines the sheen intensity.
  47406. */
  47407. intensity: number;
  47408. /**
  47409. * Defines the sheen color.
  47410. */
  47411. color: Color3;
  47412. private _texture;
  47413. /**
  47414. * Stores the sheen tint values in a texture.
  47415. * rgb is tint
  47416. * a is a intensity
  47417. */
  47418. texture: Nullable<BaseTexture>;
  47419. /** @hidden */
  47420. private _internalMarkAllSubMeshesAsTexturesDirty;
  47421. /** @hidden */
  47422. _markAllSubMeshesAsTexturesDirty(): void;
  47423. /**
  47424. * Instantiate a new istance of clear coat configuration.
  47425. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47426. */
  47427. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47428. /**
  47429. * Specifies that the submesh is ready to be used.
  47430. * @param defines the list of "defines" to update.
  47431. * @param scene defines the scene the material belongs to.
  47432. * @returns - boolean indicating that the submesh is ready or not.
  47433. */
  47434. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  47435. /**
  47436. * Checks to see if a texture is used in the material.
  47437. * @param defines the list of "defines" to update.
  47438. * @param scene defines the scene the material belongs to.
  47439. */
  47440. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  47441. /**
  47442. * Binds the material data.
  47443. * @param uniformBuffer defines the Uniform buffer to fill in.
  47444. * @param scene defines the scene the material belongs to.
  47445. * @param isFrozen defines wether the material is frozen or not.
  47446. */
  47447. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  47448. /**
  47449. * Checks to see if a texture is used in the material.
  47450. * @param texture - Base texture to use.
  47451. * @returns - Boolean specifying if a texture is used in the material.
  47452. */
  47453. hasTexture(texture: BaseTexture): boolean;
  47454. /**
  47455. * Returns an array of the actively used textures.
  47456. * @param activeTextures Array of BaseTextures
  47457. */
  47458. getActiveTextures(activeTextures: BaseTexture[]): void;
  47459. /**
  47460. * Returns the animatable textures.
  47461. * @param animatables Array of animatable textures.
  47462. */
  47463. getAnimatables(animatables: IAnimatable[]): void;
  47464. /**
  47465. * Disposes the resources of the material.
  47466. * @param forceDisposeTextures - Forces the disposal of all textures.
  47467. */
  47468. dispose(forceDisposeTextures?: boolean): void;
  47469. /**
  47470. * Get the current class name of the texture useful for serialization or dynamic coding.
  47471. * @returns "PBRSheenConfiguration"
  47472. */
  47473. getClassName(): string;
  47474. /**
  47475. * Add fallbacks to the effect fallbacks list.
  47476. * @param defines defines the Base texture to use.
  47477. * @param fallbacks defines the current fallback list.
  47478. * @param currentRank defines the current fallback rank.
  47479. * @returns the new fallback rank.
  47480. */
  47481. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47482. /**
  47483. * Add the required uniforms to the current list.
  47484. * @param uniforms defines the current uniform list.
  47485. */
  47486. static AddUniforms(uniforms: string[]): void;
  47487. /**
  47488. * Add the required uniforms to the current buffer.
  47489. * @param uniformBuffer defines the current uniform buffer.
  47490. */
  47491. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47492. /**
  47493. * Add the required samplers to the current list.
  47494. * @param samplers defines the current sampler list.
  47495. */
  47496. static AddSamplers(samplers: string[]): void;
  47497. /**
  47498. * Makes a duplicate of the current configuration into another one.
  47499. * @param sheenConfiguration define the config where to copy the info
  47500. */
  47501. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47502. /**
  47503. * Serializes this BRDF configuration.
  47504. * @returns - An object with the serialized config.
  47505. */
  47506. serialize(): any;
  47507. /**
  47508. * Parses a anisotropy Configuration from a serialized object.
  47509. * @param source - Serialized object.
  47510. * @param scene Defines the scene we are parsing for
  47511. * @param rootUrl Defines the rootUrl to load from
  47512. */
  47513. parse(source: any, scene: Scene, rootUrl: string): void;
  47514. }
  47515. }
  47516. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47517. import { Nullable } from "babylonjs/types";
  47518. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47519. import { Color3 } from "babylonjs/Maths/math.color";
  47520. import { SmartArray } from "babylonjs/Misc/smartArray";
  47521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47522. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47523. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47524. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47525. import { Engine } from "babylonjs/Engines/engine";
  47526. import { Scene } from "babylonjs/scene";
  47527. /**
  47528. * @hidden
  47529. */
  47530. export interface IMaterialSubSurfaceDefines {
  47531. SUBSURFACE: boolean;
  47532. SS_REFRACTION: boolean;
  47533. SS_TRANSLUCENCY: boolean;
  47534. SS_SCATERRING: boolean;
  47535. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47536. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47537. SS_REFRACTIONMAP_3D: boolean;
  47538. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47539. SS_LODINREFRACTIONALPHA: boolean;
  47540. SS_GAMMAREFRACTION: boolean;
  47541. SS_RGBDREFRACTION: boolean;
  47542. SS_LINEARSPECULARREFRACTION: boolean;
  47543. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47544. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47545. /** @hidden */
  47546. _areTexturesDirty: boolean;
  47547. }
  47548. /**
  47549. * Define the code related to the sub surface parameters of the pbr material.
  47550. */
  47551. export class PBRSubSurfaceConfiguration {
  47552. private _isRefractionEnabled;
  47553. /**
  47554. * Defines if the refraction is enabled in the material.
  47555. */
  47556. isRefractionEnabled: boolean;
  47557. private _isTranslucencyEnabled;
  47558. /**
  47559. * Defines if the translucency is enabled in the material.
  47560. */
  47561. isTranslucencyEnabled: boolean;
  47562. private _isScatteringEnabled;
  47563. /**
  47564. * Defines the refraction intensity of the material.
  47565. * The refraction when enabled replaces the Diffuse part of the material.
  47566. * The intensity helps transitionning between diffuse and refraction.
  47567. */
  47568. refractionIntensity: number;
  47569. /**
  47570. * Defines the translucency intensity of the material.
  47571. * When translucency has been enabled, this defines how much of the "translucency"
  47572. * is addded to the diffuse part of the material.
  47573. */
  47574. translucencyIntensity: number;
  47575. /**
  47576. * Defines the scattering intensity of the material.
  47577. * When scattering has been enabled, this defines how much of the "scattered light"
  47578. * is addded to the diffuse part of the material.
  47579. */
  47580. scatteringIntensity: number;
  47581. private _thicknessTexture;
  47582. /**
  47583. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47584. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47585. * 0 would mean minimumThickness
  47586. * 1 would mean maximumThickness
  47587. * The other channels might be use as a mask to vary the different effects intensity.
  47588. */
  47589. thicknessTexture: Nullable<BaseTexture>;
  47590. private _refractionTexture;
  47591. /**
  47592. * Defines the texture to use for refraction.
  47593. */
  47594. refractionTexture: Nullable<BaseTexture>;
  47595. private _indexOfRefraction;
  47596. /**
  47597. * Defines the index of refraction used in the material.
  47598. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47599. */
  47600. indexOfRefraction: number;
  47601. private _invertRefractionY;
  47602. /**
  47603. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47604. */
  47605. invertRefractionY: boolean;
  47606. private _linkRefractionWithTransparency;
  47607. /**
  47608. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47609. * Materials half opaque for instance using refraction could benefit from this control.
  47610. */
  47611. linkRefractionWithTransparency: boolean;
  47612. /**
  47613. * Defines the minimum thickness stored in the thickness map.
  47614. * If no thickness map is defined, this value will be used to simulate thickness.
  47615. */
  47616. minimumThickness: number;
  47617. /**
  47618. * Defines the maximum thickness stored in the thickness map.
  47619. */
  47620. maximumThickness: number;
  47621. /**
  47622. * Defines the volume tint of the material.
  47623. * This is used for both translucency and scattering.
  47624. */
  47625. tintColor: Color3;
  47626. /**
  47627. * Defines the distance at which the tint color should be found in the media.
  47628. * This is used for refraction only.
  47629. */
  47630. tintColorAtDistance: number;
  47631. /**
  47632. * Defines how far each channel transmit through the media.
  47633. * It is defined as a color to simplify it selection.
  47634. */
  47635. diffusionDistance: Color3;
  47636. private _useMaskFromThicknessTexture;
  47637. /**
  47638. * Stores the intensity of the different subsurface effects in the thickness texture.
  47639. * * the green channel is the translucency intensity.
  47640. * * the blue channel is the scattering intensity.
  47641. * * the alpha channel is the refraction intensity.
  47642. */
  47643. useMaskFromThicknessTexture: boolean;
  47644. /** @hidden */
  47645. private _internalMarkAllSubMeshesAsTexturesDirty;
  47646. /** @hidden */
  47647. _markAllSubMeshesAsTexturesDirty(): void;
  47648. /**
  47649. * Instantiate a new istance of sub surface configuration.
  47650. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47651. */
  47652. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47653. /**
  47654. * Gets wehter the submesh is ready to be used or not.
  47655. * @param defines the list of "defines" to update.
  47656. * @param scene defines the scene the material belongs to.
  47657. * @returns - boolean indicating that the submesh is ready or not.
  47658. */
  47659. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47660. /**
  47661. * Checks to see if a texture is used in the material.
  47662. * @param defines the list of "defines" to update.
  47663. * @param scene defines the scene to the material belongs to.
  47664. */
  47665. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47666. /**
  47667. * Binds the material data.
  47668. * @param uniformBuffer defines the Uniform buffer to fill in.
  47669. * @param scene defines the scene the material belongs to.
  47670. * @param engine defines the engine the material belongs to.
  47671. * @param isFrozen defines wether the material is frozen or not.
  47672. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47673. */
  47674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47675. /**
  47676. * Unbinds the material from the mesh.
  47677. * @param activeEffect defines the effect that should be unbound from.
  47678. * @returns true if unbound, otherwise false
  47679. */
  47680. unbind(activeEffect: Effect): boolean;
  47681. /**
  47682. * Returns the texture used for refraction or null if none is used.
  47683. * @param scene defines the scene the material belongs to.
  47684. * @returns - Refraction texture if present. If no refraction texture and refraction
  47685. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47686. */
  47687. private _getRefractionTexture;
  47688. /**
  47689. * Returns true if alpha blending should be disabled.
  47690. */
  47691. readonly disableAlphaBlending: boolean;
  47692. /**
  47693. * Fills the list of render target textures.
  47694. * @param renderTargets the list of render targets to update
  47695. */
  47696. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47697. /**
  47698. * Checks to see if a texture is used in the material.
  47699. * @param texture - Base texture to use.
  47700. * @returns - Boolean specifying if a texture is used in the material.
  47701. */
  47702. hasTexture(texture: BaseTexture): boolean;
  47703. /**
  47704. * Gets a boolean indicating that current material needs to register RTT
  47705. * @returns true if this uses a render target otherwise false.
  47706. */
  47707. hasRenderTargetTextures(): boolean;
  47708. /**
  47709. * Returns an array of the actively used textures.
  47710. * @param activeTextures Array of BaseTextures
  47711. */
  47712. getActiveTextures(activeTextures: BaseTexture[]): void;
  47713. /**
  47714. * Returns the animatable textures.
  47715. * @param animatables Array of animatable textures.
  47716. */
  47717. getAnimatables(animatables: IAnimatable[]): void;
  47718. /**
  47719. * Disposes the resources of the material.
  47720. * @param forceDisposeTextures - Forces the disposal of all textures.
  47721. */
  47722. dispose(forceDisposeTextures?: boolean): void;
  47723. /**
  47724. * Get the current class name of the texture useful for serialization or dynamic coding.
  47725. * @returns "PBRSubSurfaceConfiguration"
  47726. */
  47727. getClassName(): string;
  47728. /**
  47729. * Add fallbacks to the effect fallbacks list.
  47730. * @param defines defines the Base texture to use.
  47731. * @param fallbacks defines the current fallback list.
  47732. * @param currentRank defines the current fallback rank.
  47733. * @returns the new fallback rank.
  47734. */
  47735. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47736. /**
  47737. * Add the required uniforms to the current list.
  47738. * @param uniforms defines the current uniform list.
  47739. */
  47740. static AddUniforms(uniforms: string[]): void;
  47741. /**
  47742. * Add the required samplers to the current list.
  47743. * @param samplers defines the current sampler list.
  47744. */
  47745. static AddSamplers(samplers: string[]): void;
  47746. /**
  47747. * Add the required uniforms to the current buffer.
  47748. * @param uniformBuffer defines the current uniform buffer.
  47749. */
  47750. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47751. /**
  47752. * Makes a duplicate of the current configuration into another one.
  47753. * @param configuration define the config where to copy the info
  47754. */
  47755. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47756. /**
  47757. * Serializes this Sub Surface configuration.
  47758. * @returns - An object with the serialized config.
  47759. */
  47760. serialize(): any;
  47761. /**
  47762. * Parses a anisotropy Configuration from a serialized object.
  47763. * @param source - Serialized object.
  47764. * @param scene Defines the scene we are parsing for
  47765. * @param rootUrl Defines the rootUrl to load from
  47766. */
  47767. parse(source: any, scene: Scene, rootUrl: string): void;
  47768. }
  47769. }
  47770. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47771. /** @hidden */
  47772. export var pbrFragmentDeclaration: {
  47773. name: string;
  47774. shader: string;
  47775. };
  47776. }
  47777. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47778. /** @hidden */
  47779. export var pbrUboDeclaration: {
  47780. name: string;
  47781. shader: string;
  47782. };
  47783. }
  47784. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47785. /** @hidden */
  47786. export var pbrFragmentExtraDeclaration: {
  47787. name: string;
  47788. shader: string;
  47789. };
  47790. }
  47791. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47792. /** @hidden */
  47793. export var pbrFragmentSamplersDeclaration: {
  47794. name: string;
  47795. shader: string;
  47796. };
  47797. }
  47798. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47799. /** @hidden */
  47800. export var pbrHelperFunctions: {
  47801. name: string;
  47802. shader: string;
  47803. };
  47804. }
  47805. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47806. /** @hidden */
  47807. export var harmonicsFunctions: {
  47808. name: string;
  47809. shader: string;
  47810. };
  47811. }
  47812. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47813. /** @hidden */
  47814. export var pbrDirectLightingSetupFunctions: {
  47815. name: string;
  47816. shader: string;
  47817. };
  47818. }
  47819. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47820. /** @hidden */
  47821. export var pbrDirectLightingFalloffFunctions: {
  47822. name: string;
  47823. shader: string;
  47824. };
  47825. }
  47826. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47827. /** @hidden */
  47828. export var pbrBRDFFunctions: {
  47829. name: string;
  47830. shader: string;
  47831. };
  47832. }
  47833. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47834. /** @hidden */
  47835. export var pbrDirectLightingFunctions: {
  47836. name: string;
  47837. shader: string;
  47838. };
  47839. }
  47840. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47841. /** @hidden */
  47842. export var pbrIBLFunctions: {
  47843. name: string;
  47844. shader: string;
  47845. };
  47846. }
  47847. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47848. /** @hidden */
  47849. export var pbrDebug: {
  47850. name: string;
  47851. shader: string;
  47852. };
  47853. }
  47854. declare module "babylonjs/Shaders/pbr.fragment" {
  47855. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47856. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47857. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47858. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47859. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47860. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47861. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47862. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47863. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47864. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47865. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47866. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47867. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47868. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47869. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47870. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47871. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47872. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47873. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47874. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47875. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47876. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47877. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47878. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47879. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47880. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47881. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47882. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47883. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47884. /** @hidden */
  47885. export var pbrPixelShader: {
  47886. name: string;
  47887. shader: string;
  47888. };
  47889. }
  47890. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47891. /** @hidden */
  47892. export var pbrVertexDeclaration: {
  47893. name: string;
  47894. shader: string;
  47895. };
  47896. }
  47897. declare module "babylonjs/Shaders/pbr.vertex" {
  47898. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47899. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47900. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47901. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47902. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47903. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47904. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47905. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47906. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47907. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47908. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47909. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47910. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47911. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47912. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47913. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47914. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47915. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47916. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47917. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47918. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47919. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47920. /** @hidden */
  47921. export var pbrVertexShader: {
  47922. name: string;
  47923. shader: string;
  47924. };
  47925. }
  47926. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47927. import { Nullable } from "babylonjs/types";
  47928. import { Scene } from "babylonjs/scene";
  47929. import { Matrix } from "babylonjs/Maths/math.vector";
  47930. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47931. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47932. import { Mesh } from "babylonjs/Meshes/mesh";
  47933. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47934. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47935. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47936. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47937. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47938. import { Color3 } from "babylonjs/Maths/math.color";
  47939. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47940. import { Material } from "babylonjs/Materials/material";
  47941. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47942. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47944. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  47945. import "babylonjs/Shaders/pbr.fragment";
  47946. import "babylonjs/Shaders/pbr.vertex";
  47947. /**
  47948. * Manages the defines for the PBR Material.
  47949. * @hidden
  47950. */
  47951. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47952. PBR: boolean;
  47953. MAINUV1: boolean;
  47954. MAINUV2: boolean;
  47955. UV1: boolean;
  47956. UV2: boolean;
  47957. ALBEDO: boolean;
  47958. ALBEDODIRECTUV: number;
  47959. VERTEXCOLOR: boolean;
  47960. AMBIENT: boolean;
  47961. AMBIENTDIRECTUV: number;
  47962. AMBIENTINGRAYSCALE: boolean;
  47963. OPACITY: boolean;
  47964. VERTEXALPHA: boolean;
  47965. OPACITYDIRECTUV: number;
  47966. OPACITYRGB: boolean;
  47967. ALPHATEST: boolean;
  47968. DEPTHPREPASS: boolean;
  47969. ALPHABLEND: boolean;
  47970. ALPHAFROMALBEDO: boolean;
  47971. ALPHATESTVALUE: string;
  47972. SPECULAROVERALPHA: boolean;
  47973. RADIANCEOVERALPHA: boolean;
  47974. ALPHAFRESNEL: boolean;
  47975. LINEARALPHAFRESNEL: boolean;
  47976. PREMULTIPLYALPHA: boolean;
  47977. EMISSIVE: boolean;
  47978. EMISSIVEDIRECTUV: number;
  47979. REFLECTIVITY: boolean;
  47980. REFLECTIVITYDIRECTUV: number;
  47981. SPECULARTERM: boolean;
  47982. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47983. MICROSURFACEAUTOMATIC: boolean;
  47984. LODBASEDMICROSFURACE: boolean;
  47985. MICROSURFACEMAP: boolean;
  47986. MICROSURFACEMAPDIRECTUV: number;
  47987. METALLICWORKFLOW: boolean;
  47988. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47989. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47990. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47991. AOSTOREINMETALMAPRED: boolean;
  47992. ENVIRONMENTBRDF: boolean;
  47993. ENVIRONMENTBRDF_RGBD: boolean;
  47994. NORMAL: boolean;
  47995. TANGENT: boolean;
  47996. BUMP: boolean;
  47997. BUMPDIRECTUV: number;
  47998. OBJECTSPACE_NORMALMAP: boolean;
  47999. PARALLAX: boolean;
  48000. PARALLAXOCCLUSION: boolean;
  48001. NORMALXYSCALE: boolean;
  48002. LIGHTMAP: boolean;
  48003. LIGHTMAPDIRECTUV: number;
  48004. USELIGHTMAPASSHADOWMAP: boolean;
  48005. GAMMALIGHTMAP: boolean;
  48006. REFLECTION: boolean;
  48007. REFLECTIONMAP_3D: boolean;
  48008. REFLECTIONMAP_SPHERICAL: boolean;
  48009. REFLECTIONMAP_PLANAR: boolean;
  48010. REFLECTIONMAP_CUBIC: boolean;
  48011. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  48012. REFLECTIONMAP_PROJECTION: boolean;
  48013. REFLECTIONMAP_SKYBOX: boolean;
  48014. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  48015. REFLECTIONMAP_EXPLICIT: boolean;
  48016. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  48017. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  48018. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  48019. INVERTCUBICMAP: boolean;
  48020. USESPHERICALFROMREFLECTIONMAP: boolean;
  48021. USEIRRADIANCEMAP: boolean;
  48022. SPHERICAL_HARMONICS: boolean;
  48023. USESPHERICALINVERTEX: boolean;
  48024. REFLECTIONMAP_OPPOSITEZ: boolean;
  48025. LODINREFLECTIONALPHA: boolean;
  48026. GAMMAREFLECTION: boolean;
  48027. RGBDREFLECTION: boolean;
  48028. LINEARSPECULARREFLECTION: boolean;
  48029. RADIANCEOCCLUSION: boolean;
  48030. HORIZONOCCLUSION: boolean;
  48031. INSTANCES: boolean;
  48032. NUM_BONE_INFLUENCERS: number;
  48033. BonesPerMesh: number;
  48034. BONETEXTURE: boolean;
  48035. NONUNIFORMSCALING: boolean;
  48036. MORPHTARGETS: boolean;
  48037. MORPHTARGETS_NORMAL: boolean;
  48038. MORPHTARGETS_TANGENT: boolean;
  48039. MORPHTARGETS_UV: boolean;
  48040. NUM_MORPH_INFLUENCERS: number;
  48041. IMAGEPROCESSING: boolean;
  48042. VIGNETTE: boolean;
  48043. VIGNETTEBLENDMODEMULTIPLY: boolean;
  48044. VIGNETTEBLENDMODEOPAQUE: boolean;
  48045. TONEMAPPING: boolean;
  48046. TONEMAPPING_ACES: boolean;
  48047. CONTRAST: boolean;
  48048. COLORCURVES: boolean;
  48049. COLORGRADING: boolean;
  48050. COLORGRADING3D: boolean;
  48051. SAMPLER3DGREENDEPTH: boolean;
  48052. SAMPLER3DBGRMAP: boolean;
  48053. IMAGEPROCESSINGPOSTPROCESS: boolean;
  48054. EXPOSURE: boolean;
  48055. MULTIVIEW: boolean;
  48056. USEPHYSICALLIGHTFALLOFF: boolean;
  48057. USEGLTFLIGHTFALLOFF: boolean;
  48058. TWOSIDEDLIGHTING: boolean;
  48059. SHADOWFLOAT: boolean;
  48060. CLIPPLANE: boolean;
  48061. CLIPPLANE2: boolean;
  48062. CLIPPLANE3: boolean;
  48063. CLIPPLANE4: boolean;
  48064. POINTSIZE: boolean;
  48065. FOG: boolean;
  48066. LOGARITHMICDEPTH: boolean;
  48067. FORCENORMALFORWARD: boolean;
  48068. SPECULARAA: boolean;
  48069. CLEARCOAT: boolean;
  48070. CLEARCOAT_DEFAULTIOR: boolean;
  48071. CLEARCOAT_TEXTURE: boolean;
  48072. CLEARCOAT_TEXTUREDIRECTUV: number;
  48073. CLEARCOAT_BUMP: boolean;
  48074. CLEARCOAT_BUMPDIRECTUV: number;
  48075. CLEARCOAT_TINT: boolean;
  48076. CLEARCOAT_TINT_TEXTURE: boolean;
  48077. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48078. ANISOTROPIC: boolean;
  48079. ANISOTROPIC_TEXTURE: boolean;
  48080. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48081. BRDF_V_HEIGHT_CORRELATED: boolean;
  48082. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48083. SHEEN: boolean;
  48084. SHEEN_TEXTURE: boolean;
  48085. SHEEN_TEXTUREDIRECTUV: number;
  48086. SHEEN_LINKWITHALBEDO: boolean;
  48087. SUBSURFACE: boolean;
  48088. SS_REFRACTION: boolean;
  48089. SS_TRANSLUCENCY: boolean;
  48090. SS_SCATERRING: boolean;
  48091. SS_THICKNESSANDMASK_TEXTURE: boolean;
  48092. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  48093. SS_REFRACTIONMAP_3D: boolean;
  48094. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  48095. SS_LODINREFRACTIONALPHA: boolean;
  48096. SS_GAMMAREFRACTION: boolean;
  48097. SS_RGBDREFRACTION: boolean;
  48098. SS_LINEARSPECULARREFRACTION: boolean;
  48099. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  48100. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  48101. UNLIT: boolean;
  48102. DEBUGMODE: number;
  48103. /**
  48104. * Initializes the PBR Material defines.
  48105. */
  48106. constructor();
  48107. /**
  48108. * Resets the PBR Material defines.
  48109. */
  48110. reset(): void;
  48111. }
  48112. /**
  48113. * The Physically based material base class of BJS.
  48114. *
  48115. * This offers the main features of a standard PBR material.
  48116. * For more information, please refer to the documentation :
  48117. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48118. */
  48119. export abstract class PBRBaseMaterial extends PushMaterial {
  48120. /**
  48121. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48122. */
  48123. static readonly PBRMATERIAL_OPAQUE: number;
  48124. /**
  48125. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48126. */
  48127. static readonly PBRMATERIAL_ALPHATEST: number;
  48128. /**
  48129. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48130. */
  48131. static readonly PBRMATERIAL_ALPHABLEND: number;
  48132. /**
  48133. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48134. * They are also discarded below the alpha cutoff threshold to improve performances.
  48135. */
  48136. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48137. /**
  48138. * Defines the default value of how much AO map is occluding the analytical lights
  48139. * (point spot...).
  48140. */
  48141. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48142. /**
  48143. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  48144. */
  48145. static readonly LIGHTFALLOFF_PHYSICAL: number;
  48146. /**
  48147. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  48148. * to enhance interoperability with other engines.
  48149. */
  48150. static readonly LIGHTFALLOFF_GLTF: number;
  48151. /**
  48152. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  48153. * to enhance interoperability with other materials.
  48154. */
  48155. static readonly LIGHTFALLOFF_STANDARD: number;
  48156. /**
  48157. * Intensity of the direct lights e.g. the four lights available in your scene.
  48158. * This impacts both the direct diffuse and specular highlights.
  48159. */
  48160. protected _directIntensity: number;
  48161. /**
  48162. * Intensity of the emissive part of the material.
  48163. * This helps controlling the emissive effect without modifying the emissive color.
  48164. */
  48165. protected _emissiveIntensity: number;
  48166. /**
  48167. * Intensity of the environment e.g. how much the environment will light the object
  48168. * either through harmonics for rough material or through the refelction for shiny ones.
  48169. */
  48170. protected _environmentIntensity: number;
  48171. /**
  48172. * This is a special control allowing the reduction of the specular highlights coming from the
  48173. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48174. */
  48175. protected _specularIntensity: number;
  48176. /**
  48177. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  48178. */
  48179. private _lightingInfos;
  48180. /**
  48181. * Debug Control allowing disabling the bump map on this material.
  48182. */
  48183. protected _disableBumpMap: boolean;
  48184. /**
  48185. * AKA Diffuse Texture in standard nomenclature.
  48186. */
  48187. protected _albedoTexture: Nullable<BaseTexture>;
  48188. /**
  48189. * AKA Occlusion Texture in other nomenclature.
  48190. */
  48191. protected _ambientTexture: Nullable<BaseTexture>;
  48192. /**
  48193. * AKA Occlusion Texture Intensity in other nomenclature.
  48194. */
  48195. protected _ambientTextureStrength: number;
  48196. /**
  48197. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48198. * 1 means it completely occludes it
  48199. * 0 mean it has no impact
  48200. */
  48201. protected _ambientTextureImpactOnAnalyticalLights: number;
  48202. /**
  48203. * Stores the alpha values in a texture.
  48204. */
  48205. protected _opacityTexture: Nullable<BaseTexture>;
  48206. /**
  48207. * Stores the reflection values in a texture.
  48208. */
  48209. protected _reflectionTexture: Nullable<BaseTexture>;
  48210. /**
  48211. * Stores the emissive values in a texture.
  48212. */
  48213. protected _emissiveTexture: Nullable<BaseTexture>;
  48214. /**
  48215. * AKA Specular texture in other nomenclature.
  48216. */
  48217. protected _reflectivityTexture: Nullable<BaseTexture>;
  48218. /**
  48219. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48220. */
  48221. protected _metallicTexture: Nullable<BaseTexture>;
  48222. /**
  48223. * Specifies the metallic scalar of the metallic/roughness workflow.
  48224. * Can also be used to scale the metalness values of the metallic texture.
  48225. */
  48226. protected _metallic: Nullable<number>;
  48227. /**
  48228. * Specifies the roughness scalar of the metallic/roughness workflow.
  48229. * Can also be used to scale the roughness values of the metallic texture.
  48230. */
  48231. protected _roughness: Nullable<number>;
  48232. /**
  48233. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48234. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48235. */
  48236. protected _microSurfaceTexture: Nullable<BaseTexture>;
  48237. /**
  48238. * Stores surface normal data used to displace a mesh in a texture.
  48239. */
  48240. protected _bumpTexture: Nullable<BaseTexture>;
  48241. /**
  48242. * Stores the pre-calculated light information of a mesh in a texture.
  48243. */
  48244. protected _lightmapTexture: Nullable<BaseTexture>;
  48245. /**
  48246. * The color of a material in ambient lighting.
  48247. */
  48248. protected _ambientColor: Color3;
  48249. /**
  48250. * AKA Diffuse Color in other nomenclature.
  48251. */
  48252. protected _albedoColor: Color3;
  48253. /**
  48254. * AKA Specular Color in other nomenclature.
  48255. */
  48256. protected _reflectivityColor: Color3;
  48257. /**
  48258. * The color applied when light is reflected from a material.
  48259. */
  48260. protected _reflectionColor: Color3;
  48261. /**
  48262. * The color applied when light is emitted from a material.
  48263. */
  48264. protected _emissiveColor: Color3;
  48265. /**
  48266. * AKA Glossiness in other nomenclature.
  48267. */
  48268. protected _microSurface: number;
  48269. /**
  48270. * Specifies that the material will use the light map as a show map.
  48271. */
  48272. protected _useLightmapAsShadowmap: boolean;
  48273. /**
  48274. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48275. * makes the reflect vector face the model (under horizon).
  48276. */
  48277. protected _useHorizonOcclusion: boolean;
  48278. /**
  48279. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48280. * too much the area relying on ambient texture to define their ambient occlusion.
  48281. */
  48282. protected _useRadianceOcclusion: boolean;
  48283. /**
  48284. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48285. */
  48286. protected _useAlphaFromAlbedoTexture: boolean;
  48287. /**
  48288. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  48289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48290. */
  48291. protected _useSpecularOverAlpha: boolean;
  48292. /**
  48293. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48294. */
  48295. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48296. /**
  48297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48298. */
  48299. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  48300. /**
  48301. * Specifies if the metallic texture contains the roughness information in its green channel.
  48302. */
  48303. protected _useRoughnessFromMetallicTextureGreen: boolean;
  48304. /**
  48305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48306. */
  48307. protected _useMetallnessFromMetallicTextureBlue: boolean;
  48308. /**
  48309. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48310. */
  48311. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  48312. /**
  48313. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48314. */
  48315. protected _useAmbientInGrayScale: boolean;
  48316. /**
  48317. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48318. * The material will try to infer what glossiness each pixel should be.
  48319. */
  48320. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  48321. /**
  48322. * Defines the falloff type used in this material.
  48323. * It by default is Physical.
  48324. */
  48325. protected _lightFalloff: number;
  48326. /**
  48327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48329. */
  48330. protected _useRadianceOverAlpha: boolean;
  48331. /**
  48332. * Allows using an object space normal map (instead of tangent space).
  48333. */
  48334. protected _useObjectSpaceNormalMap: boolean;
  48335. /**
  48336. * Allows using the bump map in parallax mode.
  48337. */
  48338. protected _useParallax: boolean;
  48339. /**
  48340. * Allows using the bump map in parallax occlusion mode.
  48341. */
  48342. protected _useParallaxOcclusion: boolean;
  48343. /**
  48344. * Controls the scale bias of the parallax mode.
  48345. */
  48346. protected _parallaxScaleBias: number;
  48347. /**
  48348. * If sets to true, disables all the lights affecting the material.
  48349. */
  48350. protected _disableLighting: boolean;
  48351. /**
  48352. * Number of Simultaneous lights allowed on the material.
  48353. */
  48354. protected _maxSimultaneousLights: number;
  48355. /**
  48356. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48357. */
  48358. protected _invertNormalMapX: boolean;
  48359. /**
  48360. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48361. */
  48362. protected _invertNormalMapY: boolean;
  48363. /**
  48364. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48365. */
  48366. protected _twoSidedLighting: boolean;
  48367. /**
  48368. * Defines the alpha limits in alpha test mode.
  48369. */
  48370. protected _alphaCutOff: number;
  48371. /**
  48372. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48373. */
  48374. protected _forceAlphaTest: boolean;
  48375. /**
  48376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48377. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48378. */
  48379. protected _useAlphaFresnel: boolean;
  48380. /**
  48381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48382. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48383. */
  48384. protected _useLinearAlphaFresnel: boolean;
  48385. /**
  48386. * The transparency mode of the material.
  48387. */
  48388. protected _transparencyMode: Nullable<number>;
  48389. /**
  48390. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  48391. * from cos thetav and roughness:
  48392. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  48393. */
  48394. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  48395. /**
  48396. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48397. */
  48398. protected _forceIrradianceInFragment: boolean;
  48399. /**
  48400. * Force normal to face away from face.
  48401. */
  48402. protected _forceNormalForward: boolean;
  48403. /**
  48404. * Enables specular anti aliasing in the PBR shader.
  48405. * It will both interacts on the Geometry for analytical and IBL lighting.
  48406. * It also prefilter the roughness map based on the bump values.
  48407. */
  48408. protected _enableSpecularAntiAliasing: boolean;
  48409. /**
  48410. * Default configuration related to image processing available in the PBR Material.
  48411. */
  48412. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  48413. /**
  48414. * Keep track of the image processing observer to allow dispose and replace.
  48415. */
  48416. private _imageProcessingObserver;
  48417. /**
  48418. * Attaches a new image processing configuration to the PBR Material.
  48419. * @param configuration
  48420. */
  48421. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  48422. /**
  48423. * Stores the available render targets.
  48424. */
  48425. private _renderTargets;
  48426. /**
  48427. * Sets the global ambient color for the material used in lighting calculations.
  48428. */
  48429. private _globalAmbientColor;
  48430. /**
  48431. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  48432. */
  48433. private _useLogarithmicDepth;
  48434. /**
  48435. * If set to true, no lighting calculations will be applied.
  48436. */
  48437. private _unlit;
  48438. private _debugMode;
  48439. /**
  48440. * @hidden
  48441. * This is reserved for the inspector.
  48442. * Defines the material debug mode.
  48443. * It helps seeing only some components of the material while troubleshooting.
  48444. */
  48445. debugMode: number;
  48446. /**
  48447. * @hidden
  48448. * This is reserved for the inspector.
  48449. * Specify from where on screen the debug mode should start.
  48450. * The value goes from -1 (full screen) to 1 (not visible)
  48451. * It helps with side by side comparison against the final render
  48452. * This defaults to -1
  48453. */
  48454. private debugLimit;
  48455. /**
  48456. * @hidden
  48457. * This is reserved for the inspector.
  48458. * As the default viewing range might not be enough (if the ambient is really small for instance)
  48459. * You can use the factor to better multiply the final value.
  48460. */
  48461. private debugFactor;
  48462. /**
  48463. * Defines the clear coat layer parameters for the material.
  48464. */
  48465. readonly clearCoat: PBRClearCoatConfiguration;
  48466. /**
  48467. * Defines the anisotropic parameters for the material.
  48468. */
  48469. readonly anisotropy: PBRAnisotropicConfiguration;
  48470. /**
  48471. * Defines the BRDF parameters for the material.
  48472. */
  48473. readonly brdf: PBRBRDFConfiguration;
  48474. /**
  48475. * Defines the Sheen parameters for the material.
  48476. */
  48477. readonly sheen: PBRSheenConfiguration;
  48478. /**
  48479. * Defines the SubSurface parameters for the material.
  48480. */
  48481. readonly subSurface: PBRSubSurfaceConfiguration;
  48482. /**
  48483. * Custom callback helping to override the default shader used in the material.
  48484. */
  48485. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48486. /**
  48487. * Instantiates a new PBRMaterial instance.
  48488. *
  48489. * @param name The material name
  48490. * @param scene The scene the material will be use in.
  48491. */
  48492. constructor(name: string, scene: Scene);
  48493. /**
  48494. * Gets a boolean indicating that current material needs to register RTT
  48495. */
  48496. readonly hasRenderTargetTextures: boolean;
  48497. /**
  48498. * Gets the name of the material class.
  48499. */
  48500. getClassName(): string;
  48501. /**
  48502. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48503. */
  48504. /**
  48505. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48506. */
  48507. useLogarithmicDepth: boolean;
  48508. /**
  48509. * Gets the current transparency mode.
  48510. */
  48511. /**
  48512. * Sets the transparency mode of the material.
  48513. *
  48514. * | Value | Type | Description |
  48515. * | ----- | ----------------------------------- | ----------- |
  48516. * | 0 | OPAQUE | |
  48517. * | 1 | ALPHATEST | |
  48518. * | 2 | ALPHABLEND | |
  48519. * | 3 | ALPHATESTANDBLEND | |
  48520. *
  48521. */
  48522. transparencyMode: Nullable<number>;
  48523. /**
  48524. * Returns true if alpha blending should be disabled.
  48525. */
  48526. private readonly _disableAlphaBlending;
  48527. /**
  48528. * Specifies whether or not this material should be rendered in alpha blend mode.
  48529. */
  48530. needAlphaBlending(): boolean;
  48531. /**
  48532. * Specifies if the mesh will require alpha blending.
  48533. * @param mesh - BJS mesh.
  48534. */
  48535. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48536. /**
  48537. * Specifies whether or not this material should be rendered in alpha test mode.
  48538. */
  48539. needAlphaTesting(): boolean;
  48540. /**
  48541. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48542. */
  48543. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48544. /**
  48545. * Gets the texture used for the alpha test.
  48546. */
  48547. getAlphaTestTexture(): Nullable<BaseTexture>;
  48548. /**
  48549. * Specifies that the submesh is ready to be used.
  48550. * @param mesh - BJS mesh.
  48551. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48552. * @param useInstances - Specifies that instances should be used.
  48553. * @returns - boolean indicating that the submesh is ready or not.
  48554. */
  48555. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48556. /**
  48557. * Specifies if the material uses metallic roughness workflow.
  48558. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48559. */
  48560. isMetallicWorkflow(): boolean;
  48561. private _prepareEffect;
  48562. private _prepareDefines;
  48563. /**
  48564. * Force shader compilation
  48565. */
  48566. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48567. clipPlane: boolean;
  48568. }>): void;
  48569. /**
  48570. * Initializes the uniform buffer layout for the shader.
  48571. */
  48572. buildUniformLayout(): void;
  48573. /**
  48574. * Unbinds the material from the mesh
  48575. */
  48576. unbind(): void;
  48577. /**
  48578. * Binds the submesh data.
  48579. * @param world - The world matrix.
  48580. * @param mesh - The BJS mesh.
  48581. * @param subMesh - A submesh of the BJS mesh.
  48582. */
  48583. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48584. /**
  48585. * Returns the animatable textures.
  48586. * @returns - Array of animatable textures.
  48587. */
  48588. getAnimatables(): IAnimatable[];
  48589. /**
  48590. * Returns the texture used for reflections.
  48591. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48592. */
  48593. private _getReflectionTexture;
  48594. /**
  48595. * Returns an array of the actively used textures.
  48596. * @returns - Array of BaseTextures
  48597. */
  48598. getActiveTextures(): BaseTexture[];
  48599. /**
  48600. * Checks to see if a texture is used in the material.
  48601. * @param texture - Base texture to use.
  48602. * @returns - Boolean specifying if a texture is used in the material.
  48603. */
  48604. hasTexture(texture: BaseTexture): boolean;
  48605. /**
  48606. * Disposes the resources of the material.
  48607. * @param forceDisposeEffect - Forces the disposal of effects.
  48608. * @param forceDisposeTextures - Forces the disposal of all textures.
  48609. */
  48610. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48611. }
  48612. }
  48613. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48614. import { Nullable } from "babylonjs/types";
  48615. import { Scene } from "babylonjs/scene";
  48616. import { Color3 } from "babylonjs/Maths/math.color";
  48617. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48618. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48620. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48621. /**
  48622. * The Physically based material of BJS.
  48623. *
  48624. * This offers the main features of a standard PBR material.
  48625. * For more information, please refer to the documentation :
  48626. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48627. */
  48628. export class PBRMaterial extends PBRBaseMaterial {
  48629. /**
  48630. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48631. */
  48632. static readonly PBRMATERIAL_OPAQUE: number;
  48633. /**
  48634. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48635. */
  48636. static readonly PBRMATERIAL_ALPHATEST: number;
  48637. /**
  48638. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48639. */
  48640. static readonly PBRMATERIAL_ALPHABLEND: number;
  48641. /**
  48642. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48643. * They are also discarded below the alpha cutoff threshold to improve performances.
  48644. */
  48645. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48646. /**
  48647. * Defines the default value of how much AO map is occluding the analytical lights
  48648. * (point spot...).
  48649. */
  48650. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48651. /**
  48652. * Intensity of the direct lights e.g. the four lights available in your scene.
  48653. * This impacts both the direct diffuse and specular highlights.
  48654. */
  48655. directIntensity: number;
  48656. /**
  48657. * Intensity of the emissive part of the material.
  48658. * This helps controlling the emissive effect without modifying the emissive color.
  48659. */
  48660. emissiveIntensity: number;
  48661. /**
  48662. * Intensity of the environment e.g. how much the environment will light the object
  48663. * either through harmonics for rough material or through the refelction for shiny ones.
  48664. */
  48665. environmentIntensity: number;
  48666. /**
  48667. * This is a special control allowing the reduction of the specular highlights coming from the
  48668. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48669. */
  48670. specularIntensity: number;
  48671. /**
  48672. * Debug Control allowing disabling the bump map on this material.
  48673. */
  48674. disableBumpMap: boolean;
  48675. /**
  48676. * AKA Diffuse Texture in standard nomenclature.
  48677. */
  48678. albedoTexture: BaseTexture;
  48679. /**
  48680. * AKA Occlusion Texture in other nomenclature.
  48681. */
  48682. ambientTexture: BaseTexture;
  48683. /**
  48684. * AKA Occlusion Texture Intensity in other nomenclature.
  48685. */
  48686. ambientTextureStrength: number;
  48687. /**
  48688. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48689. * 1 means it completely occludes it
  48690. * 0 mean it has no impact
  48691. */
  48692. ambientTextureImpactOnAnalyticalLights: number;
  48693. /**
  48694. * Stores the alpha values in a texture.
  48695. */
  48696. opacityTexture: BaseTexture;
  48697. /**
  48698. * Stores the reflection values in a texture.
  48699. */
  48700. reflectionTexture: Nullable<BaseTexture>;
  48701. /**
  48702. * Stores the emissive values in a texture.
  48703. */
  48704. emissiveTexture: BaseTexture;
  48705. /**
  48706. * AKA Specular texture in other nomenclature.
  48707. */
  48708. reflectivityTexture: BaseTexture;
  48709. /**
  48710. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48711. */
  48712. metallicTexture: BaseTexture;
  48713. /**
  48714. * Specifies the metallic scalar of the metallic/roughness workflow.
  48715. * Can also be used to scale the metalness values of the metallic texture.
  48716. */
  48717. metallic: Nullable<number>;
  48718. /**
  48719. * Specifies the roughness scalar of the metallic/roughness workflow.
  48720. * Can also be used to scale the roughness values of the metallic texture.
  48721. */
  48722. roughness: Nullable<number>;
  48723. /**
  48724. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48725. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48726. */
  48727. microSurfaceTexture: BaseTexture;
  48728. /**
  48729. * Stores surface normal data used to displace a mesh in a texture.
  48730. */
  48731. bumpTexture: BaseTexture;
  48732. /**
  48733. * Stores the pre-calculated light information of a mesh in a texture.
  48734. */
  48735. lightmapTexture: BaseTexture;
  48736. /**
  48737. * Stores the refracted light information in a texture.
  48738. */
  48739. refractionTexture: Nullable<BaseTexture>;
  48740. /**
  48741. * The color of a material in ambient lighting.
  48742. */
  48743. ambientColor: Color3;
  48744. /**
  48745. * AKA Diffuse Color in other nomenclature.
  48746. */
  48747. albedoColor: Color3;
  48748. /**
  48749. * AKA Specular Color in other nomenclature.
  48750. */
  48751. reflectivityColor: Color3;
  48752. /**
  48753. * The color reflected from the material.
  48754. */
  48755. reflectionColor: Color3;
  48756. /**
  48757. * The color emitted from the material.
  48758. */
  48759. emissiveColor: Color3;
  48760. /**
  48761. * AKA Glossiness in other nomenclature.
  48762. */
  48763. microSurface: number;
  48764. /**
  48765. * source material index of refraction (IOR)' / 'destination material IOR.
  48766. */
  48767. indexOfRefraction: number;
  48768. /**
  48769. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48770. */
  48771. invertRefractionY: boolean;
  48772. /**
  48773. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48774. * Materials half opaque for instance using refraction could benefit from this control.
  48775. */
  48776. linkRefractionWithTransparency: boolean;
  48777. /**
  48778. * If true, the light map contains occlusion information instead of lighting info.
  48779. */
  48780. useLightmapAsShadowmap: boolean;
  48781. /**
  48782. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48783. */
  48784. useAlphaFromAlbedoTexture: boolean;
  48785. /**
  48786. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48787. */
  48788. forceAlphaTest: boolean;
  48789. /**
  48790. * Defines the alpha limits in alpha test mode.
  48791. */
  48792. alphaCutOff: number;
  48793. /**
  48794. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48795. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48796. */
  48797. useSpecularOverAlpha: boolean;
  48798. /**
  48799. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48800. */
  48801. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48802. /**
  48803. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48804. */
  48805. useRoughnessFromMetallicTextureAlpha: boolean;
  48806. /**
  48807. * Specifies if the metallic texture contains the roughness information in its green channel.
  48808. */
  48809. useRoughnessFromMetallicTextureGreen: boolean;
  48810. /**
  48811. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48812. */
  48813. useMetallnessFromMetallicTextureBlue: boolean;
  48814. /**
  48815. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48816. */
  48817. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48818. /**
  48819. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48820. */
  48821. useAmbientInGrayScale: boolean;
  48822. /**
  48823. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48824. * The material will try to infer what glossiness each pixel should be.
  48825. */
  48826. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48827. /**
  48828. * BJS is using an harcoded light falloff based on a manually sets up range.
  48829. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48830. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48831. */
  48832. /**
  48833. * BJS is using an harcoded light falloff based on a manually sets up range.
  48834. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48835. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48836. */
  48837. usePhysicalLightFalloff: boolean;
  48838. /**
  48839. * In order to support the falloff compatibility with gltf, a special mode has been added
  48840. * to reproduce the gltf light falloff.
  48841. */
  48842. /**
  48843. * In order to support the falloff compatibility with gltf, a special mode has been added
  48844. * to reproduce the gltf light falloff.
  48845. */
  48846. useGLTFLightFalloff: boolean;
  48847. /**
  48848. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48849. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48850. */
  48851. useRadianceOverAlpha: boolean;
  48852. /**
  48853. * Allows using an object space normal map (instead of tangent space).
  48854. */
  48855. useObjectSpaceNormalMap: boolean;
  48856. /**
  48857. * Allows using the bump map in parallax mode.
  48858. */
  48859. useParallax: boolean;
  48860. /**
  48861. * Allows using the bump map in parallax occlusion mode.
  48862. */
  48863. useParallaxOcclusion: boolean;
  48864. /**
  48865. * Controls the scale bias of the parallax mode.
  48866. */
  48867. parallaxScaleBias: number;
  48868. /**
  48869. * If sets to true, disables all the lights affecting the material.
  48870. */
  48871. disableLighting: boolean;
  48872. /**
  48873. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48874. */
  48875. forceIrradianceInFragment: boolean;
  48876. /**
  48877. * Number of Simultaneous lights allowed on the material.
  48878. */
  48879. maxSimultaneousLights: number;
  48880. /**
  48881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48882. */
  48883. invertNormalMapX: boolean;
  48884. /**
  48885. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48886. */
  48887. invertNormalMapY: boolean;
  48888. /**
  48889. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48890. */
  48891. twoSidedLighting: boolean;
  48892. /**
  48893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48894. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48895. */
  48896. useAlphaFresnel: boolean;
  48897. /**
  48898. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48899. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48900. */
  48901. useLinearAlphaFresnel: boolean;
  48902. /**
  48903. * Let user defines the brdf lookup texture used for IBL.
  48904. * A default 8bit version is embedded but you could point at :
  48905. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48906. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48907. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48908. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48909. */
  48910. environmentBRDFTexture: Nullable<BaseTexture>;
  48911. /**
  48912. * Force normal to face away from face.
  48913. */
  48914. forceNormalForward: boolean;
  48915. /**
  48916. * Enables specular anti aliasing in the PBR shader.
  48917. * It will both interacts on the Geometry for analytical and IBL lighting.
  48918. * It also prefilter the roughness map based on the bump values.
  48919. */
  48920. enableSpecularAntiAliasing: boolean;
  48921. /**
  48922. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48923. * makes the reflect vector face the model (under horizon).
  48924. */
  48925. useHorizonOcclusion: boolean;
  48926. /**
  48927. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48928. * too much the area relying on ambient texture to define their ambient occlusion.
  48929. */
  48930. useRadianceOcclusion: boolean;
  48931. /**
  48932. * If set to true, no lighting calculations will be applied.
  48933. */
  48934. unlit: boolean;
  48935. /**
  48936. * Gets the image processing configuration used either in this material.
  48937. */
  48938. /**
  48939. * Sets the Default image processing configuration used either in the this material.
  48940. *
  48941. * If sets to null, the scene one is in use.
  48942. */
  48943. imageProcessingConfiguration: ImageProcessingConfiguration;
  48944. /**
  48945. * Gets wether the color curves effect is enabled.
  48946. */
  48947. /**
  48948. * Sets wether the color curves effect is enabled.
  48949. */
  48950. cameraColorCurvesEnabled: boolean;
  48951. /**
  48952. * Gets wether the color grading effect is enabled.
  48953. */
  48954. /**
  48955. * Gets wether the color grading effect is enabled.
  48956. */
  48957. cameraColorGradingEnabled: boolean;
  48958. /**
  48959. * Gets wether tonemapping is enabled or not.
  48960. */
  48961. /**
  48962. * Sets wether tonemapping is enabled or not
  48963. */
  48964. cameraToneMappingEnabled: boolean;
  48965. /**
  48966. * The camera exposure used on this material.
  48967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48968. * This corresponds to a photographic exposure.
  48969. */
  48970. /**
  48971. * The camera exposure used on this material.
  48972. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48973. * This corresponds to a photographic exposure.
  48974. */
  48975. cameraExposure: number;
  48976. /**
  48977. * Gets The camera contrast used on this material.
  48978. */
  48979. /**
  48980. * Sets The camera contrast used on this material.
  48981. */
  48982. cameraContrast: number;
  48983. /**
  48984. * Gets the Color Grading 2D Lookup Texture.
  48985. */
  48986. /**
  48987. * Sets the Color Grading 2D Lookup Texture.
  48988. */
  48989. cameraColorGradingTexture: Nullable<BaseTexture>;
  48990. /**
  48991. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48992. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48993. * 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;
  48994. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48995. */
  48996. /**
  48997. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48998. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48999. * 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;
  49000. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49001. */
  49002. cameraColorCurves: Nullable<ColorCurves>;
  49003. /**
  49004. * Instantiates a new PBRMaterial instance.
  49005. *
  49006. * @param name The material name
  49007. * @param scene The scene the material will be use in.
  49008. */
  49009. constructor(name: string, scene: Scene);
  49010. /**
  49011. * Returns the name of this material class.
  49012. */
  49013. getClassName(): string;
  49014. /**
  49015. * Makes a duplicate of the current material.
  49016. * @param name - name to use for the new material.
  49017. */
  49018. clone(name: string): PBRMaterial;
  49019. /**
  49020. * Serializes this PBR Material.
  49021. * @returns - An object with the serialized material.
  49022. */
  49023. serialize(): any;
  49024. /**
  49025. * Parses a PBR Material from a serialized object.
  49026. * @param source - Serialized object.
  49027. * @param scene - BJS scene instance.
  49028. * @param rootUrl - url for the scene object
  49029. * @returns - PBRMaterial
  49030. */
  49031. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  49032. }
  49033. }
  49034. declare module "babylonjs/Misc/dds" {
  49035. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49036. import { Engine } from "babylonjs/Engines/engine";
  49037. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49038. import { Nullable } from "babylonjs/types";
  49039. import { Scene } from "babylonjs/scene";
  49040. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  49041. /**
  49042. * Direct draw surface info
  49043. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  49044. */
  49045. export interface DDSInfo {
  49046. /**
  49047. * Width of the texture
  49048. */
  49049. width: number;
  49050. /**
  49051. * Width of the texture
  49052. */
  49053. height: number;
  49054. /**
  49055. * Number of Mipmaps for the texture
  49056. * @see https://en.wikipedia.org/wiki/Mipmap
  49057. */
  49058. mipmapCount: number;
  49059. /**
  49060. * If the textures format is a known fourCC format
  49061. * @see https://www.fourcc.org/
  49062. */
  49063. isFourCC: boolean;
  49064. /**
  49065. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  49066. */
  49067. isRGB: boolean;
  49068. /**
  49069. * If the texture is a lumincance format
  49070. */
  49071. isLuminance: boolean;
  49072. /**
  49073. * If this is a cube texture
  49074. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  49075. */
  49076. isCube: boolean;
  49077. /**
  49078. * If the texture is a compressed format eg. FOURCC_DXT1
  49079. */
  49080. isCompressed: boolean;
  49081. /**
  49082. * The dxgiFormat of the texture
  49083. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  49084. */
  49085. dxgiFormat: number;
  49086. /**
  49087. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  49088. */
  49089. textureType: number;
  49090. /**
  49091. * Sphericle polynomial created for the dds texture
  49092. */
  49093. sphericalPolynomial?: SphericalPolynomial;
  49094. }
  49095. /**
  49096. * Class used to provide DDS decompression tools
  49097. */
  49098. export class DDSTools {
  49099. /**
  49100. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  49101. */
  49102. static StoreLODInAlphaChannel: boolean;
  49103. /**
  49104. * Gets DDS information from an array buffer
  49105. * @param arrayBuffer defines the array buffer to read data from
  49106. * @returns the DDS information
  49107. */
  49108. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  49109. private static _FloatView;
  49110. private static _Int32View;
  49111. private static _ToHalfFloat;
  49112. private static _FromHalfFloat;
  49113. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  49114. private static _GetHalfFloatRGBAArrayBuffer;
  49115. private static _GetFloatRGBAArrayBuffer;
  49116. private static _GetFloatAsUIntRGBAArrayBuffer;
  49117. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  49118. private static _GetRGBAArrayBuffer;
  49119. private static _ExtractLongWordOrder;
  49120. private static _GetRGBArrayBuffer;
  49121. private static _GetLuminanceArrayBuffer;
  49122. /**
  49123. * Uploads DDS Levels to a Babylon Texture
  49124. * @hidden
  49125. */
  49126. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  49127. }
  49128. module "babylonjs/Engines/engine" {
  49129. interface Engine {
  49130. /**
  49131. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  49132. * @param rootUrl defines the url where the file to load is located
  49133. * @param scene defines the current scene
  49134. * @param lodScale defines scale to apply to the mip map selection
  49135. * @param lodOffset defines offset to apply to the mip map selection
  49136. * @param onLoad defines an optional callback raised when the texture is loaded
  49137. * @param onError defines an optional callback raised if there is an issue to load the texture
  49138. * @param format defines the format of the data
  49139. * @param forcedExtension defines the extension to use to pick the right loader
  49140. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  49141. * @returns the cube texture as an InternalTexture
  49142. */
  49143. 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;
  49144. }
  49145. }
  49146. }
  49147. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  49148. import { Nullable } from "babylonjs/types";
  49149. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49150. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49151. /**
  49152. * Implementation of the DDS Texture Loader.
  49153. * @hidden
  49154. */
  49155. export class _DDSTextureLoader implements IInternalTextureLoader {
  49156. /**
  49157. * Defines wether the loader supports cascade loading the different faces.
  49158. */
  49159. readonly supportCascades: boolean;
  49160. /**
  49161. * This returns if the loader support the current file information.
  49162. * @param extension defines the file extension of the file being loaded
  49163. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49164. * @param fallback defines the fallback internal texture if any
  49165. * @param isBase64 defines whether the texture is encoded as a base64
  49166. * @param isBuffer defines whether the texture data are stored as a buffer
  49167. * @returns true if the loader can load the specified file
  49168. */
  49169. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49170. /**
  49171. * Transform the url before loading if required.
  49172. * @param rootUrl the url of the texture
  49173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49174. * @returns the transformed texture
  49175. */
  49176. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49177. /**
  49178. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49179. * @param rootUrl the url of the texture
  49180. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49181. * @returns the fallback texture
  49182. */
  49183. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49184. /**
  49185. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49186. * @param data contains the texture data
  49187. * @param texture defines the BabylonJS internal texture
  49188. * @param createPolynomials will be true if polynomials have been requested
  49189. * @param onLoad defines the callback to trigger once the texture is ready
  49190. * @param onError defines the callback to trigger in case of error
  49191. */
  49192. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49193. /**
  49194. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49195. * @param data contains the texture data
  49196. * @param texture defines the BabylonJS internal texture
  49197. * @param callback defines the method to call once ready to upload
  49198. */
  49199. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49200. }
  49201. }
  49202. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49203. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49204. /** @hidden */
  49205. export var rgbdEncodePixelShader: {
  49206. name: string;
  49207. shader: string;
  49208. };
  49209. }
  49210. declare module "babylonjs/Misc/environmentTextureTools" {
  49211. import { Nullable } from "babylonjs/types";
  49212. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49213. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49214. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49215. import "babylonjs/Engines/Extensions/engine.renderTarget";
  49216. import "babylonjs/Shaders/rgbdEncode.fragment";
  49217. import "babylonjs/Shaders/rgbdDecode.fragment";
  49218. /**
  49219. * Raw texture data and descriptor sufficient for WebGL texture upload
  49220. */
  49221. export interface EnvironmentTextureInfo {
  49222. /**
  49223. * Version of the environment map
  49224. */
  49225. version: number;
  49226. /**
  49227. * Width of image
  49228. */
  49229. width: number;
  49230. /**
  49231. * Irradiance information stored in the file.
  49232. */
  49233. irradiance: any;
  49234. /**
  49235. * Specular information stored in the file.
  49236. */
  49237. specular: any;
  49238. }
  49239. /**
  49240. * Sets of helpers addressing the serialization and deserialization of environment texture
  49241. * stored in a BabylonJS env file.
  49242. * Those files are usually stored as .env files.
  49243. */
  49244. export class EnvironmentTextureTools {
  49245. /**
  49246. * Magic number identifying the env file.
  49247. */
  49248. private static _MagicBytes;
  49249. /**
  49250. * Gets the environment info from an env file.
  49251. * @param data The array buffer containing the .env bytes.
  49252. * @returns the environment file info (the json header) if successfully parsed.
  49253. */
  49254. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  49255. /**
  49256. * Creates an environment texture from a loaded cube texture.
  49257. * @param texture defines the cube texture to convert in env file
  49258. * @return a promise containing the environment data if succesfull.
  49259. */
  49260. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49261. /**
  49262. * Creates a JSON representation of the spherical data.
  49263. * @param texture defines the texture containing the polynomials
  49264. * @return the JSON representation of the spherical info
  49265. */
  49266. private static _CreateEnvTextureIrradiance;
  49267. /**
  49268. * Uploads the texture info contained in the env file to the GPU.
  49269. * @param texture defines the internal texture to upload to
  49270. * @param arrayBuffer defines the buffer cotaining the data to load
  49271. * @param info defines the texture info retrieved through the GetEnvInfo method
  49272. * @returns a promise
  49273. */
  49274. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  49275. /**
  49276. * Uploads the levels of image data to the GPU.
  49277. * @param texture defines the internal texture to upload to
  49278. * @param imageData defines the array buffer views of image data [mipmap][face]
  49279. * @returns a promise
  49280. */
  49281. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49282. /**
  49283. * Uploads spherical polynomials information to the texture.
  49284. * @param texture defines the texture we are trying to upload the information to
  49285. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49286. */
  49287. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49288. /** @hidden */
  49289. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49290. }
  49291. }
  49292. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  49293. import { Nullable } from "babylonjs/types";
  49294. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49295. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49296. /**
  49297. * Implementation of the ENV Texture Loader.
  49298. * @hidden
  49299. */
  49300. export class _ENVTextureLoader implements IInternalTextureLoader {
  49301. /**
  49302. * Defines wether the loader supports cascade loading the different faces.
  49303. */
  49304. readonly supportCascades: boolean;
  49305. /**
  49306. * This returns if the loader support the current file information.
  49307. * @param extension defines the file extension of the file being loaded
  49308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49309. * @param fallback defines the fallback internal texture if any
  49310. * @param isBase64 defines whether the texture is encoded as a base64
  49311. * @param isBuffer defines whether the texture data are stored as a buffer
  49312. * @returns true if the loader can load the specified file
  49313. */
  49314. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49315. /**
  49316. * Transform the url before loading if required.
  49317. * @param rootUrl the url of the texture
  49318. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49319. * @returns the transformed texture
  49320. */
  49321. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49322. /**
  49323. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49324. * @param rootUrl the url of the texture
  49325. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49326. * @returns the fallback texture
  49327. */
  49328. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49329. /**
  49330. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49331. * @param data contains the texture data
  49332. * @param texture defines the BabylonJS internal texture
  49333. * @param createPolynomials will be true if polynomials have been requested
  49334. * @param onLoad defines the callback to trigger once the texture is ready
  49335. * @param onError defines the callback to trigger in case of error
  49336. */
  49337. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49338. /**
  49339. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49340. * @param data contains the texture data
  49341. * @param texture defines the BabylonJS internal texture
  49342. * @param callback defines the method to call once ready to upload
  49343. */
  49344. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  49345. }
  49346. }
  49347. declare module "babylonjs/Misc/khronosTextureContainer" {
  49348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49349. /**
  49350. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49351. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49352. */
  49353. export class KhronosTextureContainer {
  49354. /** contents of the KTX container file */
  49355. arrayBuffer: any;
  49356. private static HEADER_LEN;
  49357. private static COMPRESSED_2D;
  49358. private static COMPRESSED_3D;
  49359. private static TEX_2D;
  49360. private static TEX_3D;
  49361. /**
  49362. * Gets the openGL type
  49363. */
  49364. glType: number;
  49365. /**
  49366. * Gets the openGL type size
  49367. */
  49368. glTypeSize: number;
  49369. /**
  49370. * Gets the openGL format
  49371. */
  49372. glFormat: number;
  49373. /**
  49374. * Gets the openGL internal format
  49375. */
  49376. glInternalFormat: number;
  49377. /**
  49378. * Gets the base internal format
  49379. */
  49380. glBaseInternalFormat: number;
  49381. /**
  49382. * Gets image width in pixel
  49383. */
  49384. pixelWidth: number;
  49385. /**
  49386. * Gets image height in pixel
  49387. */
  49388. pixelHeight: number;
  49389. /**
  49390. * Gets image depth in pixels
  49391. */
  49392. pixelDepth: number;
  49393. /**
  49394. * Gets the number of array elements
  49395. */
  49396. numberOfArrayElements: number;
  49397. /**
  49398. * Gets the number of faces
  49399. */
  49400. numberOfFaces: number;
  49401. /**
  49402. * Gets the number of mipmap levels
  49403. */
  49404. numberOfMipmapLevels: number;
  49405. /**
  49406. * Gets the bytes of key value data
  49407. */
  49408. bytesOfKeyValueData: number;
  49409. /**
  49410. * Gets the load type
  49411. */
  49412. loadType: number;
  49413. /**
  49414. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  49415. */
  49416. isInvalid: boolean;
  49417. /**
  49418. * Creates a new KhronosTextureContainer
  49419. * @param arrayBuffer contents of the KTX container file
  49420. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  49421. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  49422. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  49423. */
  49424. constructor(
  49425. /** contents of the KTX container file */
  49426. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  49427. /**
  49428. * Uploads KTX content to a Babylon Texture.
  49429. * It is assumed that the texture has already been created & is currently bound
  49430. * @hidden
  49431. */
  49432. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  49433. private _upload2DCompressedLevels;
  49434. }
  49435. }
  49436. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  49437. import { Nullable } from "babylonjs/types";
  49438. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49439. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  49440. /**
  49441. * Implementation of the KTX Texture Loader.
  49442. * @hidden
  49443. */
  49444. export class _KTXTextureLoader implements IInternalTextureLoader {
  49445. /**
  49446. * Defines wether the loader supports cascade loading the different faces.
  49447. */
  49448. readonly supportCascades: boolean;
  49449. /**
  49450. * This returns if the loader support the current file information.
  49451. * @param extension defines the file extension of the file being loaded
  49452. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49453. * @param fallback defines the fallback internal texture if any
  49454. * @param isBase64 defines whether the texture is encoded as a base64
  49455. * @param isBuffer defines whether the texture data are stored as a buffer
  49456. * @returns true if the loader can load the specified file
  49457. */
  49458. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  49459. /**
  49460. * Transform the url before loading if required.
  49461. * @param rootUrl the url of the texture
  49462. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49463. * @returns the transformed texture
  49464. */
  49465. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  49466. /**
  49467. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  49468. * @param rootUrl the url of the texture
  49469. * @param textureFormatInUse defines the current compressed format in use iun the engine
  49470. * @returns the fallback texture
  49471. */
  49472. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  49473. /**
  49474. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  49475. * @param data contains the texture data
  49476. * @param texture defines the BabylonJS internal texture
  49477. * @param createPolynomials will be true if polynomials have been requested
  49478. * @param onLoad defines the callback to trigger once the texture is ready
  49479. * @param onError defines the callback to trigger in case of error
  49480. */
  49481. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49482. /**
  49483. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49484. * @param data contains the texture data
  49485. * @param texture defines the BabylonJS internal texture
  49486. * @param callback defines the method to call once ready to upload
  49487. */
  49488. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49489. }
  49490. }
  49491. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  49492. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49493. import { Scene } from "babylonjs/scene";
  49494. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  49495. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  49496. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  49497. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  49498. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  49499. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  49500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49501. /**
  49502. * Options for the default xr helper
  49503. */
  49504. export class WebXRDefaultExperienceOptions {
  49505. /**
  49506. * Floor meshes that should be used for teleporting
  49507. */
  49508. floorMeshes: Array<AbstractMesh>;
  49509. }
  49510. /**
  49511. * Default experience which provides a similar setup to the previous webVRExperience
  49512. */
  49513. export class WebXRDefaultExperience {
  49514. /**
  49515. * Base experience
  49516. */
  49517. baseExperience: WebXRExperienceHelper;
  49518. /**
  49519. * Input experience extension
  49520. */
  49521. input: WebXRInput;
  49522. /**
  49523. * Loads the controller models
  49524. */
  49525. controllerModelLoader: WebXRControllerModelLoader;
  49526. /**
  49527. * Enables laser pointer and selection
  49528. */
  49529. pointerSelection: WebXRControllerPointerSelection;
  49530. /**
  49531. * Enables teleportation
  49532. */
  49533. teleportation: WebXRControllerTeleportation;
  49534. /**
  49535. * Enables ui for enetering/exiting xr
  49536. */
  49537. enterExitUI: WebXREnterExitUI;
  49538. /**
  49539. * Default output canvas xr should render to
  49540. */
  49541. outputCanvas: WebXRManagedOutputCanvas;
  49542. /**
  49543. * Creates the default xr experience
  49544. * @param scene scene
  49545. * @param options options for basic configuration
  49546. * @returns resulting WebXRDefaultExperience
  49547. */
  49548. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49549. private constructor();
  49550. /**
  49551. * DIsposes of the experience helper
  49552. */
  49553. dispose(): void;
  49554. }
  49555. }
  49556. declare module "babylonjs/Helpers/sceneHelpers" {
  49557. import { Nullable } from "babylonjs/types";
  49558. import { Mesh } from "babylonjs/Meshes/mesh";
  49559. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49560. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49561. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49562. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49563. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49564. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49565. import "babylonjs/Meshes/Builders/boxBuilder";
  49566. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  49567. /** @hidden */
  49568. export var _forceSceneHelpersToBundle: boolean;
  49569. module "babylonjs/scene" {
  49570. interface Scene {
  49571. /**
  49572. * Creates a default light for the scene.
  49573. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49574. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49575. */
  49576. createDefaultLight(replace?: boolean): void;
  49577. /**
  49578. * Creates a default camera for the scene.
  49579. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49580. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49581. * @param replace has default false, when true replaces the active camera in the scene
  49582. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49583. */
  49584. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49585. /**
  49586. * Creates a default camera and a default light.
  49587. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49588. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49589. * @param replace has the default false, when true replaces the active camera/light in the scene
  49590. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49591. */
  49592. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49593. /**
  49594. * Creates a new sky box
  49595. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49596. * @param environmentTexture defines the texture to use as environment texture
  49597. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49598. * @param scale defines the overall scale of the skybox
  49599. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49600. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49601. * @returns a new mesh holding the sky box
  49602. */
  49603. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49604. /**
  49605. * Creates a new environment
  49606. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49607. * @param options defines the options you can use to configure the environment
  49608. * @returns the new EnvironmentHelper
  49609. */
  49610. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49611. /**
  49612. * Creates a new VREXperienceHelper
  49613. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49614. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49615. * @returns a new VREXperienceHelper
  49616. */
  49617. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49618. /**
  49619. * Creates a new WebXRDefaultExperience
  49620. * @see http://doc.babylonjs.com/how_to/webxr
  49621. * @param options experience options
  49622. * @returns a promise for a new WebXRDefaultExperience
  49623. */
  49624. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49625. }
  49626. }
  49627. }
  49628. declare module "babylonjs/Helpers/videoDome" {
  49629. import { Scene } from "babylonjs/scene";
  49630. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49631. import { Mesh } from "babylonjs/Meshes/mesh";
  49632. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49633. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49634. import "babylonjs/Meshes/Builders/sphereBuilder";
  49635. /**
  49636. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49637. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49638. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49639. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49640. */
  49641. export class VideoDome extends TransformNode {
  49642. /**
  49643. * Define the video source as a Monoscopic panoramic 360 video.
  49644. */
  49645. static readonly MODE_MONOSCOPIC: number;
  49646. /**
  49647. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49648. */
  49649. static readonly MODE_TOPBOTTOM: number;
  49650. /**
  49651. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49652. */
  49653. static readonly MODE_SIDEBYSIDE: number;
  49654. private _useDirectMapping;
  49655. /**
  49656. * The video texture being displayed on the sphere
  49657. */
  49658. protected _videoTexture: VideoTexture;
  49659. /**
  49660. * Gets the video texture being displayed on the sphere
  49661. */
  49662. readonly videoTexture: VideoTexture;
  49663. /**
  49664. * The skybox material
  49665. */
  49666. protected _material: BackgroundMaterial;
  49667. /**
  49668. * The surface used for the skybox
  49669. */
  49670. protected _mesh: Mesh;
  49671. /**
  49672. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49673. * Also see the options.resolution property.
  49674. */
  49675. fovMultiplier: number;
  49676. private _videoMode;
  49677. /**
  49678. * Gets or set the current video mode for the video. It can be:
  49679. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49680. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49681. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49682. */
  49683. videoMode: number;
  49684. /**
  49685. * Oberserver used in Stereoscopic VR Mode.
  49686. */
  49687. private _onBeforeCameraRenderObserver;
  49688. /**
  49689. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49690. * @param name Element's name, child elements will append suffixes for their own names.
  49691. * @param urlsOrVideo defines the url(s) or the video element to use
  49692. * @param options An object containing optional or exposed sub element properties
  49693. */
  49694. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49695. resolution?: number;
  49696. clickToPlay?: boolean;
  49697. autoPlay?: boolean;
  49698. loop?: boolean;
  49699. size?: number;
  49700. poster?: string;
  49701. faceForward?: boolean;
  49702. useDirectMapping?: boolean;
  49703. }, scene: Scene);
  49704. private _changeVideoMode;
  49705. /**
  49706. * Releases resources associated with this node.
  49707. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49708. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49709. */
  49710. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49711. }
  49712. }
  49713. declare module "babylonjs/Helpers/index" {
  49714. export * from "babylonjs/Helpers/environmentHelper";
  49715. export * from "babylonjs/Helpers/photoDome";
  49716. export * from "babylonjs/Helpers/sceneHelpers";
  49717. export * from "babylonjs/Helpers/videoDome";
  49718. }
  49719. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49720. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49721. import { IDisposable } from "babylonjs/scene";
  49722. import { Engine } from "babylonjs/Engines/engine";
  49723. /**
  49724. * This class can be used to get instrumentation data from a Babylon engine
  49725. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49726. */
  49727. export class EngineInstrumentation implements IDisposable {
  49728. /**
  49729. * Define the instrumented engine.
  49730. */
  49731. engine: Engine;
  49732. private _captureGPUFrameTime;
  49733. private _gpuFrameTimeToken;
  49734. private _gpuFrameTime;
  49735. private _captureShaderCompilationTime;
  49736. private _shaderCompilationTime;
  49737. private _onBeginFrameObserver;
  49738. private _onEndFrameObserver;
  49739. private _onBeforeShaderCompilationObserver;
  49740. private _onAfterShaderCompilationObserver;
  49741. /**
  49742. * Gets the perf counter used for GPU frame time
  49743. */
  49744. readonly gpuFrameTimeCounter: PerfCounter;
  49745. /**
  49746. * Gets the GPU frame time capture status
  49747. */
  49748. /**
  49749. * Enable or disable the GPU frame time capture
  49750. */
  49751. captureGPUFrameTime: boolean;
  49752. /**
  49753. * Gets the perf counter used for shader compilation time
  49754. */
  49755. readonly shaderCompilationTimeCounter: PerfCounter;
  49756. /**
  49757. * Gets the shader compilation time capture status
  49758. */
  49759. /**
  49760. * Enable or disable the shader compilation time capture
  49761. */
  49762. captureShaderCompilationTime: boolean;
  49763. /**
  49764. * Instantiates a new engine instrumentation.
  49765. * This class can be used to get instrumentation data from a Babylon engine
  49766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49767. * @param engine Defines the engine to instrument
  49768. */
  49769. constructor(
  49770. /**
  49771. * Define the instrumented engine.
  49772. */
  49773. engine: Engine);
  49774. /**
  49775. * Dispose and release associated resources.
  49776. */
  49777. dispose(): void;
  49778. }
  49779. }
  49780. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49781. import { Scene, IDisposable } from "babylonjs/scene";
  49782. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  49783. /**
  49784. * This class can be used to get instrumentation data from a Babylon engine
  49785. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49786. */
  49787. export class SceneInstrumentation implements IDisposable {
  49788. /**
  49789. * Defines the scene to instrument
  49790. */
  49791. scene: Scene;
  49792. private _captureActiveMeshesEvaluationTime;
  49793. private _activeMeshesEvaluationTime;
  49794. private _captureRenderTargetsRenderTime;
  49795. private _renderTargetsRenderTime;
  49796. private _captureFrameTime;
  49797. private _frameTime;
  49798. private _captureRenderTime;
  49799. private _renderTime;
  49800. private _captureInterFrameTime;
  49801. private _interFrameTime;
  49802. private _captureParticlesRenderTime;
  49803. private _particlesRenderTime;
  49804. private _captureSpritesRenderTime;
  49805. private _spritesRenderTime;
  49806. private _capturePhysicsTime;
  49807. private _physicsTime;
  49808. private _captureAnimationsTime;
  49809. private _animationsTime;
  49810. private _captureCameraRenderTime;
  49811. private _cameraRenderTime;
  49812. private _onBeforeActiveMeshesEvaluationObserver;
  49813. private _onAfterActiveMeshesEvaluationObserver;
  49814. private _onBeforeRenderTargetsRenderObserver;
  49815. private _onAfterRenderTargetsRenderObserver;
  49816. private _onAfterRenderObserver;
  49817. private _onBeforeDrawPhaseObserver;
  49818. private _onAfterDrawPhaseObserver;
  49819. private _onBeforeAnimationsObserver;
  49820. private _onBeforeParticlesRenderingObserver;
  49821. private _onAfterParticlesRenderingObserver;
  49822. private _onBeforeSpritesRenderingObserver;
  49823. private _onAfterSpritesRenderingObserver;
  49824. private _onBeforePhysicsObserver;
  49825. private _onAfterPhysicsObserver;
  49826. private _onAfterAnimationsObserver;
  49827. private _onBeforeCameraRenderObserver;
  49828. private _onAfterCameraRenderObserver;
  49829. /**
  49830. * Gets the perf counter used for active meshes evaluation time
  49831. */
  49832. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49833. /**
  49834. * Gets the active meshes evaluation time capture status
  49835. */
  49836. /**
  49837. * Enable or disable the active meshes evaluation time capture
  49838. */
  49839. captureActiveMeshesEvaluationTime: boolean;
  49840. /**
  49841. * Gets the perf counter used for render targets render time
  49842. */
  49843. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49844. /**
  49845. * Gets the render targets render time capture status
  49846. */
  49847. /**
  49848. * Enable or disable the render targets render time capture
  49849. */
  49850. captureRenderTargetsRenderTime: boolean;
  49851. /**
  49852. * Gets the perf counter used for particles render time
  49853. */
  49854. readonly particlesRenderTimeCounter: PerfCounter;
  49855. /**
  49856. * Gets the particles render time capture status
  49857. */
  49858. /**
  49859. * Enable or disable the particles render time capture
  49860. */
  49861. captureParticlesRenderTime: boolean;
  49862. /**
  49863. * Gets the perf counter used for sprites render time
  49864. */
  49865. readonly spritesRenderTimeCounter: PerfCounter;
  49866. /**
  49867. * Gets the sprites render time capture status
  49868. */
  49869. /**
  49870. * Enable or disable the sprites render time capture
  49871. */
  49872. captureSpritesRenderTime: boolean;
  49873. /**
  49874. * Gets the perf counter used for physics time
  49875. */
  49876. readonly physicsTimeCounter: PerfCounter;
  49877. /**
  49878. * Gets the physics time capture status
  49879. */
  49880. /**
  49881. * Enable or disable the physics time capture
  49882. */
  49883. capturePhysicsTime: boolean;
  49884. /**
  49885. * Gets the perf counter used for animations time
  49886. */
  49887. readonly animationsTimeCounter: PerfCounter;
  49888. /**
  49889. * Gets the animations time capture status
  49890. */
  49891. /**
  49892. * Enable or disable the animations time capture
  49893. */
  49894. captureAnimationsTime: boolean;
  49895. /**
  49896. * Gets the perf counter used for frame time capture
  49897. */
  49898. readonly frameTimeCounter: PerfCounter;
  49899. /**
  49900. * Gets the frame time capture status
  49901. */
  49902. /**
  49903. * Enable or disable the frame time capture
  49904. */
  49905. captureFrameTime: boolean;
  49906. /**
  49907. * Gets the perf counter used for inter-frames time capture
  49908. */
  49909. readonly interFrameTimeCounter: PerfCounter;
  49910. /**
  49911. * Gets the inter-frames time capture status
  49912. */
  49913. /**
  49914. * Enable or disable the inter-frames time capture
  49915. */
  49916. captureInterFrameTime: boolean;
  49917. /**
  49918. * Gets the perf counter used for render time capture
  49919. */
  49920. readonly renderTimeCounter: PerfCounter;
  49921. /**
  49922. * Gets the render time capture status
  49923. */
  49924. /**
  49925. * Enable or disable the render time capture
  49926. */
  49927. captureRenderTime: boolean;
  49928. /**
  49929. * Gets the perf counter used for camera render time capture
  49930. */
  49931. readonly cameraRenderTimeCounter: PerfCounter;
  49932. /**
  49933. * Gets the camera render time capture status
  49934. */
  49935. /**
  49936. * Enable or disable the camera render time capture
  49937. */
  49938. captureCameraRenderTime: boolean;
  49939. /**
  49940. * Gets the perf counter used for draw calls
  49941. */
  49942. readonly drawCallsCounter: PerfCounter;
  49943. /**
  49944. * Instantiates a new scene instrumentation.
  49945. * This class can be used to get instrumentation data from a Babylon engine
  49946. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49947. * @param scene Defines the scene to instrument
  49948. */
  49949. constructor(
  49950. /**
  49951. * Defines the scene to instrument
  49952. */
  49953. scene: Scene);
  49954. /**
  49955. * Dispose and release associated resources.
  49956. */
  49957. dispose(): void;
  49958. }
  49959. }
  49960. declare module "babylonjs/Instrumentation/index" {
  49961. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49962. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49963. export * from "babylonjs/Instrumentation/timeToken";
  49964. }
  49965. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49966. /** @hidden */
  49967. export var glowMapGenerationPixelShader: {
  49968. name: string;
  49969. shader: string;
  49970. };
  49971. }
  49972. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49973. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49974. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49975. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49976. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49977. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49978. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49979. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49980. /** @hidden */
  49981. export var glowMapGenerationVertexShader: {
  49982. name: string;
  49983. shader: string;
  49984. };
  49985. }
  49986. declare module "babylonjs/Layers/effectLayer" {
  49987. import { Observable } from "babylonjs/Misc/observable";
  49988. import { Nullable } from "babylonjs/types";
  49989. import { Camera } from "babylonjs/Cameras/camera";
  49990. import { Scene } from "babylonjs/scene";
  49991. import { ISize } from "babylonjs/Maths/math.size";
  49992. import { Color4 } from "babylonjs/Maths/math.color";
  49993. import { Engine } from "babylonjs/Engines/engine";
  49994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49996. import { Mesh } from "babylonjs/Meshes/mesh";
  49997. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49998. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49999. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50000. import { Effect } from "babylonjs/Materials/effect";
  50001. import { Material } from "babylonjs/Materials/material";
  50002. import "babylonjs/Shaders/glowMapGeneration.fragment";
  50003. import "babylonjs/Shaders/glowMapGeneration.vertex";
  50004. /**
  50005. * Effect layer options. This helps customizing the behaviour
  50006. * of the effect layer.
  50007. */
  50008. export interface IEffectLayerOptions {
  50009. /**
  50010. * Multiplication factor apply to the canvas size to compute the render target size
  50011. * used to generated the objects (the smaller the faster).
  50012. */
  50013. mainTextureRatio: number;
  50014. /**
  50015. * Enforces a fixed size texture to ensure effect stability across devices.
  50016. */
  50017. mainTextureFixedSize?: number;
  50018. /**
  50019. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  50020. */
  50021. alphaBlendingMode: number;
  50022. /**
  50023. * The camera attached to the layer.
  50024. */
  50025. camera: Nullable<Camera>;
  50026. /**
  50027. * The rendering group to draw the layer in.
  50028. */
  50029. renderingGroupId: number;
  50030. }
  50031. /**
  50032. * The effect layer Helps adding post process effect blended with the main pass.
  50033. *
  50034. * This can be for instance use to generate glow or higlight effects on the scene.
  50035. *
  50036. * The effect layer class can not be used directly and is intented to inherited from to be
  50037. * customized per effects.
  50038. */
  50039. export abstract class EffectLayer {
  50040. private _vertexBuffers;
  50041. private _indexBuffer;
  50042. private _cachedDefines;
  50043. private _effectLayerMapGenerationEffect;
  50044. private _effectLayerOptions;
  50045. private _mergeEffect;
  50046. protected _scene: Scene;
  50047. protected _engine: Engine;
  50048. protected _maxSize: number;
  50049. protected _mainTextureDesiredSize: ISize;
  50050. protected _mainTexture: RenderTargetTexture;
  50051. protected _shouldRender: boolean;
  50052. protected _postProcesses: PostProcess[];
  50053. protected _textures: BaseTexture[];
  50054. protected _emissiveTextureAndColor: {
  50055. texture: Nullable<BaseTexture>;
  50056. color: Color4;
  50057. };
  50058. /**
  50059. * The name of the layer
  50060. */
  50061. name: string;
  50062. /**
  50063. * The clear color of the texture used to generate the glow map.
  50064. */
  50065. neutralColor: Color4;
  50066. /**
  50067. * Specifies wether the highlight layer is enabled or not.
  50068. */
  50069. isEnabled: boolean;
  50070. /**
  50071. * Gets the camera attached to the layer.
  50072. */
  50073. readonly camera: Nullable<Camera>;
  50074. /**
  50075. * Gets the rendering group id the layer should render in.
  50076. */
  50077. renderingGroupId: number;
  50078. /**
  50079. * An event triggered when the effect layer has been disposed.
  50080. */
  50081. onDisposeObservable: Observable<EffectLayer>;
  50082. /**
  50083. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  50084. */
  50085. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  50086. /**
  50087. * An event triggered when the generated texture is being merged in the scene.
  50088. */
  50089. onBeforeComposeObservable: Observable<EffectLayer>;
  50090. /**
  50091. * An event triggered when the generated texture has been merged in the scene.
  50092. */
  50093. onAfterComposeObservable: Observable<EffectLayer>;
  50094. /**
  50095. * An event triggered when the efffect layer changes its size.
  50096. */
  50097. onSizeChangedObservable: Observable<EffectLayer>;
  50098. /** @hidden */
  50099. static _SceneComponentInitialization: (scene: Scene) => void;
  50100. /**
  50101. * Instantiates a new effect Layer and references it in the scene.
  50102. * @param name The name of the layer
  50103. * @param scene The scene to use the layer in
  50104. */
  50105. constructor(
  50106. /** The Friendly of the effect in the scene */
  50107. name: string, scene: Scene);
  50108. /**
  50109. * Get the effect name of the layer.
  50110. * @return The effect name
  50111. */
  50112. abstract getEffectName(): string;
  50113. /**
  50114. * Checks for the readiness of the element composing the layer.
  50115. * @param subMesh the mesh to check for
  50116. * @param useInstances specify wether or not to use instances to render the mesh
  50117. * @return true if ready otherwise, false
  50118. */
  50119. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50120. /**
  50121. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50122. * @returns true if the effect requires stencil during the main canvas render pass.
  50123. */
  50124. abstract needStencil(): boolean;
  50125. /**
  50126. * Create the merge effect. This is the shader use to blit the information back
  50127. * to the main canvas at the end of the scene rendering.
  50128. * @returns The effect containing the shader used to merge the effect on the main canvas
  50129. */
  50130. protected abstract _createMergeEffect(): Effect;
  50131. /**
  50132. * Creates the render target textures and post processes used in the effect layer.
  50133. */
  50134. protected abstract _createTextureAndPostProcesses(): void;
  50135. /**
  50136. * Implementation specific of rendering the generating effect on the main canvas.
  50137. * @param effect The effect used to render through
  50138. */
  50139. protected abstract _internalRender(effect: Effect): void;
  50140. /**
  50141. * Sets the required values for both the emissive texture and and the main color.
  50142. */
  50143. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50144. /**
  50145. * Free any resources and references associated to a mesh.
  50146. * Internal use
  50147. * @param mesh The mesh to free.
  50148. */
  50149. abstract _disposeMesh(mesh: Mesh): void;
  50150. /**
  50151. * Serializes this layer (Glow or Highlight for example)
  50152. * @returns a serialized layer object
  50153. */
  50154. abstract serialize?(): any;
  50155. /**
  50156. * Initializes the effect layer with the required options.
  50157. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  50158. */
  50159. protected _init(options: Partial<IEffectLayerOptions>): void;
  50160. /**
  50161. * Generates the index buffer of the full screen quad blending to the main canvas.
  50162. */
  50163. private _generateIndexBuffer;
  50164. /**
  50165. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  50166. */
  50167. private _generateVertexBuffer;
  50168. /**
  50169. * Sets the main texture desired size which is the closest power of two
  50170. * of the engine canvas size.
  50171. */
  50172. private _setMainTextureSize;
  50173. /**
  50174. * Creates the main texture for the effect layer.
  50175. */
  50176. protected _createMainTexture(): void;
  50177. /**
  50178. * Adds specific effects defines.
  50179. * @param defines The defines to add specifics to.
  50180. */
  50181. protected _addCustomEffectDefines(defines: string[]): void;
  50182. /**
  50183. * Checks for the readiness of the element composing the layer.
  50184. * @param subMesh the mesh to check for
  50185. * @param useInstances specify wether or not to use instances to render the mesh
  50186. * @param emissiveTexture the associated emissive texture used to generate the glow
  50187. * @return true if ready otherwise, false
  50188. */
  50189. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  50190. /**
  50191. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  50192. */
  50193. render(): void;
  50194. /**
  50195. * Determine if a given mesh will be used in the current effect.
  50196. * @param mesh mesh to test
  50197. * @returns true if the mesh will be used
  50198. */
  50199. hasMesh(mesh: AbstractMesh): boolean;
  50200. /**
  50201. * Returns true if the layer contains information to display, otherwise false.
  50202. * @returns true if the glow layer should be rendered
  50203. */
  50204. shouldRender(): boolean;
  50205. /**
  50206. * Returns true if the mesh should render, otherwise false.
  50207. * @param mesh The mesh to render
  50208. * @returns true if it should render otherwise false
  50209. */
  50210. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  50211. /**
  50212. * Returns true if the mesh can be rendered, otherwise false.
  50213. * @param mesh The mesh to render
  50214. * @param material The material used on the mesh
  50215. * @returns true if it can be rendered otherwise false
  50216. */
  50217. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50218. /**
  50219. * Returns true if the mesh should render, otherwise false.
  50220. * @param mesh The mesh to render
  50221. * @returns true if it should render otherwise false
  50222. */
  50223. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  50224. /**
  50225. * Renders the submesh passed in parameter to the generation map.
  50226. */
  50227. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  50228. /**
  50229. * Rebuild the required buffers.
  50230. * @hidden Internal use only.
  50231. */
  50232. _rebuild(): void;
  50233. /**
  50234. * Dispose only the render target textures and post process.
  50235. */
  50236. private _disposeTextureAndPostProcesses;
  50237. /**
  50238. * Dispose the highlight layer and free resources.
  50239. */
  50240. dispose(): void;
  50241. /**
  50242. * Gets the class name of the effect layer
  50243. * @returns the string with the class name of the effect layer
  50244. */
  50245. getClassName(): string;
  50246. /**
  50247. * Creates an effect layer from parsed effect layer data
  50248. * @param parsedEffectLayer defines effect layer data
  50249. * @param scene defines the current scene
  50250. * @param rootUrl defines the root URL containing the effect layer information
  50251. * @returns a parsed effect Layer
  50252. */
  50253. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  50254. }
  50255. }
  50256. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  50257. import { Scene } from "babylonjs/scene";
  50258. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50259. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50260. import { AbstractScene } from "babylonjs/abstractScene";
  50261. module "babylonjs/abstractScene" {
  50262. interface AbstractScene {
  50263. /**
  50264. * The list of effect layers (highlights/glow) added to the scene
  50265. * @see http://doc.babylonjs.com/how_to/highlight_layer
  50266. * @see http://doc.babylonjs.com/how_to/glow_layer
  50267. */
  50268. effectLayers: Array<EffectLayer>;
  50269. /**
  50270. * Removes the given effect layer from this scene.
  50271. * @param toRemove defines the effect layer to remove
  50272. * @returns the index of the removed effect layer
  50273. */
  50274. removeEffectLayer(toRemove: EffectLayer): number;
  50275. /**
  50276. * Adds the given effect layer to this scene
  50277. * @param newEffectLayer defines the effect layer to add
  50278. */
  50279. addEffectLayer(newEffectLayer: EffectLayer): void;
  50280. }
  50281. }
  50282. /**
  50283. * Defines the layer scene component responsible to manage any effect layers
  50284. * in a given scene.
  50285. */
  50286. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  50287. /**
  50288. * The component name helpfull to identify the component in the list of scene components.
  50289. */
  50290. readonly name: string;
  50291. /**
  50292. * The scene the component belongs to.
  50293. */
  50294. scene: Scene;
  50295. private _engine;
  50296. private _renderEffects;
  50297. private _needStencil;
  50298. private _previousStencilState;
  50299. /**
  50300. * Creates a new instance of the component for the given scene
  50301. * @param scene Defines the scene to register the component in
  50302. */
  50303. constructor(scene: Scene);
  50304. /**
  50305. * Registers the component in a given scene
  50306. */
  50307. register(): void;
  50308. /**
  50309. * Rebuilds the elements related to this component in case of
  50310. * context lost for instance.
  50311. */
  50312. rebuild(): void;
  50313. /**
  50314. * Serializes the component data to the specified json object
  50315. * @param serializationObject The object to serialize to
  50316. */
  50317. serialize(serializationObject: any): void;
  50318. /**
  50319. * Adds all the elements from the container to the scene
  50320. * @param container the container holding the elements
  50321. */
  50322. addFromContainer(container: AbstractScene): void;
  50323. /**
  50324. * Removes all the elements in the container from the scene
  50325. * @param container contains the elements to remove
  50326. * @param dispose if the removed element should be disposed (default: false)
  50327. */
  50328. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50329. /**
  50330. * Disposes the component and the associated ressources.
  50331. */
  50332. dispose(): void;
  50333. private _isReadyForMesh;
  50334. private _renderMainTexture;
  50335. private _setStencil;
  50336. private _setStencilBack;
  50337. private _draw;
  50338. private _drawCamera;
  50339. private _drawRenderingGroup;
  50340. }
  50341. }
  50342. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  50343. /** @hidden */
  50344. export var glowMapMergePixelShader: {
  50345. name: string;
  50346. shader: string;
  50347. };
  50348. }
  50349. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  50350. /** @hidden */
  50351. export var glowMapMergeVertexShader: {
  50352. name: string;
  50353. shader: string;
  50354. };
  50355. }
  50356. declare module "babylonjs/Layers/glowLayer" {
  50357. import { Nullable } from "babylonjs/types";
  50358. import { Camera } from "babylonjs/Cameras/camera";
  50359. import { Scene } from "babylonjs/scene";
  50360. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50361. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50362. import { Mesh } from "babylonjs/Meshes/mesh";
  50363. import { Texture } from "babylonjs/Materials/Textures/texture";
  50364. import { Effect } from "babylonjs/Materials/effect";
  50365. import { Material } from "babylonjs/Materials/material";
  50366. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50367. import { Color4 } from "babylonjs/Maths/math.color";
  50368. import "babylonjs/Shaders/glowMapMerge.fragment";
  50369. import "babylonjs/Shaders/glowMapMerge.vertex";
  50370. import "babylonjs/Layers/effectLayerSceneComponent";
  50371. module "babylonjs/abstractScene" {
  50372. interface AbstractScene {
  50373. /**
  50374. * Return a the first highlight layer of the scene with a given name.
  50375. * @param name The name of the highlight layer to look for.
  50376. * @return The highlight layer if found otherwise null.
  50377. */
  50378. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  50379. }
  50380. }
  50381. /**
  50382. * Glow layer options. This helps customizing the behaviour
  50383. * of the glow layer.
  50384. */
  50385. export interface IGlowLayerOptions {
  50386. /**
  50387. * Multiplication factor apply to the canvas size to compute the render target size
  50388. * used to generated the glowing objects (the smaller the faster).
  50389. */
  50390. mainTextureRatio: number;
  50391. /**
  50392. * Enforces a fixed size texture to ensure resize independant blur.
  50393. */
  50394. mainTextureFixedSize?: number;
  50395. /**
  50396. * How big is the kernel of the blur texture.
  50397. */
  50398. blurKernelSize: number;
  50399. /**
  50400. * The camera attached to the layer.
  50401. */
  50402. camera: Nullable<Camera>;
  50403. /**
  50404. * Enable MSAA by chosing the number of samples.
  50405. */
  50406. mainTextureSamples?: number;
  50407. /**
  50408. * The rendering group to draw the layer in.
  50409. */
  50410. renderingGroupId: number;
  50411. }
  50412. /**
  50413. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  50414. *
  50415. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50416. * glowy meshes to your scene.
  50417. *
  50418. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  50419. */
  50420. export class GlowLayer extends EffectLayer {
  50421. /**
  50422. * Effect Name of the layer.
  50423. */
  50424. static readonly EffectName: string;
  50425. /**
  50426. * The default blur kernel size used for the glow.
  50427. */
  50428. static DefaultBlurKernelSize: number;
  50429. /**
  50430. * The default texture size ratio used for the glow.
  50431. */
  50432. static DefaultTextureRatio: number;
  50433. /**
  50434. * Sets the kernel size of the blur.
  50435. */
  50436. /**
  50437. * Gets the kernel size of the blur.
  50438. */
  50439. blurKernelSize: number;
  50440. /**
  50441. * Sets the glow intensity.
  50442. */
  50443. /**
  50444. * Gets the glow intensity.
  50445. */
  50446. intensity: number;
  50447. private _options;
  50448. private _intensity;
  50449. private _horizontalBlurPostprocess1;
  50450. private _verticalBlurPostprocess1;
  50451. private _horizontalBlurPostprocess2;
  50452. private _verticalBlurPostprocess2;
  50453. private _blurTexture1;
  50454. private _blurTexture2;
  50455. private _postProcesses1;
  50456. private _postProcesses2;
  50457. private _includedOnlyMeshes;
  50458. private _excludedMeshes;
  50459. /**
  50460. * Callback used to let the user override the color selection on a per mesh basis
  50461. */
  50462. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  50463. /**
  50464. * Callback used to let the user override the texture selection on a per mesh basis
  50465. */
  50466. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  50467. /**
  50468. * Instantiates a new glow Layer and references it to the scene.
  50469. * @param name The name of the layer
  50470. * @param scene The scene to use the layer in
  50471. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  50472. */
  50473. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  50474. /**
  50475. * Get the effect name of the layer.
  50476. * @return The effect name
  50477. */
  50478. getEffectName(): string;
  50479. /**
  50480. * Create the merge effect. This is the shader use to blit the information back
  50481. * to the main canvas at the end of the scene rendering.
  50482. */
  50483. protected _createMergeEffect(): Effect;
  50484. /**
  50485. * Creates the render target textures and post processes used in the glow layer.
  50486. */
  50487. protected _createTextureAndPostProcesses(): void;
  50488. /**
  50489. * Checks for the readiness of the element composing the layer.
  50490. * @param subMesh the mesh to check for
  50491. * @param useInstances specify wether or not to use instances to render the mesh
  50492. * @param emissiveTexture the associated emissive texture used to generate the glow
  50493. * @return true if ready otherwise, false
  50494. */
  50495. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50496. /**
  50497. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50498. */
  50499. needStencil(): boolean;
  50500. /**
  50501. * Returns true if the mesh can be rendered, otherwise false.
  50502. * @param mesh The mesh to render
  50503. * @param material The material used on the mesh
  50504. * @returns true if it can be rendered otherwise false
  50505. */
  50506. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  50507. /**
  50508. * Implementation specific of rendering the generating effect on the main canvas.
  50509. * @param effect The effect used to render through
  50510. */
  50511. protected _internalRender(effect: Effect): void;
  50512. /**
  50513. * Sets the required values for both the emissive texture and and the main color.
  50514. */
  50515. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50516. /**
  50517. * Returns true if the mesh should render, otherwise false.
  50518. * @param mesh The mesh to render
  50519. * @returns true if it should render otherwise false
  50520. */
  50521. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50522. /**
  50523. * Adds specific effects defines.
  50524. * @param defines The defines to add specifics to.
  50525. */
  50526. protected _addCustomEffectDefines(defines: string[]): void;
  50527. /**
  50528. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  50529. * @param mesh The mesh to exclude from the glow layer
  50530. */
  50531. addExcludedMesh(mesh: Mesh): void;
  50532. /**
  50533. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  50534. * @param mesh The mesh to remove
  50535. */
  50536. removeExcludedMesh(mesh: Mesh): void;
  50537. /**
  50538. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  50539. * @param mesh The mesh to include in the glow layer
  50540. */
  50541. addIncludedOnlyMesh(mesh: Mesh): void;
  50542. /**
  50543. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  50544. * @param mesh The mesh to remove
  50545. */
  50546. removeIncludedOnlyMesh(mesh: Mesh): void;
  50547. /**
  50548. * Determine if a given mesh will be used in the glow layer
  50549. * @param mesh The mesh to test
  50550. * @returns true if the mesh will be highlighted by the current glow layer
  50551. */
  50552. hasMesh(mesh: AbstractMesh): boolean;
  50553. /**
  50554. * Free any resources and references associated to a mesh.
  50555. * Internal use
  50556. * @param mesh The mesh to free.
  50557. * @hidden
  50558. */
  50559. _disposeMesh(mesh: Mesh): void;
  50560. /**
  50561. * Gets the class name of the effect layer
  50562. * @returns the string with the class name of the effect layer
  50563. */
  50564. getClassName(): string;
  50565. /**
  50566. * Serializes this glow layer
  50567. * @returns a serialized glow layer object
  50568. */
  50569. serialize(): any;
  50570. /**
  50571. * Creates a Glow Layer from parsed glow layer data
  50572. * @param parsedGlowLayer defines glow layer data
  50573. * @param scene defines the current scene
  50574. * @param rootUrl defines the root URL containing the glow layer information
  50575. * @returns a parsed Glow Layer
  50576. */
  50577. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50578. }
  50579. }
  50580. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50581. /** @hidden */
  50582. export var glowBlurPostProcessPixelShader: {
  50583. name: string;
  50584. shader: string;
  50585. };
  50586. }
  50587. declare module "babylonjs/Layers/highlightLayer" {
  50588. import { Observable } from "babylonjs/Misc/observable";
  50589. import { Nullable } from "babylonjs/types";
  50590. import { Camera } from "babylonjs/Cameras/camera";
  50591. import { Scene } from "babylonjs/scene";
  50592. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50594. import { Mesh } from "babylonjs/Meshes/mesh";
  50595. import { Effect } from "babylonjs/Materials/effect";
  50596. import { Material } from "babylonjs/Materials/material";
  50597. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50598. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  50599. import "babylonjs/Shaders/glowMapMerge.fragment";
  50600. import "babylonjs/Shaders/glowMapMerge.vertex";
  50601. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50602. module "babylonjs/abstractScene" {
  50603. interface AbstractScene {
  50604. /**
  50605. * Return a the first highlight layer of the scene with a given name.
  50606. * @param name The name of the highlight layer to look for.
  50607. * @return The highlight layer if found otherwise null.
  50608. */
  50609. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50610. }
  50611. }
  50612. /**
  50613. * Highlight layer options. This helps customizing the behaviour
  50614. * of the highlight layer.
  50615. */
  50616. export interface IHighlightLayerOptions {
  50617. /**
  50618. * Multiplication factor apply to the canvas size to compute the render target size
  50619. * used to generated the glowing objects (the smaller the faster).
  50620. */
  50621. mainTextureRatio: number;
  50622. /**
  50623. * Enforces a fixed size texture to ensure resize independant blur.
  50624. */
  50625. mainTextureFixedSize?: number;
  50626. /**
  50627. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50628. * of the picture to blur (the smaller the faster).
  50629. */
  50630. blurTextureSizeRatio: number;
  50631. /**
  50632. * How big in texel of the blur texture is the vertical blur.
  50633. */
  50634. blurVerticalSize: number;
  50635. /**
  50636. * How big in texel of the blur texture is the horizontal blur.
  50637. */
  50638. blurHorizontalSize: number;
  50639. /**
  50640. * Alpha blending mode used to apply the blur. Default is combine.
  50641. */
  50642. alphaBlendingMode: number;
  50643. /**
  50644. * The camera attached to the layer.
  50645. */
  50646. camera: Nullable<Camera>;
  50647. /**
  50648. * Should we display highlight as a solid stroke?
  50649. */
  50650. isStroke?: boolean;
  50651. /**
  50652. * The rendering group to draw the layer in.
  50653. */
  50654. renderingGroupId: number;
  50655. }
  50656. /**
  50657. * The highlight layer Helps adding a glow effect around a mesh.
  50658. *
  50659. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50660. * glowy meshes to your scene.
  50661. *
  50662. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50663. */
  50664. export class HighlightLayer extends EffectLayer {
  50665. name: string;
  50666. /**
  50667. * Effect Name of the highlight layer.
  50668. */
  50669. static readonly EffectName: string;
  50670. /**
  50671. * The neutral color used during the preparation of the glow effect.
  50672. * This is black by default as the blend operation is a blend operation.
  50673. */
  50674. static NeutralColor: Color4;
  50675. /**
  50676. * Stencil value used for glowing meshes.
  50677. */
  50678. static GlowingMeshStencilReference: number;
  50679. /**
  50680. * Stencil value used for the other meshes in the scene.
  50681. */
  50682. static NormalMeshStencilReference: number;
  50683. /**
  50684. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50685. */
  50686. innerGlow: boolean;
  50687. /**
  50688. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50689. */
  50690. outerGlow: boolean;
  50691. /**
  50692. * Specifies the horizontal size of the blur.
  50693. */
  50694. /**
  50695. * Gets the horizontal size of the blur.
  50696. */
  50697. blurHorizontalSize: number;
  50698. /**
  50699. * Specifies the vertical size of the blur.
  50700. */
  50701. /**
  50702. * Gets the vertical size of the blur.
  50703. */
  50704. blurVerticalSize: number;
  50705. /**
  50706. * An event triggered when the highlight layer is being blurred.
  50707. */
  50708. onBeforeBlurObservable: Observable<HighlightLayer>;
  50709. /**
  50710. * An event triggered when the highlight layer has been blurred.
  50711. */
  50712. onAfterBlurObservable: Observable<HighlightLayer>;
  50713. private _instanceGlowingMeshStencilReference;
  50714. private _options;
  50715. private _downSamplePostprocess;
  50716. private _horizontalBlurPostprocess;
  50717. private _verticalBlurPostprocess;
  50718. private _blurTexture;
  50719. private _meshes;
  50720. private _excludedMeshes;
  50721. /**
  50722. * Instantiates a new highlight Layer and references it to the scene..
  50723. * @param name The name of the layer
  50724. * @param scene The scene to use the layer in
  50725. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50726. */
  50727. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50728. /**
  50729. * Get the effect name of the layer.
  50730. * @return The effect name
  50731. */
  50732. getEffectName(): string;
  50733. /**
  50734. * Create the merge effect. This is the shader use to blit the information back
  50735. * to the main canvas at the end of the scene rendering.
  50736. */
  50737. protected _createMergeEffect(): Effect;
  50738. /**
  50739. * Creates the render target textures and post processes used in the highlight layer.
  50740. */
  50741. protected _createTextureAndPostProcesses(): void;
  50742. /**
  50743. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50744. */
  50745. needStencil(): boolean;
  50746. /**
  50747. * Checks for the readiness of the element composing the layer.
  50748. * @param subMesh the mesh to check for
  50749. * @param useInstances specify wether or not to use instances to render the mesh
  50750. * @param emissiveTexture the associated emissive texture used to generate the glow
  50751. * @return true if ready otherwise, false
  50752. */
  50753. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50754. /**
  50755. * Implementation specific of rendering the generating effect on the main canvas.
  50756. * @param effect The effect used to render through
  50757. */
  50758. protected _internalRender(effect: Effect): void;
  50759. /**
  50760. * Returns true if the layer contains information to display, otherwise false.
  50761. */
  50762. shouldRender(): boolean;
  50763. /**
  50764. * Returns true if the mesh should render, otherwise false.
  50765. * @param mesh The mesh to render
  50766. * @returns true if it should render otherwise false
  50767. */
  50768. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50769. /**
  50770. * Sets the required values for both the emissive texture and and the main color.
  50771. */
  50772. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50773. /**
  50774. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50775. * @param mesh The mesh to exclude from the highlight layer
  50776. */
  50777. addExcludedMesh(mesh: Mesh): void;
  50778. /**
  50779. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50780. * @param mesh The mesh to highlight
  50781. */
  50782. removeExcludedMesh(mesh: Mesh): void;
  50783. /**
  50784. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50785. * @param mesh mesh to test
  50786. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50787. */
  50788. hasMesh(mesh: AbstractMesh): boolean;
  50789. /**
  50790. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50791. * @param mesh The mesh to highlight
  50792. * @param color The color of the highlight
  50793. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50794. */
  50795. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50796. /**
  50797. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50798. * @param mesh The mesh to highlight
  50799. */
  50800. removeMesh(mesh: Mesh): void;
  50801. /**
  50802. * Force the stencil to the normal expected value for none glowing parts
  50803. */
  50804. private _defaultStencilReference;
  50805. /**
  50806. * Free any resources and references associated to a mesh.
  50807. * Internal use
  50808. * @param mesh The mesh to free.
  50809. * @hidden
  50810. */
  50811. _disposeMesh(mesh: Mesh): void;
  50812. /**
  50813. * Dispose the highlight layer and free resources.
  50814. */
  50815. dispose(): void;
  50816. /**
  50817. * Gets the class name of the effect layer
  50818. * @returns the string with the class name of the effect layer
  50819. */
  50820. getClassName(): string;
  50821. /**
  50822. * Serializes this Highlight layer
  50823. * @returns a serialized Highlight layer object
  50824. */
  50825. serialize(): any;
  50826. /**
  50827. * Creates a Highlight layer from parsed Highlight layer data
  50828. * @param parsedHightlightLayer defines the Highlight layer data
  50829. * @param scene defines the current scene
  50830. * @param rootUrl defines the root URL containing the Highlight layer information
  50831. * @returns a parsed Highlight layer
  50832. */
  50833. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50834. }
  50835. }
  50836. declare module "babylonjs/Layers/layerSceneComponent" {
  50837. import { Scene } from "babylonjs/scene";
  50838. import { ISceneComponent } from "babylonjs/sceneComponent";
  50839. import { Layer } from "babylonjs/Layers/layer";
  50840. import { AbstractScene } from "babylonjs/abstractScene";
  50841. module "babylonjs/abstractScene" {
  50842. interface AbstractScene {
  50843. /**
  50844. * The list of layers (background and foreground) of the scene
  50845. */
  50846. layers: Array<Layer>;
  50847. }
  50848. }
  50849. /**
  50850. * Defines the layer scene component responsible to manage any layers
  50851. * in a given scene.
  50852. */
  50853. export class LayerSceneComponent implements ISceneComponent {
  50854. /**
  50855. * The component name helpfull to identify the component in the list of scene components.
  50856. */
  50857. readonly name: string;
  50858. /**
  50859. * The scene the component belongs to.
  50860. */
  50861. scene: Scene;
  50862. private _engine;
  50863. /**
  50864. * Creates a new instance of the component for the given scene
  50865. * @param scene Defines the scene to register the component in
  50866. */
  50867. constructor(scene: Scene);
  50868. /**
  50869. * Registers the component in a given scene
  50870. */
  50871. register(): void;
  50872. /**
  50873. * Rebuilds the elements related to this component in case of
  50874. * context lost for instance.
  50875. */
  50876. rebuild(): void;
  50877. /**
  50878. * Disposes the component and the associated ressources.
  50879. */
  50880. dispose(): void;
  50881. private _draw;
  50882. private _drawCameraPredicate;
  50883. private _drawCameraBackground;
  50884. private _drawCameraForeground;
  50885. private _drawRenderTargetPredicate;
  50886. private _drawRenderTargetBackground;
  50887. private _drawRenderTargetForeground;
  50888. /**
  50889. * Adds all the elements from the container to the scene
  50890. * @param container the container holding the elements
  50891. */
  50892. addFromContainer(container: AbstractScene): void;
  50893. /**
  50894. * Removes all the elements in the container from the scene
  50895. * @param container contains the elements to remove
  50896. * @param dispose if the removed element should be disposed (default: false)
  50897. */
  50898. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50899. }
  50900. }
  50901. declare module "babylonjs/Shaders/layer.fragment" {
  50902. /** @hidden */
  50903. export var layerPixelShader: {
  50904. name: string;
  50905. shader: string;
  50906. };
  50907. }
  50908. declare module "babylonjs/Shaders/layer.vertex" {
  50909. /** @hidden */
  50910. export var layerVertexShader: {
  50911. name: string;
  50912. shader: string;
  50913. };
  50914. }
  50915. declare module "babylonjs/Layers/layer" {
  50916. import { Observable } from "babylonjs/Misc/observable";
  50917. import { Nullable } from "babylonjs/types";
  50918. import { Scene } from "babylonjs/scene";
  50919. import { Vector2 } from "babylonjs/Maths/math.vector";
  50920. import { Color4 } from "babylonjs/Maths/math.color";
  50921. import { Texture } from "babylonjs/Materials/Textures/texture";
  50922. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50923. import "babylonjs/Shaders/layer.fragment";
  50924. import "babylonjs/Shaders/layer.vertex";
  50925. /**
  50926. * This represents a full screen 2d layer.
  50927. * This can be useful to display a picture in the background of your scene for instance.
  50928. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50929. */
  50930. export class Layer {
  50931. /**
  50932. * Define the name of the layer.
  50933. */
  50934. name: string;
  50935. /**
  50936. * Define the texture the layer should display.
  50937. */
  50938. texture: Nullable<Texture>;
  50939. /**
  50940. * Is the layer in background or foreground.
  50941. */
  50942. isBackground: boolean;
  50943. /**
  50944. * Define the color of the layer (instead of texture).
  50945. */
  50946. color: Color4;
  50947. /**
  50948. * Define the scale of the layer in order to zoom in out of the texture.
  50949. */
  50950. scale: Vector2;
  50951. /**
  50952. * Define an offset for the layer in order to shift the texture.
  50953. */
  50954. offset: Vector2;
  50955. /**
  50956. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50957. */
  50958. alphaBlendingMode: number;
  50959. /**
  50960. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50961. * Alpha test will not mix with the background color in case of transparency.
  50962. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50963. */
  50964. alphaTest: boolean;
  50965. /**
  50966. * Define a mask to restrict the layer to only some of the scene cameras.
  50967. */
  50968. layerMask: number;
  50969. /**
  50970. * Define the list of render target the layer is visible into.
  50971. */
  50972. renderTargetTextures: RenderTargetTexture[];
  50973. /**
  50974. * Define if the layer is only used in renderTarget or if it also
  50975. * renders in the main frame buffer of the canvas.
  50976. */
  50977. renderOnlyInRenderTargetTextures: boolean;
  50978. private _scene;
  50979. private _vertexBuffers;
  50980. private _indexBuffer;
  50981. private _effect;
  50982. private _alphaTestEffect;
  50983. /**
  50984. * An event triggered when the layer is disposed.
  50985. */
  50986. onDisposeObservable: Observable<Layer>;
  50987. private _onDisposeObserver;
  50988. /**
  50989. * Back compatibility with callback before the onDisposeObservable existed.
  50990. * The set callback will be triggered when the layer has been disposed.
  50991. */
  50992. onDispose: () => void;
  50993. /**
  50994. * An event triggered before rendering the scene
  50995. */
  50996. onBeforeRenderObservable: Observable<Layer>;
  50997. private _onBeforeRenderObserver;
  50998. /**
  50999. * Back compatibility with callback before the onBeforeRenderObservable existed.
  51000. * The set callback will be triggered just before rendering the layer.
  51001. */
  51002. onBeforeRender: () => void;
  51003. /**
  51004. * An event triggered after rendering the scene
  51005. */
  51006. onAfterRenderObservable: Observable<Layer>;
  51007. private _onAfterRenderObserver;
  51008. /**
  51009. * Back compatibility with callback before the onAfterRenderObservable existed.
  51010. * The set callback will be triggered just after rendering the layer.
  51011. */
  51012. onAfterRender: () => void;
  51013. /**
  51014. * Instantiates a new layer.
  51015. * This represents a full screen 2d layer.
  51016. * This can be useful to display a picture in the background of your scene for instance.
  51017. * @see https://www.babylonjs-playground.com/#08A2BS#1
  51018. * @param name Define the name of the layer in the scene
  51019. * @param imgUrl Define the url of the texture to display in the layer
  51020. * @param scene Define the scene the layer belongs to
  51021. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  51022. * @param color Defines a color for the layer
  51023. */
  51024. constructor(
  51025. /**
  51026. * Define the name of the layer.
  51027. */
  51028. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  51029. private _createIndexBuffer;
  51030. /** @hidden */
  51031. _rebuild(): void;
  51032. /**
  51033. * Renders the layer in the scene.
  51034. */
  51035. render(): void;
  51036. /**
  51037. * Disposes and releases the associated ressources.
  51038. */
  51039. dispose(): void;
  51040. }
  51041. }
  51042. declare module "babylonjs/Layers/index" {
  51043. export * from "babylonjs/Layers/effectLayer";
  51044. export * from "babylonjs/Layers/effectLayerSceneComponent";
  51045. export * from "babylonjs/Layers/glowLayer";
  51046. export * from "babylonjs/Layers/highlightLayer";
  51047. export * from "babylonjs/Layers/layer";
  51048. export * from "babylonjs/Layers/layerSceneComponent";
  51049. }
  51050. declare module "babylonjs/Shaders/lensFlare.fragment" {
  51051. /** @hidden */
  51052. export var lensFlarePixelShader: {
  51053. name: string;
  51054. shader: string;
  51055. };
  51056. }
  51057. declare module "babylonjs/Shaders/lensFlare.vertex" {
  51058. /** @hidden */
  51059. export var lensFlareVertexShader: {
  51060. name: string;
  51061. shader: string;
  51062. };
  51063. }
  51064. declare module "babylonjs/LensFlares/lensFlareSystem" {
  51065. import { Scene } from "babylonjs/scene";
  51066. import { Vector3 } from "babylonjs/Maths/math.vector";
  51067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51068. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  51069. import "babylonjs/Shaders/lensFlare.fragment";
  51070. import "babylonjs/Shaders/lensFlare.vertex";
  51071. import { Viewport } from "babylonjs/Maths/math.viewport";
  51072. /**
  51073. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51074. * It is usually composed of several `lensFlare`.
  51075. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51076. */
  51077. export class LensFlareSystem {
  51078. /**
  51079. * Define the name of the lens flare system
  51080. */
  51081. name: string;
  51082. /**
  51083. * List of lens flares used in this system.
  51084. */
  51085. lensFlares: LensFlare[];
  51086. /**
  51087. * Define a limit from the border the lens flare can be visible.
  51088. */
  51089. borderLimit: number;
  51090. /**
  51091. * Define a viewport border we do not want to see the lens flare in.
  51092. */
  51093. viewportBorder: number;
  51094. /**
  51095. * Define a predicate which could limit the list of meshes able to occlude the effect.
  51096. */
  51097. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51098. /**
  51099. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  51100. */
  51101. layerMask: number;
  51102. /**
  51103. * Define the id of the lens flare system in the scene.
  51104. * (equal to name by default)
  51105. */
  51106. id: string;
  51107. private _scene;
  51108. private _emitter;
  51109. private _vertexBuffers;
  51110. private _indexBuffer;
  51111. private _effect;
  51112. private _positionX;
  51113. private _positionY;
  51114. private _isEnabled;
  51115. /** @hidden */
  51116. static _SceneComponentInitialization: (scene: Scene) => void;
  51117. /**
  51118. * Instantiates a lens flare system.
  51119. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  51120. * It is usually composed of several `lensFlare`.
  51121. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51122. * @param name Define the name of the lens flare system in the scene
  51123. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  51124. * @param scene Define the scene the lens flare system belongs to
  51125. */
  51126. constructor(
  51127. /**
  51128. * Define the name of the lens flare system
  51129. */
  51130. name: string, emitter: any, scene: Scene);
  51131. /**
  51132. * Define if the lens flare system is enabled.
  51133. */
  51134. isEnabled: boolean;
  51135. /**
  51136. * Get the scene the effects belongs to.
  51137. * @returns the scene holding the lens flare system
  51138. */
  51139. getScene(): Scene;
  51140. /**
  51141. * Get the emitter of the lens flare system.
  51142. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51143. * @returns the emitter of the lens flare system
  51144. */
  51145. getEmitter(): any;
  51146. /**
  51147. * Set the emitter of the lens flare system.
  51148. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  51149. * @param newEmitter Define the new emitter of the system
  51150. */
  51151. setEmitter(newEmitter: any): void;
  51152. /**
  51153. * Get the lens flare system emitter position.
  51154. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  51155. * @returns the position
  51156. */
  51157. getEmitterPosition(): Vector3;
  51158. /**
  51159. * @hidden
  51160. */
  51161. computeEffectivePosition(globalViewport: Viewport): boolean;
  51162. /** @hidden */
  51163. _isVisible(): boolean;
  51164. /**
  51165. * @hidden
  51166. */
  51167. render(): boolean;
  51168. /**
  51169. * Dispose and release the lens flare with its associated resources.
  51170. */
  51171. dispose(): void;
  51172. /**
  51173. * Parse a lens flare system from a JSON repressentation
  51174. * @param parsedLensFlareSystem Define the JSON to parse
  51175. * @param scene Define the scene the parsed system should be instantiated in
  51176. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  51177. * @returns the parsed system
  51178. */
  51179. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  51180. /**
  51181. * Serialize the current Lens Flare System into a JSON representation.
  51182. * @returns the serialized JSON
  51183. */
  51184. serialize(): any;
  51185. }
  51186. }
  51187. declare module "babylonjs/LensFlares/lensFlare" {
  51188. import { Nullable } from "babylonjs/types";
  51189. import { Color3 } from "babylonjs/Maths/math.color";
  51190. import { Texture } from "babylonjs/Materials/Textures/texture";
  51191. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51192. /**
  51193. * This represents one of the lens effect in a `lensFlareSystem`.
  51194. * It controls one of the indiviual texture used in the effect.
  51195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51196. */
  51197. export class LensFlare {
  51198. /**
  51199. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51200. */
  51201. size: number;
  51202. /**
  51203. * 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.
  51204. */
  51205. position: number;
  51206. /**
  51207. * Define the lens color.
  51208. */
  51209. color: Color3;
  51210. /**
  51211. * Define the lens texture.
  51212. */
  51213. texture: Nullable<Texture>;
  51214. /**
  51215. * Define the alpha mode to render this particular lens.
  51216. */
  51217. alphaMode: number;
  51218. private _system;
  51219. /**
  51220. * Creates a new Lens Flare.
  51221. * This represents one of the lens effect in a `lensFlareSystem`.
  51222. * It controls one of the indiviual texture used in the effect.
  51223. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51224. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  51225. * @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.
  51226. * @param color Define the lens color
  51227. * @param imgUrl Define the lens texture url
  51228. * @param system Define the `lensFlareSystem` this flare is part of
  51229. * @returns The newly created Lens Flare
  51230. */
  51231. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  51232. /**
  51233. * Instantiates a new Lens Flare.
  51234. * This represents one of the lens effect in a `lensFlareSystem`.
  51235. * It controls one of the indiviual texture used in the effect.
  51236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51237. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  51238. * @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.
  51239. * @param color Define the lens color
  51240. * @param imgUrl Define the lens texture url
  51241. * @param system Define the `lensFlareSystem` this flare is part of
  51242. */
  51243. constructor(
  51244. /**
  51245. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  51246. */
  51247. size: number,
  51248. /**
  51249. * 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.
  51250. */
  51251. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  51252. /**
  51253. * Dispose and release the lens flare with its associated resources.
  51254. */
  51255. dispose(): void;
  51256. }
  51257. }
  51258. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  51259. import { Nullable } from "babylonjs/types";
  51260. import { Scene } from "babylonjs/scene";
  51261. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51262. import { AbstractScene } from "babylonjs/abstractScene";
  51263. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  51264. module "babylonjs/abstractScene" {
  51265. interface AbstractScene {
  51266. /**
  51267. * The list of lens flare system added to the scene
  51268. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  51269. */
  51270. lensFlareSystems: Array<LensFlareSystem>;
  51271. /**
  51272. * Removes the given lens flare system from this scene.
  51273. * @param toRemove The lens flare system to remove
  51274. * @returns The index of the removed lens flare system
  51275. */
  51276. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  51277. /**
  51278. * Adds the given lens flare system to this scene
  51279. * @param newLensFlareSystem The lens flare system to add
  51280. */
  51281. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  51282. /**
  51283. * Gets a lens flare system using its name
  51284. * @param name defines the name to look for
  51285. * @returns the lens flare system or null if not found
  51286. */
  51287. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  51288. /**
  51289. * Gets a lens flare system using its id
  51290. * @param id defines the id to look for
  51291. * @returns the lens flare system or null if not found
  51292. */
  51293. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  51294. }
  51295. }
  51296. /**
  51297. * Defines the lens flare scene component responsible to manage any lens flares
  51298. * in a given scene.
  51299. */
  51300. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  51301. /**
  51302. * The component name helpfull to identify the component in the list of scene components.
  51303. */
  51304. readonly name: string;
  51305. /**
  51306. * The scene the component belongs to.
  51307. */
  51308. scene: Scene;
  51309. /**
  51310. * Creates a new instance of the component for the given scene
  51311. * @param scene Defines the scene to register the component in
  51312. */
  51313. constructor(scene: Scene);
  51314. /**
  51315. * Registers the component in a given scene
  51316. */
  51317. register(): void;
  51318. /**
  51319. * Rebuilds the elements related to this component in case of
  51320. * context lost for instance.
  51321. */
  51322. rebuild(): void;
  51323. /**
  51324. * Adds all the elements from the container to the scene
  51325. * @param container the container holding the elements
  51326. */
  51327. addFromContainer(container: AbstractScene): void;
  51328. /**
  51329. * Removes all the elements in the container from the scene
  51330. * @param container contains the elements to remove
  51331. * @param dispose if the removed element should be disposed (default: false)
  51332. */
  51333. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51334. /**
  51335. * Serializes the component data to the specified json object
  51336. * @param serializationObject The object to serialize to
  51337. */
  51338. serialize(serializationObject: any): void;
  51339. /**
  51340. * Disposes the component and the associated ressources.
  51341. */
  51342. dispose(): void;
  51343. private _draw;
  51344. }
  51345. }
  51346. declare module "babylonjs/LensFlares/index" {
  51347. export * from "babylonjs/LensFlares/lensFlare";
  51348. export * from "babylonjs/LensFlares/lensFlareSystem";
  51349. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  51350. }
  51351. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  51352. import { Scene } from "babylonjs/scene";
  51353. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51354. import { AbstractScene } from "babylonjs/abstractScene";
  51355. /**
  51356. * Defines the shadow generator component responsible to manage any shadow generators
  51357. * in a given scene.
  51358. */
  51359. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  51360. /**
  51361. * The component name helpfull to identify the component in the list of scene components.
  51362. */
  51363. readonly name: string;
  51364. /**
  51365. * The scene the component belongs to.
  51366. */
  51367. scene: Scene;
  51368. /**
  51369. * Creates a new instance of the component for the given scene
  51370. * @param scene Defines the scene to register the component in
  51371. */
  51372. constructor(scene: Scene);
  51373. /**
  51374. * Registers the component in a given scene
  51375. */
  51376. register(): void;
  51377. /**
  51378. * Rebuilds the elements related to this component in case of
  51379. * context lost for instance.
  51380. */
  51381. rebuild(): void;
  51382. /**
  51383. * Serializes the component data to the specified json object
  51384. * @param serializationObject The object to serialize to
  51385. */
  51386. serialize(serializationObject: any): void;
  51387. /**
  51388. * Adds all the elements from the container to the scene
  51389. * @param container the container holding the elements
  51390. */
  51391. addFromContainer(container: AbstractScene): void;
  51392. /**
  51393. * Removes all the elements in the container from the scene
  51394. * @param container contains the elements to remove
  51395. * @param dispose if the removed element should be disposed (default: false)
  51396. */
  51397. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51398. /**
  51399. * Rebuilds the elements related to this component in case of
  51400. * context lost for instance.
  51401. */
  51402. dispose(): void;
  51403. private _gatherRenderTargets;
  51404. }
  51405. }
  51406. declare module "babylonjs/Lights/Shadows/index" {
  51407. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  51408. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  51409. }
  51410. declare module "babylonjs/Lights/pointLight" {
  51411. import { Scene } from "babylonjs/scene";
  51412. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51414. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51415. import { Effect } from "babylonjs/Materials/effect";
  51416. /**
  51417. * A point light is a light defined by an unique point in world space.
  51418. * The light is emitted in every direction from this point.
  51419. * A good example of a point light is a standard light bulb.
  51420. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51421. */
  51422. export class PointLight extends ShadowLight {
  51423. private _shadowAngle;
  51424. /**
  51425. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51426. * This specifies what angle the shadow will use to be created.
  51427. *
  51428. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51429. */
  51430. /**
  51431. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51432. * This specifies what angle the shadow will use to be created.
  51433. *
  51434. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  51435. */
  51436. shadowAngle: number;
  51437. /**
  51438. * Gets the direction if it has been set.
  51439. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51440. */
  51441. /**
  51442. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  51443. */
  51444. direction: Vector3;
  51445. /**
  51446. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  51447. * A PointLight emits the light in every direction.
  51448. * It can cast shadows.
  51449. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  51450. * ```javascript
  51451. * var pointLight = new PointLight("pl", camera.position, scene);
  51452. * ```
  51453. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51454. * @param name The light friendly name
  51455. * @param position The position of the point light in the scene
  51456. * @param scene The scene the lights belongs to
  51457. */
  51458. constructor(name: string, position: Vector3, scene: Scene);
  51459. /**
  51460. * Returns the string "PointLight"
  51461. * @returns the class name
  51462. */
  51463. getClassName(): string;
  51464. /**
  51465. * Returns the integer 0.
  51466. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51467. */
  51468. getTypeID(): number;
  51469. /**
  51470. * Specifies wether or not the shadowmap should be a cube texture.
  51471. * @returns true if the shadowmap needs to be a cube texture.
  51472. */
  51473. needCube(): boolean;
  51474. /**
  51475. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  51476. * @param faceIndex The index of the face we are computed the direction to generate shadow
  51477. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  51478. */
  51479. getShadowDirection(faceIndex?: number): Vector3;
  51480. /**
  51481. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  51482. * - fov = PI / 2
  51483. * - aspect ratio : 1.0
  51484. * - z-near and far equal to the active camera minZ and maxZ.
  51485. * Returns the PointLight.
  51486. */
  51487. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51488. protected _buildUniformLayout(): void;
  51489. /**
  51490. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  51491. * @param effect The effect to update
  51492. * @param lightIndex The index of the light in the effect to update
  51493. * @returns The point light
  51494. */
  51495. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  51496. /**
  51497. * Prepares the list of defines specific to the light type.
  51498. * @param defines the list of defines
  51499. * @param lightIndex defines the index of the light for the effect
  51500. */
  51501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51502. }
  51503. }
  51504. declare module "babylonjs/Lights/index" {
  51505. export * from "babylonjs/Lights/light";
  51506. export * from "babylonjs/Lights/shadowLight";
  51507. export * from "babylonjs/Lights/Shadows/index";
  51508. export * from "babylonjs/Lights/directionalLight";
  51509. export * from "babylonjs/Lights/hemisphericLight";
  51510. export * from "babylonjs/Lights/pointLight";
  51511. export * from "babylonjs/Lights/spotLight";
  51512. }
  51513. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  51514. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  51515. /**
  51516. * Header information of HDR texture files.
  51517. */
  51518. export interface HDRInfo {
  51519. /**
  51520. * The height of the texture in pixels.
  51521. */
  51522. height: number;
  51523. /**
  51524. * The width of the texture in pixels.
  51525. */
  51526. width: number;
  51527. /**
  51528. * The index of the beginning of the data in the binary file.
  51529. */
  51530. dataPosition: number;
  51531. }
  51532. /**
  51533. * This groups tools to convert HDR texture to native colors array.
  51534. */
  51535. export class HDRTools {
  51536. private static Ldexp;
  51537. private static Rgbe2float;
  51538. private static readStringLine;
  51539. /**
  51540. * Reads header information from an RGBE texture stored in a native array.
  51541. * More information on this format are available here:
  51542. * https://en.wikipedia.org/wiki/RGBE_image_format
  51543. *
  51544. * @param uint8array The binary file stored in native array.
  51545. * @return The header information.
  51546. */
  51547. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51548. /**
  51549. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51550. * This RGBE texture needs to store the information as a panorama.
  51551. *
  51552. * More information on this format are available here:
  51553. * https://en.wikipedia.org/wiki/RGBE_image_format
  51554. *
  51555. * @param buffer The binary file stored in an array buffer.
  51556. * @param size The expected size of the extracted cubemap.
  51557. * @return The Cube Map information.
  51558. */
  51559. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51560. /**
  51561. * Returns the pixels data extracted from an RGBE texture.
  51562. * This pixels will be stored left to right up to down in the R G B order in one array.
  51563. *
  51564. * More information on this format are available here:
  51565. * https://en.wikipedia.org/wiki/RGBE_image_format
  51566. *
  51567. * @param uint8array The binary file stored in an array buffer.
  51568. * @param hdrInfo The header information of the file.
  51569. * @return The pixels data in RGB right to left up to down order.
  51570. */
  51571. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51572. private static RGBE_ReadPixels_RLE;
  51573. }
  51574. }
  51575. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51576. import { Nullable } from "babylonjs/types";
  51577. import { Scene } from "babylonjs/scene";
  51578. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51580. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51581. /**
  51582. * This represents a texture coming from an HDR input.
  51583. *
  51584. * The only supported format is currently panorama picture stored in RGBE format.
  51585. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51586. */
  51587. export class HDRCubeTexture extends BaseTexture {
  51588. private static _facesMapping;
  51589. private _generateHarmonics;
  51590. private _noMipmap;
  51591. private _textureMatrix;
  51592. private _size;
  51593. private _onLoad;
  51594. private _onError;
  51595. /**
  51596. * The texture URL.
  51597. */
  51598. url: string;
  51599. /**
  51600. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51601. */
  51602. coordinatesMode: number;
  51603. protected _isBlocking: boolean;
  51604. /**
  51605. * Sets wether or not the texture is blocking during loading.
  51606. */
  51607. /**
  51608. * Gets wether or not the texture is blocking during loading.
  51609. */
  51610. isBlocking: boolean;
  51611. protected _rotationY: number;
  51612. /**
  51613. * Sets texture matrix rotation angle around Y axis in radians.
  51614. */
  51615. /**
  51616. * Gets texture matrix rotation angle around Y axis radians.
  51617. */
  51618. rotationY: number;
  51619. /**
  51620. * Gets or sets the center of the bounding box associated with the cube texture
  51621. * It must define where the camera used to render the texture was set
  51622. */
  51623. boundingBoxPosition: Vector3;
  51624. private _boundingBoxSize;
  51625. /**
  51626. * Gets or sets the size of the bounding box associated with the cube texture
  51627. * When defined, the cubemap will switch to local mode
  51628. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51629. * @example https://www.babylonjs-playground.com/#RNASML
  51630. */
  51631. boundingBoxSize: Vector3;
  51632. /**
  51633. * Instantiates an HDRTexture from the following parameters.
  51634. *
  51635. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51636. * @param scene The scene the texture will be used in
  51637. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51638. * @param noMipmap Forces to not generate the mipmap if true
  51639. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51640. * @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)
  51641. * @param reserved Reserved flag for internal use.
  51642. */
  51643. 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>);
  51644. /**
  51645. * Get the current class name of the texture useful for serialization or dynamic coding.
  51646. * @returns "HDRCubeTexture"
  51647. */
  51648. getClassName(): string;
  51649. /**
  51650. * Occurs when the file is raw .hdr file.
  51651. */
  51652. private loadTexture;
  51653. clone(): HDRCubeTexture;
  51654. delayLoad(): void;
  51655. /**
  51656. * Get the texture reflection matrix used to rotate/transform the reflection.
  51657. * @returns the reflection matrix
  51658. */
  51659. getReflectionTextureMatrix(): Matrix;
  51660. /**
  51661. * Set the texture reflection matrix used to rotate/transform the reflection.
  51662. * @param value Define the reflection matrix to set
  51663. */
  51664. setReflectionTextureMatrix(value: Matrix): void;
  51665. /**
  51666. * Parses a JSON representation of an HDR Texture in order to create the texture
  51667. * @param parsedTexture Define the JSON representation
  51668. * @param scene Define the scene the texture should be created in
  51669. * @param rootUrl Define the root url in case we need to load relative dependencies
  51670. * @returns the newly created texture after parsing
  51671. */
  51672. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51673. serialize(): any;
  51674. }
  51675. }
  51676. declare module "babylonjs/Physics/physicsEngine" {
  51677. import { Nullable } from "babylonjs/types";
  51678. import { Vector3 } from "babylonjs/Maths/math.vector";
  51679. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51680. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51681. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51682. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51683. /**
  51684. * Class used to control physics engine
  51685. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51686. */
  51687. export class PhysicsEngine implements IPhysicsEngine {
  51688. private _physicsPlugin;
  51689. /**
  51690. * Global value used to control the smallest number supported by the simulation
  51691. */
  51692. static Epsilon: number;
  51693. private _impostors;
  51694. private _joints;
  51695. /**
  51696. * Gets the gravity vector used by the simulation
  51697. */
  51698. gravity: Vector3;
  51699. /**
  51700. * Factory used to create the default physics plugin.
  51701. * @returns The default physics plugin
  51702. */
  51703. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51704. /**
  51705. * Creates a new Physics Engine
  51706. * @param gravity defines the gravity vector used by the simulation
  51707. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51708. */
  51709. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51710. /**
  51711. * Sets the gravity vector used by the simulation
  51712. * @param gravity defines the gravity vector to use
  51713. */
  51714. setGravity(gravity: Vector3): void;
  51715. /**
  51716. * Set the time step of the physics engine.
  51717. * Default is 1/60.
  51718. * To slow it down, enter 1/600 for example.
  51719. * To speed it up, 1/30
  51720. * @param newTimeStep defines the new timestep to apply to this world.
  51721. */
  51722. setTimeStep(newTimeStep?: number): void;
  51723. /**
  51724. * Get the time step of the physics engine.
  51725. * @returns the current time step
  51726. */
  51727. getTimeStep(): number;
  51728. /**
  51729. * Release all resources
  51730. */
  51731. dispose(): void;
  51732. /**
  51733. * Gets the name of the current physics plugin
  51734. * @returns the name of the plugin
  51735. */
  51736. getPhysicsPluginName(): string;
  51737. /**
  51738. * Adding a new impostor for the impostor tracking.
  51739. * This will be done by the impostor itself.
  51740. * @param impostor the impostor to add
  51741. */
  51742. addImpostor(impostor: PhysicsImpostor): void;
  51743. /**
  51744. * Remove an impostor from the engine.
  51745. * This impostor and its mesh will not longer be updated by the physics engine.
  51746. * @param impostor the impostor to remove
  51747. */
  51748. removeImpostor(impostor: PhysicsImpostor): void;
  51749. /**
  51750. * Add a joint to the physics engine
  51751. * @param mainImpostor defines the main impostor to which the joint is added.
  51752. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51753. * @param joint defines the joint that will connect both impostors.
  51754. */
  51755. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51756. /**
  51757. * Removes a joint from the simulation
  51758. * @param mainImpostor defines the impostor used with the joint
  51759. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51760. * @param joint defines the joint to remove
  51761. */
  51762. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51763. /**
  51764. * Called by the scene. No need to call it.
  51765. * @param delta defines the timespam between frames
  51766. */
  51767. _step(delta: number): void;
  51768. /**
  51769. * Gets the current plugin used to run the simulation
  51770. * @returns current plugin
  51771. */
  51772. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51773. /**
  51774. * Gets the list of physic impostors
  51775. * @returns an array of PhysicsImpostor
  51776. */
  51777. getImpostors(): Array<PhysicsImpostor>;
  51778. /**
  51779. * Gets the impostor for a physics enabled object
  51780. * @param object defines the object impersonated by the impostor
  51781. * @returns the PhysicsImpostor or null if not found
  51782. */
  51783. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51784. /**
  51785. * Gets the impostor for a physics body object
  51786. * @param body defines physics body used by the impostor
  51787. * @returns the PhysicsImpostor or null if not found
  51788. */
  51789. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51790. /**
  51791. * Does a raycast in the physics world
  51792. * @param from when should the ray start?
  51793. * @param to when should the ray end?
  51794. * @returns PhysicsRaycastResult
  51795. */
  51796. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51797. }
  51798. }
  51799. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51800. import { Nullable } from "babylonjs/types";
  51801. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51803. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51804. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51805. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51806. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51807. /** @hidden */
  51808. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51809. private _useDeltaForWorldStep;
  51810. world: any;
  51811. name: string;
  51812. private _physicsMaterials;
  51813. private _fixedTimeStep;
  51814. private _cannonRaycastResult;
  51815. private _raycastResult;
  51816. private _physicsBodysToRemoveAfterStep;
  51817. BJSCANNON: any;
  51818. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51819. setGravity(gravity: Vector3): void;
  51820. setTimeStep(timeStep: number): void;
  51821. getTimeStep(): number;
  51822. executeStep(delta: number): void;
  51823. private _removeMarkedPhysicsBodiesFromWorld;
  51824. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51825. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51826. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51827. private _processChildMeshes;
  51828. removePhysicsBody(impostor: PhysicsImpostor): void;
  51829. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51830. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51831. private _addMaterial;
  51832. private _checkWithEpsilon;
  51833. private _createShape;
  51834. private _createHeightmap;
  51835. private _minus90X;
  51836. private _plus90X;
  51837. private _tmpPosition;
  51838. private _tmpDeltaPosition;
  51839. private _tmpUnityRotation;
  51840. private _updatePhysicsBodyTransformation;
  51841. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51842. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51843. isSupported(): boolean;
  51844. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51845. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51846. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51847. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51848. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51849. getBodyMass(impostor: PhysicsImpostor): number;
  51850. getBodyFriction(impostor: PhysicsImpostor): number;
  51851. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51852. getBodyRestitution(impostor: PhysicsImpostor): number;
  51853. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51854. sleepBody(impostor: PhysicsImpostor): void;
  51855. wakeUpBody(impostor: PhysicsImpostor): void;
  51856. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51857. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51858. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51859. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51860. getRadius(impostor: PhysicsImpostor): number;
  51861. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51862. dispose(): void;
  51863. private _extendNamespace;
  51864. /**
  51865. * Does a raycast in the physics world
  51866. * @param from when should the ray start?
  51867. * @param to when should the ray end?
  51868. * @returns PhysicsRaycastResult
  51869. */
  51870. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51871. }
  51872. }
  51873. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51874. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51875. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51876. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51878. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  51879. import { Nullable } from "babylonjs/types";
  51880. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51881. /** @hidden */
  51882. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51883. world: any;
  51884. name: string;
  51885. BJSOIMO: any;
  51886. private _raycastResult;
  51887. constructor(iterations?: number, oimoInjection?: any);
  51888. setGravity(gravity: Vector3): void;
  51889. setTimeStep(timeStep: number): void;
  51890. getTimeStep(): number;
  51891. private _tmpImpostorsArray;
  51892. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51893. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51894. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51895. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51896. private _tmpPositionVector;
  51897. removePhysicsBody(impostor: PhysicsImpostor): void;
  51898. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51899. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51900. isSupported(): boolean;
  51901. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51902. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51903. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51904. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51905. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51906. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51907. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51908. getBodyMass(impostor: PhysicsImpostor): number;
  51909. getBodyFriction(impostor: PhysicsImpostor): number;
  51910. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51911. getBodyRestitution(impostor: PhysicsImpostor): number;
  51912. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51913. sleepBody(impostor: PhysicsImpostor): void;
  51914. wakeUpBody(impostor: PhysicsImpostor): void;
  51915. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51916. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51917. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51918. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51919. getRadius(impostor: PhysicsImpostor): number;
  51920. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51921. dispose(): void;
  51922. /**
  51923. * Does a raycast in the physics world
  51924. * @param from when should the ray start?
  51925. * @param to when should the ray end?
  51926. * @returns PhysicsRaycastResult
  51927. */
  51928. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51929. }
  51930. }
  51931. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51932. import { Nullable } from "babylonjs/types";
  51933. import { Scene } from "babylonjs/scene";
  51934. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  51935. import { Color4 } from "babylonjs/Maths/math.color";
  51936. import { Mesh } from "babylonjs/Meshes/mesh";
  51937. /**
  51938. * Class containing static functions to help procedurally build meshes
  51939. */
  51940. export class RibbonBuilder {
  51941. /**
  51942. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51943. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51944. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51945. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51946. * * 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
  51947. * * 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
  51948. * * 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
  51949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51952. * * 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
  51953. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51954. * * 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
  51955. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51957. * @param name defines the name of the mesh
  51958. * @param options defines the options used to create the mesh
  51959. * @param scene defines the hosting scene
  51960. * @returns the ribbon mesh
  51961. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51963. */
  51964. static CreateRibbon(name: string, options: {
  51965. pathArray: Vector3[][];
  51966. closeArray?: boolean;
  51967. closePath?: boolean;
  51968. offset?: number;
  51969. updatable?: boolean;
  51970. sideOrientation?: number;
  51971. frontUVs?: Vector4;
  51972. backUVs?: Vector4;
  51973. instance?: Mesh;
  51974. invertUV?: boolean;
  51975. uvs?: Vector2[];
  51976. colors?: Color4[];
  51977. }, scene?: Nullable<Scene>): Mesh;
  51978. }
  51979. }
  51980. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51981. import { Nullable } from "babylonjs/types";
  51982. import { Scene } from "babylonjs/scene";
  51983. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  51984. import { Mesh } from "babylonjs/Meshes/mesh";
  51985. /**
  51986. * Class containing static functions to help procedurally build meshes
  51987. */
  51988. export class ShapeBuilder {
  51989. /**
  51990. * 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.
  51991. * * 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.
  51992. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51993. * * 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.
  51994. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51995. * * 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
  51996. * * 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
  51997. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51999. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52002. * @param name defines the name of the mesh
  52003. * @param options defines the options used to create the mesh
  52004. * @param scene defines the hosting scene
  52005. * @returns the extruded shape mesh
  52006. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52008. */
  52009. static ExtrudeShape(name: string, options: {
  52010. shape: Vector3[];
  52011. path: Vector3[];
  52012. scale?: number;
  52013. rotation?: number;
  52014. cap?: number;
  52015. updatable?: boolean;
  52016. sideOrientation?: number;
  52017. frontUVs?: Vector4;
  52018. backUVs?: Vector4;
  52019. instance?: Mesh;
  52020. invertUV?: boolean;
  52021. }, scene?: Nullable<Scene>): Mesh;
  52022. /**
  52023. * Creates an custom extruded shape mesh.
  52024. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52025. * * 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.
  52026. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52027. * * 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
  52028. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52029. * * 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
  52030. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52031. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52032. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52033. * * 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
  52034. * * 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
  52035. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52040. * @param name defines the name of the mesh
  52041. * @param options defines the options used to create the mesh
  52042. * @param scene defines the hosting scene
  52043. * @returns the custom extruded shape mesh
  52044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52045. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52046. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52047. */
  52048. static ExtrudeShapeCustom(name: string, options: {
  52049. shape: Vector3[];
  52050. path: Vector3[];
  52051. scaleFunction?: any;
  52052. rotationFunction?: any;
  52053. ribbonCloseArray?: boolean;
  52054. ribbonClosePath?: boolean;
  52055. cap?: number;
  52056. updatable?: boolean;
  52057. sideOrientation?: number;
  52058. frontUVs?: Vector4;
  52059. backUVs?: Vector4;
  52060. instance?: Mesh;
  52061. invertUV?: boolean;
  52062. }, scene?: Nullable<Scene>): Mesh;
  52063. private static _ExtrudeShapeGeneric;
  52064. }
  52065. }
  52066. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  52067. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  52068. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  52069. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52070. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  52071. import { Nullable } from "babylonjs/types";
  52072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52073. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  52074. /**
  52075. * AmmoJS Physics plugin
  52076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  52077. * @see https://github.com/kripken/ammo.js/
  52078. */
  52079. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  52080. private _useDeltaForWorldStep;
  52081. /**
  52082. * Reference to the Ammo library
  52083. */
  52084. bjsAMMO: any;
  52085. /**
  52086. * Created ammoJS world which physics bodies are added to
  52087. */
  52088. world: any;
  52089. /**
  52090. * Name of the plugin
  52091. */
  52092. name: string;
  52093. private _timeStep;
  52094. private _fixedTimeStep;
  52095. private _maxSteps;
  52096. private _tmpQuaternion;
  52097. private _tmpAmmoTransform;
  52098. private _tmpAmmoQuaternion;
  52099. private _tmpAmmoConcreteContactResultCallback;
  52100. private _collisionConfiguration;
  52101. private _dispatcher;
  52102. private _overlappingPairCache;
  52103. private _solver;
  52104. private _softBodySolver;
  52105. private _tmpAmmoVectorA;
  52106. private _tmpAmmoVectorB;
  52107. private _tmpAmmoVectorC;
  52108. private _tmpAmmoVectorD;
  52109. private _tmpContactCallbackResult;
  52110. private _tmpAmmoVectorRCA;
  52111. private _tmpAmmoVectorRCB;
  52112. private _raycastResult;
  52113. private static readonly DISABLE_COLLISION_FLAG;
  52114. private static readonly KINEMATIC_FLAG;
  52115. private static readonly DISABLE_DEACTIVATION_FLAG;
  52116. /**
  52117. * Initializes the ammoJS plugin
  52118. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  52119. * @param ammoInjection can be used to inject your own ammo reference
  52120. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  52121. */
  52122. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  52123. /**
  52124. * Sets the gravity of the physics world (m/(s^2))
  52125. * @param gravity Gravity to set
  52126. */
  52127. setGravity(gravity: Vector3): void;
  52128. /**
  52129. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  52130. * @param timeStep timestep to use in seconds
  52131. */
  52132. setTimeStep(timeStep: number): void;
  52133. /**
  52134. * 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)
  52135. * @param fixedTimeStep fixedTimeStep to use in seconds
  52136. */
  52137. setFixedTimeStep(fixedTimeStep: number): void;
  52138. /**
  52139. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  52140. * @param maxSteps the maximum number of steps by the physics engine per frame
  52141. */
  52142. setMaxSteps(maxSteps: number): void;
  52143. /**
  52144. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  52145. * @returns the current timestep in seconds
  52146. */
  52147. getTimeStep(): number;
  52148. private _isImpostorInContact;
  52149. private _isImpostorPairInContact;
  52150. private _stepSimulation;
  52151. /**
  52152. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  52153. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  52154. * After the step the babylon meshes are set to the position of the physics imposters
  52155. * @param delta amount of time to step forward
  52156. * @param impostors array of imposters to update before/after the step
  52157. */
  52158. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  52159. /**
  52160. * Update babylon mesh to match physics world object
  52161. * @param impostor imposter to match
  52162. */
  52163. private _afterSoftStep;
  52164. /**
  52165. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52166. * @param impostor imposter to match
  52167. */
  52168. private _ropeStep;
  52169. /**
  52170. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  52171. * @param impostor imposter to match
  52172. */
  52173. private _softbodyOrClothStep;
  52174. private _tmpVector;
  52175. private _tmpMatrix;
  52176. /**
  52177. * Applies an impulse on the imposter
  52178. * @param impostor imposter to apply impulse to
  52179. * @param force amount of force to be applied to the imposter
  52180. * @param contactPoint the location to apply the impulse on the imposter
  52181. */
  52182. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52183. /**
  52184. * Applies a force on the imposter
  52185. * @param impostor imposter to apply force
  52186. * @param force amount of force to be applied to the imposter
  52187. * @param contactPoint the location to apply the force on the imposter
  52188. */
  52189. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  52190. /**
  52191. * Creates a physics body using the plugin
  52192. * @param impostor the imposter to create the physics body on
  52193. */
  52194. generatePhysicsBody(impostor: PhysicsImpostor): void;
  52195. /**
  52196. * Removes the physics body from the imposter and disposes of the body's memory
  52197. * @param impostor imposter to remove the physics body from
  52198. */
  52199. removePhysicsBody(impostor: PhysicsImpostor): void;
  52200. /**
  52201. * Generates a joint
  52202. * @param impostorJoint the imposter joint to create the joint with
  52203. */
  52204. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  52205. /**
  52206. * Removes a joint
  52207. * @param impostorJoint the imposter joint to remove the joint from
  52208. */
  52209. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  52210. private _addMeshVerts;
  52211. /**
  52212. * Initialise the soft body vertices to match its object's (mesh) vertices
  52213. * Softbody vertices (nodes) are in world space and to match this
  52214. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  52215. * @param impostor to create the softbody for
  52216. */
  52217. private _softVertexData;
  52218. /**
  52219. * Create an impostor's soft body
  52220. * @param impostor to create the softbody for
  52221. */
  52222. private _createSoftbody;
  52223. /**
  52224. * Create cloth for an impostor
  52225. * @param impostor to create the softbody for
  52226. */
  52227. private _createCloth;
  52228. /**
  52229. * Create rope for an impostor
  52230. * @param impostor to create the softbody for
  52231. */
  52232. private _createRope;
  52233. private _addHullVerts;
  52234. private _createShape;
  52235. /**
  52236. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  52237. * @param impostor imposter containing the physics body and babylon object
  52238. */
  52239. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  52240. /**
  52241. * Sets the babylon object's position/rotation from the physics body's position/rotation
  52242. * @param impostor imposter containing the physics body and babylon object
  52243. * @param newPosition new position
  52244. * @param newRotation new rotation
  52245. */
  52246. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  52247. /**
  52248. * If this plugin is supported
  52249. * @returns true if its supported
  52250. */
  52251. isSupported(): boolean;
  52252. /**
  52253. * Sets the linear velocity of the physics body
  52254. * @param impostor imposter to set the velocity on
  52255. * @param velocity velocity to set
  52256. */
  52257. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52258. /**
  52259. * Sets the angular velocity of the physics body
  52260. * @param impostor imposter to set the velocity on
  52261. * @param velocity velocity to set
  52262. */
  52263. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  52264. /**
  52265. * gets the linear velocity
  52266. * @param impostor imposter to get linear velocity from
  52267. * @returns linear velocity
  52268. */
  52269. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52270. /**
  52271. * gets the angular velocity
  52272. * @param impostor imposter to get angular velocity from
  52273. * @returns angular velocity
  52274. */
  52275. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  52276. /**
  52277. * Sets the mass of physics body
  52278. * @param impostor imposter to set the mass on
  52279. * @param mass mass to set
  52280. */
  52281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  52282. /**
  52283. * Gets the mass of the physics body
  52284. * @param impostor imposter to get the mass from
  52285. * @returns mass
  52286. */
  52287. getBodyMass(impostor: PhysicsImpostor): number;
  52288. /**
  52289. * Gets friction of the impostor
  52290. * @param impostor impostor to get friction from
  52291. * @returns friction value
  52292. */
  52293. getBodyFriction(impostor: PhysicsImpostor): number;
  52294. /**
  52295. * Sets friction of the impostor
  52296. * @param impostor impostor to set friction on
  52297. * @param friction friction value
  52298. */
  52299. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  52300. /**
  52301. * Gets restitution of the impostor
  52302. * @param impostor impostor to get restitution from
  52303. * @returns restitution value
  52304. */
  52305. getBodyRestitution(impostor: PhysicsImpostor): number;
  52306. /**
  52307. * Sets resitution of the impostor
  52308. * @param impostor impostor to set resitution on
  52309. * @param restitution resitution value
  52310. */
  52311. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  52312. /**
  52313. * Gets pressure inside the impostor
  52314. * @param impostor impostor to get pressure from
  52315. * @returns pressure value
  52316. */
  52317. getBodyPressure(impostor: PhysicsImpostor): number;
  52318. /**
  52319. * Sets pressure inside a soft body impostor
  52320. * Cloth and rope must remain 0 pressure
  52321. * @param impostor impostor to set pressure on
  52322. * @param pressure pressure value
  52323. */
  52324. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  52325. /**
  52326. * Gets stiffness of the impostor
  52327. * @param impostor impostor to get stiffness from
  52328. * @returns pressure value
  52329. */
  52330. getBodyStiffness(impostor: PhysicsImpostor): number;
  52331. /**
  52332. * Sets stiffness of the impostor
  52333. * @param impostor impostor to set stiffness on
  52334. * @param stiffness stiffness value from 0 to 1
  52335. */
  52336. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  52337. /**
  52338. * Gets velocityIterations of the impostor
  52339. * @param impostor impostor to get velocity iterations from
  52340. * @returns velocityIterations value
  52341. */
  52342. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  52343. /**
  52344. * Sets velocityIterations of the impostor
  52345. * @param impostor impostor to set velocity iterations on
  52346. * @param velocityIterations velocityIterations value
  52347. */
  52348. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  52349. /**
  52350. * Gets positionIterations of the impostor
  52351. * @param impostor impostor to get position iterations from
  52352. * @returns positionIterations value
  52353. */
  52354. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  52355. /**
  52356. * Sets positionIterations of the impostor
  52357. * @param impostor impostor to set position on
  52358. * @param positionIterations positionIterations value
  52359. */
  52360. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  52361. /**
  52362. * Append an anchor to a cloth object
  52363. * @param impostor is the cloth impostor to add anchor to
  52364. * @param otherImpostor is the rigid impostor to anchor to
  52365. * @param width ratio across width from 0 to 1
  52366. * @param height ratio up height from 0 to 1
  52367. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  52368. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52369. */
  52370. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52371. /**
  52372. * Append an hook to a rope object
  52373. * @param impostor is the rope impostor to add hook to
  52374. * @param otherImpostor is the rigid impostor to hook to
  52375. * @param length ratio along the rope from 0 to 1
  52376. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  52377. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  52378. */
  52379. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  52380. /**
  52381. * Sleeps the physics body and stops it from being active
  52382. * @param impostor impostor to sleep
  52383. */
  52384. sleepBody(impostor: PhysicsImpostor): void;
  52385. /**
  52386. * Activates the physics body
  52387. * @param impostor impostor to activate
  52388. */
  52389. wakeUpBody(impostor: PhysicsImpostor): void;
  52390. /**
  52391. * Updates the distance parameters of the joint
  52392. * @param joint joint to update
  52393. * @param maxDistance maximum distance of the joint
  52394. * @param minDistance minimum distance of the joint
  52395. */
  52396. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  52397. /**
  52398. * Sets a motor on the joint
  52399. * @param joint joint to set motor on
  52400. * @param speed speed of the motor
  52401. * @param maxForce maximum force of the motor
  52402. * @param motorIndex index of the motor
  52403. */
  52404. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  52405. /**
  52406. * Sets the motors limit
  52407. * @param joint joint to set limit on
  52408. * @param upperLimit upper limit
  52409. * @param lowerLimit lower limit
  52410. */
  52411. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  52412. /**
  52413. * Syncs the position and rotation of a mesh with the impostor
  52414. * @param mesh mesh to sync
  52415. * @param impostor impostor to update the mesh with
  52416. */
  52417. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  52418. /**
  52419. * Gets the radius of the impostor
  52420. * @param impostor impostor to get radius from
  52421. * @returns the radius
  52422. */
  52423. getRadius(impostor: PhysicsImpostor): number;
  52424. /**
  52425. * Gets the box size of the impostor
  52426. * @param impostor impostor to get box size from
  52427. * @param result the resulting box size
  52428. */
  52429. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  52430. /**
  52431. * Disposes of the impostor
  52432. */
  52433. dispose(): void;
  52434. /**
  52435. * Does a raycast in the physics world
  52436. * @param from when should the ray start?
  52437. * @param to when should the ray end?
  52438. * @returns PhysicsRaycastResult
  52439. */
  52440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  52441. }
  52442. }
  52443. declare module "babylonjs/Probes/reflectionProbe" {
  52444. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52445. import { Vector3 } from "babylonjs/Maths/math.vector";
  52446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52447. import { Nullable } from "babylonjs/types";
  52448. import { Scene } from "babylonjs/scene";
  52449. module "babylonjs/abstractScene" {
  52450. interface AbstractScene {
  52451. /**
  52452. * The list of reflection probes added to the scene
  52453. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52454. */
  52455. reflectionProbes: Array<ReflectionProbe>;
  52456. /**
  52457. * Removes the given reflection probe from this scene.
  52458. * @param toRemove The reflection probe to remove
  52459. * @returns The index of the removed reflection probe
  52460. */
  52461. removeReflectionProbe(toRemove: ReflectionProbe): number;
  52462. /**
  52463. * Adds the given reflection probe to this scene.
  52464. * @param newReflectionProbe The reflection probe to add
  52465. */
  52466. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  52467. }
  52468. }
  52469. /**
  52470. * Class used to generate realtime reflection / refraction cube textures
  52471. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  52472. */
  52473. export class ReflectionProbe {
  52474. /** defines the name of the probe */
  52475. name: string;
  52476. private _scene;
  52477. private _renderTargetTexture;
  52478. private _projectionMatrix;
  52479. private _viewMatrix;
  52480. private _target;
  52481. private _add;
  52482. private _attachedMesh;
  52483. private _invertYAxis;
  52484. /** Gets or sets probe position (center of the cube map) */
  52485. position: Vector3;
  52486. /**
  52487. * Creates a new reflection probe
  52488. * @param name defines the name of the probe
  52489. * @param size defines the texture resolution (for each face)
  52490. * @param scene defines the hosting scene
  52491. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  52492. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  52493. */
  52494. constructor(
  52495. /** defines the name of the probe */
  52496. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  52497. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  52498. samples: number;
  52499. /** Gets or sets the refresh rate to use (on every frame by default) */
  52500. refreshRate: number;
  52501. /**
  52502. * Gets the hosting scene
  52503. * @returns a Scene
  52504. */
  52505. getScene(): Scene;
  52506. /** Gets the internal CubeTexture used to render to */
  52507. readonly cubeTexture: RenderTargetTexture;
  52508. /** Gets the list of meshes to render */
  52509. readonly renderList: Nullable<AbstractMesh[]>;
  52510. /**
  52511. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  52512. * @param mesh defines the mesh to attach to
  52513. */
  52514. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  52515. /**
  52516. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  52517. * @param renderingGroupId The rendering group id corresponding to its index
  52518. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  52519. */
  52520. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  52521. /**
  52522. * Clean all associated resources
  52523. */
  52524. dispose(): void;
  52525. /**
  52526. * Converts the reflection probe information to a readable string for debug purpose.
  52527. * @param fullDetails Supports for multiple levels of logging within scene loading
  52528. * @returns the human readable reflection probe info
  52529. */
  52530. toString(fullDetails?: boolean): string;
  52531. /**
  52532. * Get the class name of the relfection probe.
  52533. * @returns "ReflectionProbe"
  52534. */
  52535. getClassName(): string;
  52536. /**
  52537. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  52538. * @returns The JSON representation of the texture
  52539. */
  52540. serialize(): any;
  52541. /**
  52542. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  52543. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  52544. * @param scene Define the scene the parsed reflection probe should be instantiated in
  52545. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  52546. * @returns The parsed reflection probe if successful
  52547. */
  52548. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52549. }
  52550. }
  52551. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52552. /** @hidden */
  52553. export var _BabylonLoaderRegistered: boolean;
  52554. }
  52555. declare module "babylonjs/Loading/Plugins/index" {
  52556. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52557. }
  52558. declare module "babylonjs/Loading/index" {
  52559. export * from "babylonjs/Loading/loadingScreen";
  52560. export * from "babylonjs/Loading/Plugins/index";
  52561. export * from "babylonjs/Loading/sceneLoader";
  52562. export * from "babylonjs/Loading/sceneLoaderFlags";
  52563. }
  52564. declare module "babylonjs/Materials/Background/index" {
  52565. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52566. }
  52567. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52568. import { Scene } from "babylonjs/scene";
  52569. import { Color3 } from "babylonjs/Maths/math.color";
  52570. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52571. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52572. /**
  52573. * The Physically based simple base material of BJS.
  52574. *
  52575. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52576. * It is used as the base class for both the specGloss and metalRough conventions.
  52577. */
  52578. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52579. /**
  52580. * Number of Simultaneous lights allowed on the material.
  52581. */
  52582. maxSimultaneousLights: number;
  52583. /**
  52584. * If sets to true, disables all the lights affecting the material.
  52585. */
  52586. disableLighting: boolean;
  52587. /**
  52588. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52589. */
  52590. environmentTexture: BaseTexture;
  52591. /**
  52592. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52593. */
  52594. invertNormalMapX: boolean;
  52595. /**
  52596. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52597. */
  52598. invertNormalMapY: boolean;
  52599. /**
  52600. * Normal map used in the model.
  52601. */
  52602. normalTexture: BaseTexture;
  52603. /**
  52604. * Emissivie color used to self-illuminate the model.
  52605. */
  52606. emissiveColor: Color3;
  52607. /**
  52608. * Emissivie texture used to self-illuminate the model.
  52609. */
  52610. emissiveTexture: BaseTexture;
  52611. /**
  52612. * Occlusion Channel Strenght.
  52613. */
  52614. occlusionStrength: number;
  52615. /**
  52616. * Occlusion Texture of the material (adding extra occlusion effects).
  52617. */
  52618. occlusionTexture: BaseTexture;
  52619. /**
  52620. * Defines the alpha limits in alpha test mode.
  52621. */
  52622. alphaCutOff: number;
  52623. /**
  52624. * Gets the current double sided mode.
  52625. */
  52626. /**
  52627. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52628. */
  52629. doubleSided: boolean;
  52630. /**
  52631. * Stores the pre-calculated light information of a mesh in a texture.
  52632. */
  52633. lightmapTexture: BaseTexture;
  52634. /**
  52635. * If true, the light map contains occlusion information instead of lighting info.
  52636. */
  52637. useLightmapAsShadowmap: boolean;
  52638. /**
  52639. * Instantiates a new PBRMaterial instance.
  52640. *
  52641. * @param name The material name
  52642. * @param scene The scene the material will be use in.
  52643. */
  52644. constructor(name: string, scene: Scene);
  52645. getClassName(): string;
  52646. }
  52647. }
  52648. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52649. import { Scene } from "babylonjs/scene";
  52650. import { Color3 } from "babylonjs/Maths/math.color";
  52651. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52652. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52653. /**
  52654. * The PBR material of BJS following the metal roughness convention.
  52655. *
  52656. * This fits to the PBR convention in the GLTF definition:
  52657. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52658. */
  52659. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52660. /**
  52661. * The base color has two different interpretations depending on the value of metalness.
  52662. * When the material is a metal, the base color is the specific measured reflectance value
  52663. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52664. * of the material.
  52665. */
  52666. baseColor: Color3;
  52667. /**
  52668. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52669. * well as opacity information in the alpha channel.
  52670. */
  52671. baseTexture: BaseTexture;
  52672. /**
  52673. * Specifies the metallic scalar value of the material.
  52674. * Can also be used to scale the metalness values of the metallic texture.
  52675. */
  52676. metallic: number;
  52677. /**
  52678. * Specifies the roughness scalar value of the material.
  52679. * Can also be used to scale the roughness values of the metallic texture.
  52680. */
  52681. roughness: number;
  52682. /**
  52683. * Texture containing both the metallic value in the B channel and the
  52684. * roughness value in the G channel to keep better precision.
  52685. */
  52686. metallicRoughnessTexture: BaseTexture;
  52687. /**
  52688. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52689. *
  52690. * @param name The material name
  52691. * @param scene The scene the material will be use in.
  52692. */
  52693. constructor(name: string, scene: Scene);
  52694. /**
  52695. * Return the currrent class name of the material.
  52696. */
  52697. getClassName(): string;
  52698. /**
  52699. * Makes a duplicate of the current material.
  52700. * @param name - name to use for the new material.
  52701. */
  52702. clone(name: string): PBRMetallicRoughnessMaterial;
  52703. /**
  52704. * Serialize the material to a parsable JSON object.
  52705. */
  52706. serialize(): any;
  52707. /**
  52708. * Parses a JSON object correponding to the serialize function.
  52709. */
  52710. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52711. }
  52712. }
  52713. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52714. import { Scene } from "babylonjs/scene";
  52715. import { Color3 } from "babylonjs/Maths/math.color";
  52716. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52717. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52718. /**
  52719. * The PBR material of BJS following the specular glossiness convention.
  52720. *
  52721. * This fits to the PBR convention in the GLTF definition:
  52722. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52723. */
  52724. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52725. /**
  52726. * Specifies the diffuse color of the material.
  52727. */
  52728. diffuseColor: Color3;
  52729. /**
  52730. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52731. * channel.
  52732. */
  52733. diffuseTexture: BaseTexture;
  52734. /**
  52735. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52736. */
  52737. specularColor: Color3;
  52738. /**
  52739. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52740. */
  52741. glossiness: number;
  52742. /**
  52743. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52744. */
  52745. specularGlossinessTexture: BaseTexture;
  52746. /**
  52747. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52748. *
  52749. * @param name The material name
  52750. * @param scene The scene the material will be use in.
  52751. */
  52752. constructor(name: string, scene: Scene);
  52753. /**
  52754. * Return the currrent class name of the material.
  52755. */
  52756. getClassName(): string;
  52757. /**
  52758. * Makes a duplicate of the current material.
  52759. * @param name - name to use for the new material.
  52760. */
  52761. clone(name: string): PBRSpecularGlossinessMaterial;
  52762. /**
  52763. * Serialize the material to a parsable JSON object.
  52764. */
  52765. serialize(): any;
  52766. /**
  52767. * Parses a JSON object correponding to the serialize function.
  52768. */
  52769. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52770. }
  52771. }
  52772. declare module "babylonjs/Materials/PBR/index" {
  52773. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52774. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52775. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52776. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52777. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52778. }
  52779. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52780. import { Nullable } from "babylonjs/types";
  52781. import { Scene } from "babylonjs/scene";
  52782. import { Matrix } from "babylonjs/Maths/math.vector";
  52783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52784. /**
  52785. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52786. * It can help converting any input color in a desired output one. This can then be used to create effects
  52787. * from sepia, black and white to sixties or futuristic rendering...
  52788. *
  52789. * The only supported format is currently 3dl.
  52790. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52791. */
  52792. export class ColorGradingTexture extends BaseTexture {
  52793. /**
  52794. * The current texture matrix. (will always be identity in color grading texture)
  52795. */
  52796. private _textureMatrix;
  52797. /**
  52798. * The texture URL.
  52799. */
  52800. url: string;
  52801. /**
  52802. * Empty line regex stored for GC.
  52803. */
  52804. private static _noneEmptyLineRegex;
  52805. private _engine;
  52806. /**
  52807. * Instantiates a ColorGradingTexture from the following parameters.
  52808. *
  52809. * @param url The location of the color gradind data (currently only supporting 3dl)
  52810. * @param scene The scene the texture will be used in
  52811. */
  52812. constructor(url: string, scene: Scene);
  52813. /**
  52814. * Returns the texture matrix used in most of the material.
  52815. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52816. */
  52817. getTextureMatrix(): Matrix;
  52818. /**
  52819. * Occurs when the file being loaded is a .3dl LUT file.
  52820. */
  52821. private load3dlTexture;
  52822. /**
  52823. * Starts the loading process of the texture.
  52824. */
  52825. private loadTexture;
  52826. /**
  52827. * Clones the color gradind texture.
  52828. */
  52829. clone(): ColorGradingTexture;
  52830. /**
  52831. * Called during delayed load for textures.
  52832. */
  52833. delayLoad(): void;
  52834. /**
  52835. * Parses a color grading texture serialized by Babylon.
  52836. * @param parsedTexture The texture information being parsedTexture
  52837. * @param scene The scene to load the texture in
  52838. * @param rootUrl The root url of the data assets to load
  52839. * @return A color gradind texture
  52840. */
  52841. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52842. /**
  52843. * Serializes the LUT texture to json format.
  52844. */
  52845. serialize(): any;
  52846. }
  52847. }
  52848. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52850. import { Scene } from "babylonjs/scene";
  52851. import { Nullable } from "babylonjs/types";
  52852. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52853. /**
  52854. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52855. */
  52856. export class EquiRectangularCubeTexture extends BaseTexture {
  52857. /** The six faces of the cube. */
  52858. private static _FacesMapping;
  52859. private _noMipmap;
  52860. private _onLoad;
  52861. private _onError;
  52862. /** The size of the cubemap. */
  52863. private _size;
  52864. /** The buffer of the image. */
  52865. private _buffer;
  52866. /** The width of the input image. */
  52867. private _width;
  52868. /** The height of the input image. */
  52869. private _height;
  52870. /** The URL to the image. */
  52871. url: string;
  52872. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52873. coordinatesMode: number;
  52874. /**
  52875. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52876. * @param url The location of the image
  52877. * @param scene The scene the texture will be used in
  52878. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52879. * @param noMipmap Forces to not generate the mipmap if true
  52880. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52881. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52882. * @param onLoad — defines a callback called when texture is loaded
  52883. * @param onError — defines a callback called if there is an error
  52884. */
  52885. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52886. /**
  52887. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52888. */
  52889. private loadImage;
  52890. /**
  52891. * Convert the image buffer into a cubemap and create a CubeTexture.
  52892. */
  52893. private loadTexture;
  52894. /**
  52895. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52896. * @param buffer The ArrayBuffer that should be converted.
  52897. * @returns The buffer as Float32Array.
  52898. */
  52899. private getFloat32ArrayFromArrayBuffer;
  52900. /**
  52901. * Get the current class name of the texture useful for serialization or dynamic coding.
  52902. * @returns "EquiRectangularCubeTexture"
  52903. */
  52904. getClassName(): string;
  52905. /**
  52906. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52907. * @returns A clone of the current EquiRectangularCubeTexture.
  52908. */
  52909. clone(): EquiRectangularCubeTexture;
  52910. }
  52911. }
  52912. declare module "babylonjs/Misc/tga" {
  52913. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52914. /**
  52915. * Based on jsTGALoader - Javascript loader for TGA file
  52916. * By Vincent Thibault
  52917. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52918. */
  52919. export class TGATools {
  52920. private static _TYPE_INDEXED;
  52921. private static _TYPE_RGB;
  52922. private static _TYPE_GREY;
  52923. private static _TYPE_RLE_INDEXED;
  52924. private static _TYPE_RLE_RGB;
  52925. private static _TYPE_RLE_GREY;
  52926. private static _ORIGIN_MASK;
  52927. private static _ORIGIN_SHIFT;
  52928. private static _ORIGIN_BL;
  52929. private static _ORIGIN_BR;
  52930. private static _ORIGIN_UL;
  52931. private static _ORIGIN_UR;
  52932. /**
  52933. * Gets the header of a TGA file
  52934. * @param data defines the TGA data
  52935. * @returns the header
  52936. */
  52937. static GetTGAHeader(data: Uint8Array): any;
  52938. /**
  52939. * Uploads TGA content to a Babylon Texture
  52940. * @hidden
  52941. */
  52942. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52943. /** @hidden */
  52944. 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;
  52945. /** @hidden */
  52946. 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;
  52947. /** @hidden */
  52948. 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;
  52949. /** @hidden */
  52950. 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;
  52951. /** @hidden */
  52952. 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;
  52953. /** @hidden */
  52954. 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;
  52955. }
  52956. }
  52957. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52958. import { Nullable } from "babylonjs/types";
  52959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52960. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52961. /**
  52962. * Implementation of the TGA Texture Loader.
  52963. * @hidden
  52964. */
  52965. export class _TGATextureLoader implements IInternalTextureLoader {
  52966. /**
  52967. * Defines wether the loader supports cascade loading the different faces.
  52968. */
  52969. readonly supportCascades: boolean;
  52970. /**
  52971. * This returns if the loader support the current file information.
  52972. * @param extension defines the file extension of the file being loaded
  52973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52974. * @param fallback defines the fallback internal texture if any
  52975. * @param isBase64 defines whether the texture is encoded as a base64
  52976. * @param isBuffer defines whether the texture data are stored as a buffer
  52977. * @returns true if the loader can load the specified file
  52978. */
  52979. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52980. /**
  52981. * Transform the url before loading if required.
  52982. * @param rootUrl the url of the texture
  52983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52984. * @returns the transformed texture
  52985. */
  52986. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52987. /**
  52988. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52989. * @param rootUrl the url of the texture
  52990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52991. * @returns the fallback texture
  52992. */
  52993. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52994. /**
  52995. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52996. * @param data contains the texture data
  52997. * @param texture defines the BabylonJS internal texture
  52998. * @param createPolynomials will be true if polynomials have been requested
  52999. * @param onLoad defines the callback to trigger once the texture is ready
  53000. * @param onError defines the callback to trigger in case of error
  53001. */
  53002. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53003. /**
  53004. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53005. * @param data contains the texture data
  53006. * @param texture defines the BabylonJS internal texture
  53007. * @param callback defines the method to call once ready to upload
  53008. */
  53009. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53010. }
  53011. }
  53012. declare module "babylonjs/Misc/basis" {
  53013. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53014. /**
  53015. * Info about the .basis files
  53016. */
  53017. class BasisFileInfo {
  53018. /**
  53019. * If the file has alpha
  53020. */
  53021. hasAlpha: boolean;
  53022. /**
  53023. * Info about each image of the basis file
  53024. */
  53025. images: Array<{
  53026. levels: Array<{
  53027. width: number;
  53028. height: number;
  53029. transcodedPixels: ArrayBufferView;
  53030. }>;
  53031. }>;
  53032. }
  53033. /**
  53034. * Result of transcoding a basis file
  53035. */
  53036. class TranscodeResult {
  53037. /**
  53038. * Info about the .basis file
  53039. */
  53040. fileInfo: BasisFileInfo;
  53041. /**
  53042. * Format to use when loading the file
  53043. */
  53044. format: number;
  53045. }
  53046. /**
  53047. * Configuration options for the Basis transcoder
  53048. */
  53049. export class BasisTranscodeConfiguration {
  53050. /**
  53051. * Supported compression formats used to determine the supported output format of the transcoder
  53052. */
  53053. supportedCompressionFormats?: {
  53054. /**
  53055. * etc1 compression format
  53056. */
  53057. etc1?: boolean;
  53058. /**
  53059. * s3tc compression format
  53060. */
  53061. s3tc?: boolean;
  53062. /**
  53063. * pvrtc compression format
  53064. */
  53065. pvrtc?: boolean;
  53066. /**
  53067. * etc2 compression format
  53068. */
  53069. etc2?: boolean;
  53070. };
  53071. /**
  53072. * If mipmap levels should be loaded for transcoded images (Default: true)
  53073. */
  53074. loadMipmapLevels?: boolean;
  53075. /**
  53076. * Index of a single image to load (Default: all images)
  53077. */
  53078. loadSingleImage?: number;
  53079. }
  53080. /**
  53081. * Used to load .Basis files
  53082. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  53083. */
  53084. export class BasisTools {
  53085. private static _IgnoreSupportedFormats;
  53086. /**
  53087. * URL to use when loading the basis transcoder
  53088. */
  53089. static JSModuleURL: string;
  53090. /**
  53091. * URL to use when loading the wasm module for the transcoder
  53092. */
  53093. static WasmModuleURL: string;
  53094. /**
  53095. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  53096. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  53097. * @returns internal format corresponding to the Basis format
  53098. */
  53099. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  53100. private static _WorkerPromise;
  53101. private static _Worker;
  53102. private static _actionId;
  53103. private static _CreateWorkerAsync;
  53104. /**
  53105. * Transcodes a loaded image file to compressed pixel data
  53106. * @param imageData image data to transcode
  53107. * @param config configuration options for the transcoding
  53108. * @returns a promise resulting in the transcoded image
  53109. */
  53110. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  53111. /**
  53112. * Loads a texture from the transcode result
  53113. * @param texture texture load to
  53114. * @param transcodeResult the result of transcoding the basis file to load from
  53115. */
  53116. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  53117. }
  53118. }
  53119. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  53120. import { Nullable } from "babylonjs/types";
  53121. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53122. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  53123. /**
  53124. * Loader for .basis file format
  53125. */
  53126. export class _BasisTextureLoader implements IInternalTextureLoader {
  53127. /**
  53128. * Defines whether the loader supports cascade loading the different faces.
  53129. */
  53130. readonly supportCascades: boolean;
  53131. /**
  53132. * This returns if the loader support the current file information.
  53133. * @param extension defines the file extension of the file being loaded
  53134. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53135. * @param fallback defines the fallback internal texture if any
  53136. * @param isBase64 defines whether the texture is encoded as a base64
  53137. * @param isBuffer defines whether the texture data are stored as a buffer
  53138. * @returns true if the loader can load the specified file
  53139. */
  53140. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  53141. /**
  53142. * Transform the url before loading if required.
  53143. * @param rootUrl the url of the texture
  53144. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53145. * @returns the transformed texture
  53146. */
  53147. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  53148. /**
  53149. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53150. * @param rootUrl the url of the texture
  53151. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53152. * @returns the fallback texture
  53153. */
  53154. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  53155. /**
  53156. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  53157. * @param data contains the texture data
  53158. * @param texture defines the BabylonJS internal texture
  53159. * @param createPolynomials will be true if polynomials have been requested
  53160. * @param onLoad defines the callback to trigger once the texture is ready
  53161. * @param onError defines the callback to trigger in case of error
  53162. */
  53163. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  53164. /**
  53165. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53166. * @param data contains the texture data
  53167. * @param texture defines the BabylonJS internal texture
  53168. * @param callback defines the method to call once ready to upload
  53169. */
  53170. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  53171. }
  53172. }
  53173. declare module "babylonjs/Materials/Textures/Loaders/index" {
  53174. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  53175. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  53176. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  53177. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  53178. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  53179. }
  53180. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  53181. import { Scene } from "babylonjs/scene";
  53182. import { Texture } from "babylonjs/Materials/Textures/texture";
  53183. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53184. /**
  53185. * 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.
  53186. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53187. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53188. */
  53189. export class CustomProceduralTexture extends ProceduralTexture {
  53190. private _animate;
  53191. private _time;
  53192. private _config;
  53193. private _texturePath;
  53194. /**
  53195. * Instantiates a new Custom Procedural Texture.
  53196. * 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.
  53197. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  53198. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  53199. * @param name Define the name of the texture
  53200. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  53201. * @param size Define the size of the texture to create
  53202. * @param scene Define the scene the texture belongs to
  53203. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  53204. * @param generateMipMaps Define if the texture should creates mip maps or not
  53205. */
  53206. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53207. private _loadJson;
  53208. /**
  53209. * Is the texture ready to be used ? (rendered at least once)
  53210. * @returns true if ready, otherwise, false.
  53211. */
  53212. isReady(): boolean;
  53213. /**
  53214. * Render the texture to its associated render target.
  53215. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  53216. */
  53217. render(useCameraPostProcess?: boolean): void;
  53218. /**
  53219. * Update the list of dependant textures samplers in the shader.
  53220. */
  53221. updateTextures(): void;
  53222. /**
  53223. * Update the uniform values of the procedural texture in the shader.
  53224. */
  53225. updateShaderUniforms(): void;
  53226. /**
  53227. * Define if the texture animates or not.
  53228. */
  53229. animate: boolean;
  53230. }
  53231. }
  53232. declare module "babylonjs/Shaders/noise.fragment" {
  53233. /** @hidden */
  53234. export var noisePixelShader: {
  53235. name: string;
  53236. shader: string;
  53237. };
  53238. }
  53239. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  53240. import { Nullable } from "babylonjs/types";
  53241. import { Scene } from "babylonjs/scene";
  53242. import { Texture } from "babylonjs/Materials/Textures/texture";
  53243. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53244. import "babylonjs/Shaders/noise.fragment";
  53245. /**
  53246. * Class used to generate noise procedural textures
  53247. */
  53248. export class NoiseProceduralTexture extends ProceduralTexture {
  53249. private _time;
  53250. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  53251. brightness: number;
  53252. /** Defines the number of octaves to process */
  53253. octaves: number;
  53254. /** Defines the level of persistence (0.8 by default) */
  53255. persistence: number;
  53256. /** Gets or sets animation speed factor (default is 1) */
  53257. animationSpeedFactor: number;
  53258. /**
  53259. * Creates a new NoiseProceduralTexture
  53260. * @param name defines the name fo the texture
  53261. * @param size defines the size of the texture (default is 256)
  53262. * @param scene defines the hosting scene
  53263. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  53264. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  53265. */
  53266. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  53267. private _updateShaderUniforms;
  53268. protected _getDefines(): string;
  53269. /** Generate the current state of the procedural texture */
  53270. render(useCameraPostProcess?: boolean): void;
  53271. /**
  53272. * Serializes this noise procedural texture
  53273. * @returns a serialized noise procedural texture object
  53274. */
  53275. serialize(): any;
  53276. /**
  53277. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  53278. * @param parsedTexture defines parsed texture data
  53279. * @param scene defines the current scene
  53280. * @param rootUrl defines the root URL containing noise procedural texture information
  53281. * @returns a parsed NoiseProceduralTexture
  53282. */
  53283. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  53284. }
  53285. }
  53286. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  53287. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  53288. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  53289. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  53290. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  53291. }
  53292. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  53293. import { Nullable } from "babylonjs/types";
  53294. import { Scene } from "babylonjs/scene";
  53295. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53296. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53297. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  53298. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53299. /**
  53300. * Raw cube texture where the raw buffers are passed in
  53301. */
  53302. export class RawCubeTexture extends CubeTexture {
  53303. /**
  53304. * Creates a cube texture where the raw buffers are passed in.
  53305. * @param scene defines the scene the texture is attached to
  53306. * @param data defines the array of data to use to create each face
  53307. * @param size defines the size of the textures
  53308. * @param format defines the format of the data
  53309. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  53310. * @param generateMipMaps defines if the engine should generate the mip levels
  53311. * @param invertY defines if data must be stored with Y axis inverted
  53312. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  53313. * @param compression defines the compression used (null by default)
  53314. */
  53315. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  53316. /**
  53317. * Updates the raw cube texture.
  53318. * @param data defines the data to store
  53319. * @param format defines the data format
  53320. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53321. * @param invertY defines if data must be stored with Y axis inverted
  53322. * @param compression defines the compression used (null by default)
  53323. * @param level defines which level of the texture to update
  53324. */
  53325. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  53326. /**
  53327. * Updates a raw cube texture with RGBD encoded data.
  53328. * @param data defines the array of data [mipmap][face] to use to create each face
  53329. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  53330. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53331. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53332. * @returns a promsie that resolves when the operation is complete
  53333. */
  53334. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  53335. /**
  53336. * Clones the raw cube texture.
  53337. * @return a new cube texture
  53338. */
  53339. clone(): CubeTexture;
  53340. /** @hidden */
  53341. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53342. }
  53343. }
  53344. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  53345. import { Scene } from "babylonjs/scene";
  53346. import { Texture } from "babylonjs/Materials/Textures/texture";
  53347. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53348. /**
  53349. * Class used to store 3D textures containing user data
  53350. */
  53351. export class RawTexture3D extends Texture {
  53352. /** Gets or sets the texture format to use */
  53353. format: number;
  53354. private _engine;
  53355. /**
  53356. * Create a new RawTexture3D
  53357. * @param data defines the data of the texture
  53358. * @param width defines the width of the texture
  53359. * @param height defines the height of the texture
  53360. * @param depth defines the depth of the texture
  53361. * @param format defines the texture format to use
  53362. * @param scene defines the hosting scene
  53363. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  53364. * @param invertY defines if texture must be stored with Y axis inverted
  53365. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  53366. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  53367. */
  53368. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  53369. /** Gets or sets the texture format to use */
  53370. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  53371. /**
  53372. * Update the texture with new data
  53373. * @param data defines the data to store in the texture
  53374. */
  53375. update(data: ArrayBufferView): void;
  53376. }
  53377. }
  53378. declare module "babylonjs/Materials/Textures/refractionTexture" {
  53379. import { Scene } from "babylonjs/scene";
  53380. import { Plane } from "babylonjs/Maths/math.plane";
  53381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53382. /**
  53383. * Creates a refraction texture used by refraction channel of the standard material.
  53384. * It is like a mirror but to see through a material.
  53385. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53386. */
  53387. export class RefractionTexture extends RenderTargetTexture {
  53388. /**
  53389. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  53390. * 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.
  53391. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53392. */
  53393. refractionPlane: Plane;
  53394. /**
  53395. * Define how deep under the surface we should see.
  53396. */
  53397. depth: number;
  53398. /**
  53399. * Creates a refraction texture used by refraction channel of the standard material.
  53400. * It is like a mirror but to see through a material.
  53401. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  53402. * @param name Define the texture name
  53403. * @param size Define the size of the underlying texture
  53404. * @param scene Define the scene the refraction belongs to
  53405. * @param generateMipMaps Define if we need to generate mips level for the refraction
  53406. */
  53407. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  53408. /**
  53409. * Clone the refraction texture.
  53410. * @returns the cloned texture
  53411. */
  53412. clone(): RefractionTexture;
  53413. /**
  53414. * Serialize the texture to a JSON representation you could use in Parse later on
  53415. * @returns the serialized JSON representation
  53416. */
  53417. serialize(): any;
  53418. }
  53419. }
  53420. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  53421. import { Nullable } from "babylonjs/types";
  53422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53423. import { Matrix } from "babylonjs/Maths/math.vector";
  53424. import { Engine } from "babylonjs/Engines/engine";
  53425. import { Scene } from "babylonjs/scene";
  53426. /**
  53427. * Defines the options related to the creation of an HtmlElementTexture
  53428. */
  53429. export interface IHtmlElementTextureOptions {
  53430. /**
  53431. * Defines wether mip maps should be created or not.
  53432. */
  53433. generateMipMaps?: boolean;
  53434. /**
  53435. * Defines the sampling mode of the texture.
  53436. */
  53437. samplingMode?: number;
  53438. /**
  53439. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  53440. */
  53441. engine: Nullable<Engine>;
  53442. /**
  53443. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  53444. */
  53445. scene: Nullable<Scene>;
  53446. }
  53447. /**
  53448. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  53449. * To be as efficient as possible depending on your constraints nothing aside the first upload
  53450. * is automatically managed.
  53451. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  53452. * in your application.
  53453. *
  53454. * As the update is not automatic, you need to call them manually.
  53455. */
  53456. export class HtmlElementTexture extends BaseTexture {
  53457. /**
  53458. * The texture URL.
  53459. */
  53460. element: HTMLVideoElement | HTMLCanvasElement;
  53461. private static readonly DefaultOptions;
  53462. private _textureMatrix;
  53463. private _engine;
  53464. private _isVideo;
  53465. private _generateMipMaps;
  53466. private _samplingMode;
  53467. /**
  53468. * Instantiates a HtmlElementTexture from the following parameters.
  53469. *
  53470. * @param name Defines the name of the texture
  53471. * @param element Defines the video or canvas the texture is filled with
  53472. * @param options Defines the other none mandatory texture creation options
  53473. */
  53474. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  53475. private _createInternalTexture;
  53476. /**
  53477. * Returns the texture matrix used in most of the material.
  53478. */
  53479. getTextureMatrix(): Matrix;
  53480. /**
  53481. * Updates the content of the texture.
  53482. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  53483. */
  53484. update(invertY?: Nullable<boolean>): void;
  53485. }
  53486. }
  53487. declare module "babylonjs/Materials/Textures/index" {
  53488. export * from "babylonjs/Materials/Textures/baseTexture";
  53489. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  53490. export * from "babylonjs/Materials/Textures/cubeTexture";
  53491. export * from "babylonjs/Materials/Textures/dynamicTexture";
  53492. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  53493. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  53494. export * from "babylonjs/Materials/Textures/internalTexture";
  53495. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  53496. export * from "babylonjs/Materials/Textures/Loaders/index";
  53497. export * from "babylonjs/Materials/Textures/mirrorTexture";
  53498. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  53499. export * from "babylonjs/Materials/Textures/Procedurals/index";
  53500. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  53501. export * from "babylonjs/Materials/Textures/rawTexture";
  53502. export * from "babylonjs/Materials/Textures/rawTexture3D";
  53503. export * from "babylonjs/Materials/Textures/refractionTexture";
  53504. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  53505. export * from "babylonjs/Materials/Textures/texture";
  53506. export * from "babylonjs/Materials/Textures/videoTexture";
  53507. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  53508. }
  53509. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  53510. /**
  53511. * Enum used to define the target of a block
  53512. */
  53513. export enum NodeMaterialBlockTargets {
  53514. /** Vertex shader */
  53515. Vertex = 1,
  53516. /** Fragment shader */
  53517. Fragment = 2,
  53518. /** Neutral */
  53519. Neutral = 4,
  53520. /** Vertex and Fragment */
  53521. VertexAndFragment = 3
  53522. }
  53523. }
  53524. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  53525. /**
  53526. * Defines the kind of connection point for node based material
  53527. */
  53528. export enum NodeMaterialBlockConnectionPointTypes {
  53529. /** Float */
  53530. Float = 1,
  53531. /** Int */
  53532. Int = 2,
  53533. /** Vector2 */
  53534. Vector2 = 4,
  53535. /** Vector3 */
  53536. Vector3 = 8,
  53537. /** Vector4 */
  53538. Vector4 = 16,
  53539. /** Color3 */
  53540. Color3 = 32,
  53541. /** Color4 */
  53542. Color4 = 64,
  53543. /** Matrix */
  53544. Matrix = 128,
  53545. /** Vector3 or Color3 */
  53546. Vector3OrColor3 = 40,
  53547. /** Vector3 or Vector4 */
  53548. Vector3OrVector4 = 24,
  53549. /** Vector4 or Color4 */
  53550. Vector4OrColor4 = 80,
  53551. /** Color3 or Color4 */
  53552. Color3OrColor4 = 96,
  53553. /** Vector2 or Color3 or Color4 */
  53554. Vector2OrColor3OrColor4 = 100,
  53555. /** Vector3 or Color3 or Color4 or Vector4 */
  53556. Vector3OrColor3OrVector4OrColor4 = 120,
  53557. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  53558. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  53559. /** Detect type based on connection */
  53560. AutoDetect = 1024,
  53561. /** Output type that will be defined by input type */
  53562. BasedOnInput = 2048
  53563. }
  53564. }
  53565. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53567. /**
  53568. * Root class for all node material optimizers
  53569. */
  53570. export class NodeMaterialOptimizer {
  53571. /**
  53572. * Function used to optimize a NodeMaterial graph
  53573. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53574. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53575. */
  53576. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53577. }
  53578. }
  53579. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  53580. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53581. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53582. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53583. /**
  53584. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  53585. */
  53586. export class TransformBlock extends NodeMaterialBlock {
  53587. /**
  53588. * Defines the value to use to complement W value to transform it to a Vector4
  53589. */
  53590. complementW: number;
  53591. /**
  53592. * Defines the value to use to complement z value to transform it to a Vector4
  53593. */
  53594. complementZ: number;
  53595. /**
  53596. * Creates a new TransformBlock
  53597. * @param name defines the block name
  53598. */
  53599. constructor(name: string);
  53600. /**
  53601. * Gets the current class name
  53602. * @returns the class name
  53603. */
  53604. getClassName(): string;
  53605. /**
  53606. * Gets the vector input
  53607. */
  53608. readonly vector: NodeMaterialConnectionPoint;
  53609. /**
  53610. * Gets the output component
  53611. */
  53612. readonly output: NodeMaterialConnectionPoint;
  53613. /**
  53614. * Gets the matrix transform input
  53615. */
  53616. readonly transform: NodeMaterialConnectionPoint;
  53617. protected _buildBlock(state: NodeMaterialBuildState): this;
  53618. }
  53619. }
  53620. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53621. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53622. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53623. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53624. /**
  53625. * Block used to output the vertex position
  53626. */
  53627. export class VertexOutputBlock extends NodeMaterialBlock {
  53628. /**
  53629. * Creates a new VertexOutputBlock
  53630. * @param name defines the block name
  53631. */
  53632. constructor(name: string);
  53633. /**
  53634. * Gets the current class name
  53635. * @returns the class name
  53636. */
  53637. getClassName(): string;
  53638. /**
  53639. * Gets the vector input component
  53640. */
  53641. readonly vector: NodeMaterialConnectionPoint;
  53642. protected _buildBlock(state: NodeMaterialBuildState): this;
  53643. }
  53644. }
  53645. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53646. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53647. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53648. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53649. /**
  53650. * Block used to output the final color
  53651. */
  53652. export class FragmentOutputBlock extends NodeMaterialBlock {
  53653. /**
  53654. * Gets or sets a boolean indicating if this block will output an alpha value
  53655. */
  53656. alphaBlendingEnabled: boolean;
  53657. /**
  53658. * Create a new FragmentOutputBlock
  53659. * @param name defines the block name
  53660. */
  53661. constructor(name: string);
  53662. /**
  53663. * Gets the current class name
  53664. * @returns the class name
  53665. */
  53666. getClassName(): string;
  53667. /**
  53668. * Gets the rgba input component
  53669. */
  53670. readonly rgba: NodeMaterialConnectionPoint;
  53671. /**
  53672. * Gets the rgb input component
  53673. */
  53674. readonly rgb: NodeMaterialConnectionPoint;
  53675. /**
  53676. * Gets the a input component
  53677. */
  53678. readonly a: NodeMaterialConnectionPoint;
  53679. protected _buildBlock(state: NodeMaterialBuildState): this;
  53680. }
  53681. }
  53682. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53683. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53684. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53685. import { Scene } from "babylonjs/scene";
  53686. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53687. import { Matrix } from "babylonjs/Maths/math.vector";
  53688. import { Mesh } from "babylonjs/Meshes/mesh";
  53689. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53690. import { Observable } from "babylonjs/Misc/observable";
  53691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53692. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53693. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53694. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53695. import { Nullable } from "babylonjs/types";
  53696. /**
  53697. * Interface used to configure the node material editor
  53698. */
  53699. export interface INodeMaterialEditorOptions {
  53700. /** Define the URl to load node editor script */
  53701. editorURL?: string;
  53702. }
  53703. /** @hidden */
  53704. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53705. /** BONES */
  53706. NUM_BONE_INFLUENCERS: number;
  53707. BonesPerMesh: number;
  53708. BONETEXTURE: boolean;
  53709. /** MORPH TARGETS */
  53710. MORPHTARGETS: boolean;
  53711. MORPHTARGETS_NORMAL: boolean;
  53712. MORPHTARGETS_TANGENT: boolean;
  53713. MORPHTARGETS_UV: boolean;
  53714. NUM_MORPH_INFLUENCERS: number;
  53715. /** IMAGE PROCESSING */
  53716. IMAGEPROCESSING: boolean;
  53717. VIGNETTE: boolean;
  53718. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53719. VIGNETTEBLENDMODEOPAQUE: boolean;
  53720. TONEMAPPING: boolean;
  53721. TONEMAPPING_ACES: boolean;
  53722. CONTRAST: boolean;
  53723. EXPOSURE: boolean;
  53724. COLORCURVES: boolean;
  53725. COLORGRADING: boolean;
  53726. COLORGRADING3D: boolean;
  53727. SAMPLER3DGREENDEPTH: boolean;
  53728. SAMPLER3DBGRMAP: boolean;
  53729. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53730. constructor();
  53731. setValue(name: string, value: boolean): void;
  53732. }
  53733. /**
  53734. * Class used to configure NodeMaterial
  53735. */
  53736. export interface INodeMaterialOptions {
  53737. /**
  53738. * Defines if blocks should emit comments
  53739. */
  53740. emitComments: boolean;
  53741. }
  53742. /**
  53743. * Class used to create a node based material built by assembling shader blocks
  53744. */
  53745. export class NodeMaterial extends PushMaterial {
  53746. private _options;
  53747. private _vertexCompilationState;
  53748. private _fragmentCompilationState;
  53749. private _sharedData;
  53750. private _buildId;
  53751. private _buildWasSuccessful;
  53752. private _cachedWorldViewMatrix;
  53753. private _cachedWorldViewProjectionMatrix;
  53754. private _optimizers;
  53755. /** Define the URl to load node editor script */
  53756. static EditorURL: string;
  53757. private BJSNODEMATERIALEDITOR;
  53758. /** Get the inspector from bundle or global */
  53759. private _getGlobalNodeMaterialEditor;
  53760. /**
  53761. * Defines the maximum number of lights that can be used in the material
  53762. */
  53763. maxSimultaneousLights: number;
  53764. /**
  53765. * Observable raised when the material is built
  53766. */
  53767. onBuildObservable: Observable<NodeMaterial>;
  53768. /**
  53769. * Gets or sets the root nodes of the material vertex shader
  53770. */
  53771. _vertexOutputNodes: NodeMaterialBlock[];
  53772. /**
  53773. * Gets or sets the root nodes of the material fragment (pixel) shader
  53774. */
  53775. _fragmentOutputNodes: NodeMaterialBlock[];
  53776. /** Gets or sets options to control the node material overall behavior */
  53777. options: INodeMaterialOptions;
  53778. /**
  53779. * Default configuration related to image processing available in the standard Material.
  53780. */
  53781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53782. /**
  53783. * Gets the image processing configuration used either in this material.
  53784. */
  53785. /**
  53786. * Sets the Default image processing configuration used either in the this material.
  53787. *
  53788. * If sets to null, the scene one is in use.
  53789. */
  53790. imageProcessingConfiguration: ImageProcessingConfiguration;
  53791. /**
  53792. * Create a new node based material
  53793. * @param name defines the material name
  53794. * @param scene defines the hosting scene
  53795. * @param options defines creation option
  53796. */
  53797. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53798. /**
  53799. * Gets the current class name of the material e.g. "NodeMaterial"
  53800. * @returns the class name
  53801. */
  53802. getClassName(): string;
  53803. /**
  53804. * Keep track of the image processing observer to allow dispose and replace.
  53805. */
  53806. private _imageProcessingObserver;
  53807. /**
  53808. * Attaches a new image processing configuration to the Standard Material.
  53809. * @param configuration
  53810. */
  53811. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53812. /**
  53813. * Adds a new optimizer to the list of optimizers
  53814. * @param optimizer defines the optimizers to add
  53815. * @returns the current material
  53816. */
  53817. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53818. /**
  53819. * Remove an optimizer from the list of optimizers
  53820. * @param optimizer defines the optimizers to remove
  53821. * @returns the current material
  53822. */
  53823. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53824. /**
  53825. * Add a new block to the list of output nodes
  53826. * @param node defines the node to add
  53827. * @returns the current material
  53828. */
  53829. addOutputNode(node: NodeMaterialBlock): this;
  53830. /**
  53831. * Remove a block from the list of root nodes
  53832. * @param node defines the node to remove
  53833. * @returns the current material
  53834. */
  53835. removeOutputNode(node: NodeMaterialBlock): this;
  53836. private _addVertexOutputNode;
  53837. private _removeVertexOutputNode;
  53838. private _addFragmentOutputNode;
  53839. private _removeFragmentOutputNode;
  53840. /**
  53841. * Specifies if the material will require alpha blending
  53842. * @returns a boolean specifying if alpha blending is needed
  53843. */
  53844. needAlphaBlending(): boolean;
  53845. /**
  53846. * Specifies if this material should be rendered in alpha test mode
  53847. * @returns a boolean specifying if an alpha test is needed.
  53848. */
  53849. needAlphaTesting(): boolean;
  53850. private _initializeBlock;
  53851. private _resetDualBlocks;
  53852. /**
  53853. * Build the material and generates the inner effect
  53854. * @param verbose defines if the build should log activity
  53855. */
  53856. build(verbose?: boolean): void;
  53857. /**
  53858. * Runs an otpimization phase to try to improve the shader code
  53859. */
  53860. optimize(): void;
  53861. private _prepareDefinesForAttributes;
  53862. /**
  53863. * Get if the submesh is ready to be used and all its information available.
  53864. * Child classes can use it to update shaders
  53865. * @param mesh defines the mesh to check
  53866. * @param subMesh defines which submesh to check
  53867. * @param useInstances specifies that instances should be used
  53868. * @returns a boolean indicating that the submesh is ready or not
  53869. */
  53870. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53871. /**
  53872. * Get a string representing the shaders built by the current node graph
  53873. */
  53874. readonly compiledShaders: string;
  53875. /**
  53876. * Binds the world matrix to the material
  53877. * @param world defines the world transformation matrix
  53878. */
  53879. bindOnlyWorldMatrix(world: Matrix): void;
  53880. /**
  53881. * Binds the submesh to this material by preparing the effect and shader to draw
  53882. * @param world defines the world transformation matrix
  53883. * @param mesh defines the mesh containing the submesh
  53884. * @param subMesh defines the submesh to bind the material to
  53885. */
  53886. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53887. /**
  53888. * Gets the active textures from the material
  53889. * @returns an array of textures
  53890. */
  53891. getActiveTextures(): BaseTexture[];
  53892. /**
  53893. * Specifies if the material uses a texture
  53894. * @param texture defines the texture to check against the material
  53895. * @returns a boolean specifying if the material uses the texture
  53896. */
  53897. hasTexture(texture: BaseTexture): boolean;
  53898. /**
  53899. * Disposes the material
  53900. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53901. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53902. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53903. */
  53904. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53905. /** Creates the node editor window. */
  53906. private _createNodeEditor;
  53907. /**
  53908. * Launch the node material editor
  53909. * @param config Define the configuration of the editor
  53910. * @return a promise fulfilled when the node editor is visible
  53911. */
  53912. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53913. /**
  53914. * Clear the current material
  53915. */
  53916. clear(): void;
  53917. /**
  53918. * Clear the current material and set it to a default state
  53919. */
  53920. setToDefault(): void;
  53921. private _gatherBlocks;
  53922. /**
  53923. * Serializes this material in a JSON representation
  53924. * @returns the serialized material object
  53925. */
  53926. serialize(): any;
  53927. /**
  53928. * Clear the current graph and load a new one from a serialization object
  53929. * @param source defines the JSON representation of the material
  53930. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53931. */
  53932. loadFromSerialization(source: any, rootUrl?: string): void;
  53933. /**
  53934. * Creates a node material from parsed material data
  53935. * @param source defines the JSON representation of the material
  53936. * @param scene defines the hosting scene
  53937. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  53938. * @returns a new node material
  53939. */
  53940. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  53941. }
  53942. }
  53943. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  53944. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53945. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53946. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53947. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53949. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53950. import { Effect } from "babylonjs/Materials/effect";
  53951. import { Mesh } from "babylonjs/Meshes/mesh";
  53952. import { Nullable } from "babylonjs/types";
  53953. import { Scene } from "babylonjs/scene";
  53954. /**
  53955. * Block used to read a texture from a sampler
  53956. */
  53957. export class TextureBlock extends NodeMaterialBlock {
  53958. private _defineName;
  53959. private _samplerName;
  53960. private _transformedUVName;
  53961. private _textureTransformName;
  53962. private _textureInfoName;
  53963. private _mainUVName;
  53964. private _mainUVDefineName;
  53965. /**
  53966. * Gets or sets the texture associated with the node
  53967. */
  53968. texture: Nullable<BaseTexture>;
  53969. /**
  53970. * Create a new TextureBlock
  53971. * @param name defines the block name
  53972. */
  53973. constructor(name: string);
  53974. /**
  53975. * Gets the current class name
  53976. * @returns the class name
  53977. */
  53978. getClassName(): string;
  53979. /**
  53980. * Gets the uv input component
  53981. */
  53982. readonly uv: NodeMaterialConnectionPoint;
  53983. /**
  53984. * Gets the output component
  53985. */
  53986. readonly output: NodeMaterialConnectionPoint;
  53987. autoConfigure(): void;
  53988. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53989. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53990. isReady(): boolean;
  53991. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53992. private _injectVertexCode;
  53993. private _writeOutput;
  53994. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  53995. serialize(): any;
  53996. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  53997. }
  53998. }
  53999. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  54000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54002. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54003. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  54004. /**
  54005. * Class used to store shared data between 2 NodeMaterialBuildState
  54006. */
  54007. export class NodeMaterialBuildStateSharedData {
  54008. /**
  54009. * Gets the list of emitted varyings
  54010. */
  54011. varyings: string[];
  54012. /**
  54013. * Gets the varying declaration string
  54014. */
  54015. varyingDeclaration: string;
  54016. /**
  54017. * Input blocks
  54018. */
  54019. inputBlocks: InputBlock[];
  54020. /**
  54021. * Input blocks
  54022. */
  54023. textureBlocks: TextureBlock[];
  54024. /**
  54025. * Bindable blocks (Blocks that need to set data to the effect)
  54026. */
  54027. bindableBlocks: NodeMaterialBlock[];
  54028. /**
  54029. * List of blocks that can provide a compilation fallback
  54030. */
  54031. blocksWithFallbacks: NodeMaterialBlock[];
  54032. /**
  54033. * List of blocks that can provide a define update
  54034. */
  54035. blocksWithDefines: NodeMaterialBlock[];
  54036. /**
  54037. * List of blocks that can provide a repeatable content
  54038. */
  54039. repeatableContentBlocks: NodeMaterialBlock[];
  54040. /**
  54041. * List of blocks that can provide a dynamic list of uniforms
  54042. */
  54043. dynamicUniformBlocks: NodeMaterialBlock[];
  54044. /**
  54045. * List of blocks that can block the isReady function for the material
  54046. */
  54047. blockingBlocks: NodeMaterialBlock[];
  54048. /**
  54049. * Build Id used to avoid multiple recompilations
  54050. */
  54051. buildId: number;
  54052. /** List of emitted variables */
  54053. variableNames: {
  54054. [key: string]: number;
  54055. };
  54056. /** List of emitted defines */
  54057. defineNames: {
  54058. [key: string]: number;
  54059. };
  54060. /** Should emit comments? */
  54061. emitComments: boolean;
  54062. /** Emit build activity */
  54063. verbose: boolean;
  54064. /**
  54065. * Gets the compilation hints emitted at compilation time
  54066. */
  54067. hints: {
  54068. needWorldViewMatrix: boolean;
  54069. needWorldViewProjectionMatrix: boolean;
  54070. needAlphaBlending: boolean;
  54071. needAlphaTesting: boolean;
  54072. };
  54073. /**
  54074. * List of compilation checks
  54075. */
  54076. checks: {
  54077. emitVertex: boolean;
  54078. emitFragment: boolean;
  54079. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  54080. };
  54081. /** Creates a new shared data */
  54082. constructor();
  54083. /**
  54084. * Emits console errors and exceptions if there is a failing check
  54085. */
  54086. emitErrors(): void;
  54087. }
  54088. }
  54089. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  54090. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54091. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54092. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  54093. /**
  54094. * Class used to store node based material build state
  54095. */
  54096. export class NodeMaterialBuildState {
  54097. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  54098. supportUniformBuffers: boolean;
  54099. /**
  54100. * Gets the list of emitted attributes
  54101. */
  54102. attributes: string[];
  54103. /**
  54104. * Gets the list of emitted uniforms
  54105. */
  54106. uniforms: string[];
  54107. /**
  54108. * Gets the list of emitted uniform buffers
  54109. */
  54110. uniformBuffers: string[];
  54111. /**
  54112. * Gets the list of emitted samplers
  54113. */
  54114. samplers: string[];
  54115. /**
  54116. * Gets the list of emitted functions
  54117. */
  54118. functions: {
  54119. [key: string]: string;
  54120. };
  54121. /**
  54122. * Gets the target of the compilation state
  54123. */
  54124. target: NodeMaterialBlockTargets;
  54125. /**
  54126. * Gets the list of emitted counters
  54127. */
  54128. counters: {
  54129. [key: string]: number;
  54130. };
  54131. /**
  54132. * Shared data between multiple NodeMaterialBuildState instances
  54133. */
  54134. sharedData: NodeMaterialBuildStateSharedData;
  54135. /** @hidden */
  54136. _vertexState: NodeMaterialBuildState;
  54137. /** @hidden */
  54138. _attributeDeclaration: string;
  54139. /** @hidden */
  54140. _uniformDeclaration: string;
  54141. /** @hidden */
  54142. _samplerDeclaration: string;
  54143. /** @hidden */
  54144. _varyingTransfer: string;
  54145. private _repeatableContentAnchorIndex;
  54146. /** @hidden */
  54147. _builtCompilationString: string;
  54148. /**
  54149. * Gets the emitted compilation strings
  54150. */
  54151. compilationString: string;
  54152. /**
  54153. * Finalize the compilation strings
  54154. * @param state defines the current compilation state
  54155. */
  54156. finalize(state: NodeMaterialBuildState): void;
  54157. /** @hidden */
  54158. readonly _repeatableContentAnchor: string;
  54159. /** @hidden */
  54160. _getFreeVariableName(prefix: string): string;
  54161. /** @hidden */
  54162. _getFreeDefineName(prefix: string): string;
  54163. /** @hidden */
  54164. _excludeVariableName(name: string): void;
  54165. /** @hidden */
  54166. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  54167. /** @hidden */
  54168. _emitFunction(name: string, code: string, comments: string): void;
  54169. /** @hidden */
  54170. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  54171. replaceStrings?: {
  54172. search: RegExp;
  54173. replace: string;
  54174. }[];
  54175. repeatKey?: string;
  54176. }): string;
  54177. /** @hidden */
  54178. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  54179. repeatKey?: string;
  54180. removeAttributes?: boolean;
  54181. removeUniforms?: boolean;
  54182. removeVaryings?: boolean;
  54183. removeIfDef?: boolean;
  54184. replaceStrings?: {
  54185. search: RegExp;
  54186. replace: string;
  54187. }[];
  54188. }, storeKey?: string): void;
  54189. /** @hidden */
  54190. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54191. /** @hidden */
  54192. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  54193. }
  54194. }
  54195. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  54196. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54198. import { Nullable } from "babylonjs/types";
  54199. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54200. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54201. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54203. import { Mesh } from "babylonjs/Meshes/mesh";
  54204. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54205. import { Scene } from "babylonjs/scene";
  54206. /**
  54207. * Defines a block that can be used inside a node based material
  54208. */
  54209. export class NodeMaterialBlock {
  54210. private _buildId;
  54211. private _buildTarget;
  54212. private _target;
  54213. private _isFinalMerger;
  54214. private _isInput;
  54215. /** @hidden */
  54216. _inputs: NodeMaterialConnectionPoint[];
  54217. /** @hidden */
  54218. _outputs: NodeMaterialConnectionPoint[];
  54219. /**
  54220. * Gets or sets the name of the block
  54221. */
  54222. name: string;
  54223. /**
  54224. * Gets or sets the unique id of the node
  54225. */
  54226. uniqueId: number;
  54227. /**
  54228. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  54229. */
  54230. readonly isFinalMerger: boolean;
  54231. /**
  54232. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  54233. */
  54234. readonly isInput: boolean;
  54235. /**
  54236. * Gets or sets the build Id
  54237. */
  54238. buildId: number;
  54239. /**
  54240. * Gets or sets the target of the block
  54241. */
  54242. target: NodeMaterialBlockTargets;
  54243. /**
  54244. * Gets the list of input points
  54245. */
  54246. readonly inputs: NodeMaterialConnectionPoint[];
  54247. /** Gets the list of output points */
  54248. readonly outputs: NodeMaterialConnectionPoint[];
  54249. /**
  54250. * Find an input by its name
  54251. * @param name defines the name of the input to look for
  54252. * @returns the input or null if not found
  54253. */
  54254. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54255. /**
  54256. * Find an output by its name
  54257. * @param name defines the name of the outputto look for
  54258. * @returns the output or null if not found
  54259. */
  54260. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  54261. /**
  54262. * Creates a new NodeMaterialBlock
  54263. * @param name defines the block name
  54264. * @param target defines the target of that block (Vertex by default)
  54265. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  54266. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  54267. */
  54268. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  54269. /**
  54270. * Initialize the block and prepare the context for build
  54271. * @param state defines the state that will be used for the build
  54272. */
  54273. initialize(state: NodeMaterialBuildState): void;
  54274. /**
  54275. * Bind data to effect. Will only be called for blocks with isBindable === true
  54276. * @param effect defines the effect to bind data to
  54277. * @param nodeMaterial defines the hosting NodeMaterial
  54278. * @param mesh defines the mesh that will be rendered
  54279. */
  54280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54281. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  54282. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  54283. protected _writeFloat(value: number): string;
  54284. /**
  54285. * Gets the current class name e.g. "NodeMaterialBlock"
  54286. * @returns the class name
  54287. */
  54288. getClassName(): string;
  54289. /**
  54290. * Register a new input. Must be called inside a block constructor
  54291. * @param name defines the connection point name
  54292. * @param type defines the connection point type
  54293. * @param isOptional defines a boolean indicating that this input can be omitted
  54294. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54295. * @returns the current block
  54296. */
  54297. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  54298. /**
  54299. * Register a new output. Must be called inside a block constructor
  54300. * @param name defines the connection point name
  54301. * @param type defines the connection point type
  54302. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  54303. * @returns the current block
  54304. */
  54305. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  54306. /**
  54307. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  54308. * @param forOutput defines an optional connection point to check compatibility with
  54309. * @returns the first available input or null
  54310. */
  54311. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  54312. /**
  54313. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  54314. * @param forBlock defines an optional block to check compatibility with
  54315. * @returns the first available input or null
  54316. */
  54317. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  54318. /**
  54319. * Connect current block with another block
  54320. * @param other defines the block to connect with
  54321. * @param options define the various options to help pick the right connections
  54322. * @returns the current block
  54323. */
  54324. connectTo(other: NodeMaterialBlock, options?: {
  54325. input?: string;
  54326. output?: string;
  54327. outputSwizzle?: string;
  54328. }): this | undefined;
  54329. protected _buildBlock(state: NodeMaterialBuildState): void;
  54330. /**
  54331. * Add uniforms, samplers and uniform buffers at compilation time
  54332. * @param state defines the state to update
  54333. * @param nodeMaterial defines the node material requesting the update
  54334. * @param defines defines the material defines to update
  54335. */
  54336. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54337. /**
  54338. * Add potential fallbacks if shader compilation fails
  54339. * @param mesh defines the mesh to be rendered
  54340. * @param fallbacks defines the current prioritized list of fallbacks
  54341. */
  54342. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54343. /**
  54344. * Update defines for shader compilation
  54345. * @param mesh defines the mesh to be rendered
  54346. * @param nodeMaterial defines the node material requesting the update
  54347. * @param defines defines the material defines to update
  54348. * @param useInstances specifies that instances should be used
  54349. */
  54350. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54351. /**
  54352. * Initialize defines for shader compilation
  54353. * @param mesh defines the mesh to be rendered
  54354. * @param nodeMaterial defines the node material requesting the update
  54355. * @param defines defines the material defines to be prepared
  54356. * @param useInstances specifies that instances should be used
  54357. */
  54358. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54359. /**
  54360. * Lets the block try to connect some inputs automatically
  54361. */
  54362. autoConfigure(): void;
  54363. /**
  54364. * Function called when a block is declared as repeatable content generator
  54365. * @param vertexShaderState defines the current compilation state for the vertex shader
  54366. * @param fragmentShaderState defines the current compilation state for the fragment shader
  54367. * @param mesh defines the mesh to be rendered
  54368. * @param defines defines the material defines to update
  54369. */
  54370. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54371. /**
  54372. * Checks if the block is ready
  54373. * @param mesh defines the mesh to be rendered
  54374. * @param nodeMaterial defines the node material requesting the update
  54375. * @param defines defines the material defines to update
  54376. * @param useInstances specifies that instances should be used
  54377. * @returns true if the block is ready
  54378. */
  54379. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  54380. private _processBuild;
  54381. /**
  54382. * Compile the current node and generate the shader code
  54383. * @param state defines the current compilation state (uniforms, samplers, current string)
  54384. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  54385. * @returns true if already built
  54386. */
  54387. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  54388. /**
  54389. * Serializes this block in a JSON representation
  54390. * @returns the serialized block object
  54391. */
  54392. serialize(): any;
  54393. /** @hidden */
  54394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54395. }
  54396. }
  54397. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  54398. /**
  54399. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54400. */
  54401. export enum NodeMaterialBlockConnectionPointMode {
  54402. /** Value is an uniform */
  54403. Uniform = 0,
  54404. /** Value is a mesh attribute */
  54405. Attribute = 1,
  54406. /** Value is a varying between vertex and fragment shaders */
  54407. Varying = 2,
  54408. /** Mode is undefined */
  54409. Undefined = 3
  54410. }
  54411. }
  54412. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  54413. /**
  54414. * Enum used to define well known values e.g. values automatically provided by the system
  54415. */
  54416. export enum NodeMaterialWellKnownValues {
  54417. /** World */
  54418. World = 1,
  54419. /** View */
  54420. View = 2,
  54421. /** Projection */
  54422. Projection = 3,
  54423. /** ViewProjection */
  54424. ViewProjection = 4,
  54425. /** WorldView */
  54426. WorldView = 5,
  54427. /** WorldViewProjection */
  54428. WorldViewProjection = 6,
  54429. /** CameraPosition */
  54430. CameraPosition = 7,
  54431. /** Fog Color */
  54432. FogColor = 8
  54433. }
  54434. }
  54435. declare module "babylonjs/Maths/math.vertexFormat" {
  54436. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  54437. /**
  54438. * Contains position and normal vectors for a vertex
  54439. */
  54440. export class PositionNormalVertex {
  54441. /** the position of the vertex (defaut: 0,0,0) */
  54442. position: Vector3;
  54443. /** the normal of the vertex (defaut: 0,1,0) */
  54444. normal: Vector3;
  54445. /**
  54446. * Creates a PositionNormalVertex
  54447. * @param position the position of the vertex (defaut: 0,0,0)
  54448. * @param normal the normal of the vertex (defaut: 0,1,0)
  54449. */
  54450. constructor(
  54451. /** the position of the vertex (defaut: 0,0,0) */
  54452. position?: Vector3,
  54453. /** the normal of the vertex (defaut: 0,1,0) */
  54454. normal?: Vector3);
  54455. /**
  54456. * Clones the PositionNormalVertex
  54457. * @returns the cloned PositionNormalVertex
  54458. */
  54459. clone(): PositionNormalVertex;
  54460. }
  54461. /**
  54462. * Contains position, normal and uv vectors for a vertex
  54463. */
  54464. export class PositionNormalTextureVertex {
  54465. /** the position of the vertex (defaut: 0,0,0) */
  54466. position: Vector3;
  54467. /** the normal of the vertex (defaut: 0,1,0) */
  54468. normal: Vector3;
  54469. /** the uv of the vertex (default: 0,0) */
  54470. uv: Vector2;
  54471. /**
  54472. * Creates a PositionNormalTextureVertex
  54473. * @param position the position of the vertex (defaut: 0,0,0)
  54474. * @param normal the normal of the vertex (defaut: 0,1,0)
  54475. * @param uv the uv of the vertex (default: 0,0)
  54476. */
  54477. constructor(
  54478. /** the position of the vertex (defaut: 0,0,0) */
  54479. position?: Vector3,
  54480. /** the normal of the vertex (defaut: 0,1,0) */
  54481. normal?: Vector3,
  54482. /** the uv of the vertex (default: 0,0) */
  54483. uv?: Vector2);
  54484. /**
  54485. * Clones the PositionNormalTextureVertex
  54486. * @returns the cloned PositionNormalTextureVertex
  54487. */
  54488. clone(): PositionNormalTextureVertex;
  54489. }
  54490. }
  54491. declare module "babylonjs/Maths/math" {
  54492. export * from "babylonjs/Maths/math.axis";
  54493. export * from "babylonjs/Maths/math.color";
  54494. export * from "babylonjs/Maths/math.constants";
  54495. export * from "babylonjs/Maths/math.frustum";
  54496. export * from "babylonjs/Maths/math.path";
  54497. export * from "babylonjs/Maths/math.plane";
  54498. export * from "babylonjs/Maths/math.size";
  54499. export * from "babylonjs/Maths/math.vector";
  54500. export * from "babylonjs/Maths/math.vertexFormat";
  54501. export * from "babylonjs/Maths/math.viewport";
  54502. }
  54503. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  54504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54505. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54506. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54507. import { Nullable } from "babylonjs/types";
  54508. import { Effect } from "babylonjs/Materials/effect";
  54509. import { Matrix } from "babylonjs/Maths/math.vector";
  54510. import { Scene } from "babylonjs/scene";
  54511. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54512. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54513. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54514. /**
  54515. * Block used to expose an input value
  54516. */
  54517. export class InputBlock extends NodeMaterialBlock {
  54518. private _mode;
  54519. private _associatedVariableName;
  54520. private _storedValue;
  54521. private _valueCallback;
  54522. private _type;
  54523. /** @hidden */
  54524. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54525. /**
  54526. * Gets or sets the connection point type (default is float)
  54527. */
  54528. readonly type: NodeMaterialBlockConnectionPointTypes;
  54529. /**
  54530. * Creates a new InputBlock
  54531. * @param name defines the block name
  54532. * @param target defines the target of that block (Vertex by default)
  54533. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  54534. */
  54535. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  54536. /**
  54537. * Gets the output component
  54538. */
  54539. readonly output: NodeMaterialConnectionPoint;
  54540. /**
  54541. * Set the source of this connection point to a vertex attribute
  54542. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  54543. * @returns the current connection point
  54544. */
  54545. setAsAttribute(attributeName?: string): InputBlock;
  54546. /**
  54547. * Set the source of this connection point to a well known value
  54548. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  54549. * @returns the current connection point
  54550. */
  54551. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  54552. /**
  54553. * Gets or sets the value of that point.
  54554. * Please note that this value will be ignored if valueCallback is defined
  54555. */
  54556. value: any;
  54557. /**
  54558. * Gets or sets a callback used to get the value of that point.
  54559. * Please note that setting this value will force the connection point to ignore the value property
  54560. */
  54561. valueCallback: () => any;
  54562. /**
  54563. * Gets or sets the associated variable name in the shader
  54564. */
  54565. associatedVariableName: string;
  54566. /**
  54567. * Gets a boolean indicating that this connection point not defined yet
  54568. */
  54569. readonly isUndefined: boolean;
  54570. /**
  54571. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  54572. * In this case the connection point name must be the name of the uniform to use.
  54573. * Can only be set on inputs
  54574. */
  54575. isUniform: boolean;
  54576. /**
  54577. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  54578. * In this case the connection point name must be the name of the attribute to use
  54579. * Can only be set on inputs
  54580. */
  54581. isAttribute: boolean;
  54582. /**
  54583. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  54584. * Can only be set on exit points
  54585. */
  54586. isVarying: boolean;
  54587. /**
  54588. * Gets a boolean indicating that the current connection point is a well known value
  54589. */
  54590. readonly isWellKnownValue: boolean;
  54591. /**
  54592. * Gets or sets the current well known value or null if not defined as well know value
  54593. */
  54594. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  54595. /**
  54596. * Gets the current class name
  54597. * @returns the class name
  54598. */
  54599. getClassName(): string;
  54600. private _emitDefine;
  54601. /**
  54602. * Set the input block to its default value (based on its type)
  54603. */
  54604. setDefaultValue(): void;
  54605. private _emit;
  54606. /** @hidden */
  54607. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  54608. /** @hidden */
  54609. _transmit(effect: Effect, scene: Scene): void;
  54610. protected _buildBlock(state: NodeMaterialBuildState): void;
  54611. serialize(): any;
  54612. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  54613. }
  54614. }
  54615. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  54616. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54617. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54618. import { Nullable } from "babylonjs/types";
  54619. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  54620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54621. /**
  54622. * Defines a connection point for a block
  54623. */
  54624. export class NodeMaterialConnectionPoint {
  54625. /** @hidden */
  54626. _ownerBlock: NodeMaterialBlock;
  54627. /** @hidden */
  54628. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54629. private _endpoints;
  54630. private _associatedVariableName;
  54631. /** @hidden */
  54632. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  54633. private _type;
  54634. /** @hidden */
  54635. _enforceAssociatedVariableName: boolean;
  54636. /**
  54637. * Gets or sets the associated variable name in the shader
  54638. */
  54639. associatedVariableName: string;
  54640. /**
  54641. * Gets or sets the connection point type (default is float)
  54642. */
  54643. type: NodeMaterialBlockConnectionPointTypes;
  54644. /**
  54645. * Gets or sets the connection point name
  54646. */
  54647. name: string;
  54648. /**
  54649. * Gets or sets the swizzle to apply to this connection point when reading or writing
  54650. */
  54651. swizzle: string;
  54652. /**
  54653. * Gets or sets a boolean indicating that this connection point can be omitted
  54654. */
  54655. isOptional: boolean;
  54656. /**
  54657. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  54658. */
  54659. define: string;
  54660. /** Gets or sets the target of that connection point */
  54661. target: NodeMaterialBlockTargets;
  54662. /**
  54663. * Gets a boolean indicating that the current point is connected
  54664. */
  54665. readonly isConnected: boolean;
  54666. /**
  54667. * Gets a boolean indicating that the current point is connected to an input block
  54668. */
  54669. readonly isConnectedToInput: boolean;
  54670. /**
  54671. * Gets a the connected input block (if any)
  54672. */
  54673. readonly connectInputBlock: Nullable<InputBlock>;
  54674. /** Get the other side of the connection (if any) */
  54675. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  54676. /** Get the block that owns this connection point */
  54677. readonly ownerBlock: NodeMaterialBlock;
  54678. /** Get the block connected on the other side of this connection (if any) */
  54679. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  54680. /** Get the block connected on the endpoints of this connection (if any) */
  54681. readonly connectedBlocks: Array<NodeMaterialBlock>;
  54682. /** Gets the list of connected endpoints */
  54683. readonly endpoints: NodeMaterialConnectionPoint[];
  54684. /**
  54685. * Creates a new connection point
  54686. * @param name defines the connection point name
  54687. * @param ownerBlock defines the block hosting this connection point
  54688. */
  54689. constructor(name: string, ownerBlock: NodeMaterialBlock);
  54690. /**
  54691. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  54692. * @returns the class name
  54693. */
  54694. getClassName(): string;
  54695. /**
  54696. * Gets an boolean indicating if the current point can be connected to another point
  54697. * @param connectionPoint defines the other connection point
  54698. * @returns true if the connection is possible
  54699. */
  54700. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  54701. /**
  54702. * Connect this point to another connection point
  54703. * @param connectionPoint defines the other connection point
  54704. * @returns the current connection point
  54705. */
  54706. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54707. /**
  54708. * Disconnect this point from one of his endpoint
  54709. * @param endpoint defines the other connection point
  54710. * @returns the current connection point
  54711. */
  54712. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  54713. /**
  54714. * Serializes this point in a JSON representation
  54715. * @returns the serialized point object
  54716. */
  54717. serialize(): any;
  54718. private static _GetTypeLength;
  54719. }
  54720. }
  54721. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  54722. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54723. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54725. import { Mesh } from "babylonjs/Meshes/mesh";
  54726. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  54727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54728. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54729. /**
  54730. * Block used to add support for vertex skinning (bones)
  54731. */
  54732. export class BonesBlock extends NodeMaterialBlock {
  54733. /**
  54734. * Creates a new BonesBlock
  54735. * @param name defines the block name
  54736. */
  54737. constructor(name: string);
  54738. /**
  54739. * Initialize the block and prepare the context for build
  54740. * @param state defines the state that will be used for the build
  54741. */
  54742. initialize(state: NodeMaterialBuildState): void;
  54743. /**
  54744. * Gets the current class name
  54745. * @returns the class name
  54746. */
  54747. getClassName(): string;
  54748. /**
  54749. * Gets the matrix indices input component
  54750. */
  54751. readonly matricesIndices: NodeMaterialConnectionPoint;
  54752. /**
  54753. * Gets the matrix weights input component
  54754. */
  54755. readonly matricesWeights: NodeMaterialConnectionPoint;
  54756. /**
  54757. * Gets the extra matrix indices input component
  54758. */
  54759. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  54760. /**
  54761. * Gets the extra matrix weights input component
  54762. */
  54763. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  54764. /**
  54765. * Gets the world input component
  54766. */
  54767. readonly world: NodeMaterialConnectionPoint;
  54768. /**
  54769. * Gets the output component
  54770. */
  54771. readonly output: NodeMaterialConnectionPoint;
  54772. autoConfigure(): void;
  54773. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  54774. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54776. protected _buildBlock(state: NodeMaterialBuildState): this;
  54777. }
  54778. }
  54779. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  54780. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54781. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54784. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54785. /**
  54786. * Block used to add support for instances
  54787. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  54788. */
  54789. export class InstancesBlock extends NodeMaterialBlock {
  54790. /**
  54791. * Creates a new InstancesBlock
  54792. * @param name defines the block name
  54793. */
  54794. constructor(name: string);
  54795. /**
  54796. * Gets the current class name
  54797. * @returns the class name
  54798. */
  54799. getClassName(): string;
  54800. /**
  54801. * Gets the first world row input component
  54802. */
  54803. readonly world0: NodeMaterialConnectionPoint;
  54804. /**
  54805. * Gets the second world row input component
  54806. */
  54807. readonly world1: NodeMaterialConnectionPoint;
  54808. /**
  54809. * Gets the third world row input component
  54810. */
  54811. readonly world2: NodeMaterialConnectionPoint;
  54812. /**
  54813. * Gets the forth world row input component
  54814. */
  54815. readonly world3: NodeMaterialConnectionPoint;
  54816. /**
  54817. * Gets the world input component
  54818. */
  54819. readonly world: NodeMaterialConnectionPoint;
  54820. /**
  54821. * Gets the output component
  54822. */
  54823. readonly output: NodeMaterialConnectionPoint;
  54824. autoConfigure(): void;
  54825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54826. protected _buildBlock(state: NodeMaterialBuildState): this;
  54827. }
  54828. }
  54829. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54834. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54835. import { Effect } from "babylonjs/Materials/effect";
  54836. import { Mesh } from "babylonjs/Meshes/mesh";
  54837. /**
  54838. * Block used to add morph targets support to vertex shader
  54839. */
  54840. export class MorphTargetsBlock extends NodeMaterialBlock {
  54841. private _repeatableContentAnchor;
  54842. private _repeatebleContentGenerated;
  54843. /**
  54844. * Create a new MorphTargetsBlock
  54845. * @param name defines the block name
  54846. */
  54847. constructor(name: string);
  54848. /**
  54849. * Gets the current class name
  54850. * @returns the class name
  54851. */
  54852. getClassName(): string;
  54853. /**
  54854. * Gets the position input component
  54855. */
  54856. readonly position: NodeMaterialConnectionPoint;
  54857. /**
  54858. * Gets the normal input component
  54859. */
  54860. readonly normal: NodeMaterialConnectionPoint;
  54861. /**
  54862. * Gets the tangent input component
  54863. */
  54864. readonly tangent: NodeMaterialConnectionPoint;
  54865. /**
  54866. * Gets the tangent input component
  54867. */
  54868. readonly uv: NodeMaterialConnectionPoint;
  54869. /**
  54870. * Gets the position output component
  54871. */
  54872. readonly positionOutput: NodeMaterialConnectionPoint;
  54873. /**
  54874. * Gets the normal output component
  54875. */
  54876. readonly normalOutput: NodeMaterialConnectionPoint;
  54877. /**
  54878. * Gets the tangent output component
  54879. */
  54880. readonly tangentOutput: NodeMaterialConnectionPoint;
  54881. /**
  54882. * Gets the tangent output component
  54883. */
  54884. readonly uvOutput: NodeMaterialConnectionPoint;
  54885. initialize(state: NodeMaterialBuildState): void;
  54886. autoConfigure(): void;
  54887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54888. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54889. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54890. protected _buildBlock(state: NodeMaterialBuildState): this;
  54891. }
  54892. }
  54893. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54894. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54895. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54896. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54897. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54898. }
  54899. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54903. /**
  54904. * Block used to add an alpha test in the fragment shader
  54905. */
  54906. export class AlphaTestBlock extends NodeMaterialBlock {
  54907. /**
  54908. * Gets or sets the alpha value where alpha testing happens
  54909. */
  54910. alphaCutOff: number;
  54911. /**
  54912. * Create a new AlphaTestBlock
  54913. * @param name defines the block name
  54914. */
  54915. constructor(name: string);
  54916. /**
  54917. * Gets the current class name
  54918. * @returns the class name
  54919. */
  54920. getClassName(): string;
  54921. /**
  54922. * Gets the color input component
  54923. */
  54924. readonly color: NodeMaterialConnectionPoint;
  54925. protected _buildBlock(state: NodeMaterialBuildState): this;
  54926. }
  54927. }
  54928. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54932. /**
  54933. * Block used to create a Color4 out of 4 inputs (one for each component)
  54934. */
  54935. export class RGBAMergerBlock extends NodeMaterialBlock {
  54936. /**
  54937. * Create a new RGBAMergerBlock
  54938. * @param name defines the block name
  54939. */
  54940. constructor(name: string);
  54941. /**
  54942. * Gets the current class name
  54943. * @returns the class name
  54944. */
  54945. getClassName(): string;
  54946. /**
  54947. * Gets the R input component
  54948. */
  54949. readonly r: NodeMaterialConnectionPoint;
  54950. /**
  54951. * Gets the G input component
  54952. */
  54953. readonly g: NodeMaterialConnectionPoint;
  54954. /**
  54955. * Gets the B input component
  54956. */
  54957. readonly b: NodeMaterialConnectionPoint;
  54958. /**
  54959. * Gets the RGB input component
  54960. */
  54961. readonly rgb: NodeMaterialConnectionPoint;
  54962. /**
  54963. * Gets the R input component
  54964. */
  54965. readonly a: NodeMaterialConnectionPoint;
  54966. /**
  54967. * Gets the output component
  54968. */
  54969. readonly output: NodeMaterialConnectionPoint;
  54970. protected _buildBlock(state: NodeMaterialBuildState): this;
  54971. }
  54972. }
  54973. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54974. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54975. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54976. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54977. /**
  54978. * Block used to create a Color3 out of 3 inputs (one for each component)
  54979. */
  54980. export class RGBMergerBlock extends NodeMaterialBlock {
  54981. /**
  54982. * Create a new RGBMergerBlock
  54983. * @param name defines the block name
  54984. */
  54985. constructor(name: string);
  54986. /**
  54987. * Gets the current class name
  54988. * @returns the class name
  54989. */
  54990. getClassName(): string;
  54991. /**
  54992. * Gets the R component input
  54993. */
  54994. readonly r: NodeMaterialConnectionPoint;
  54995. /**
  54996. * Gets the G component input
  54997. */
  54998. readonly g: NodeMaterialConnectionPoint;
  54999. /**
  55000. * Gets the B component input
  55001. */
  55002. readonly b: NodeMaterialConnectionPoint;
  55003. /**
  55004. * Gets the output component
  55005. */
  55006. readonly output: NodeMaterialConnectionPoint;
  55007. protected _buildBlock(state: NodeMaterialBuildState): this;
  55008. }
  55009. }
  55010. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  55011. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55012. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55013. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55014. /**
  55015. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  55016. */
  55017. export class RGBASplitterBlock extends NodeMaterialBlock {
  55018. /**
  55019. * Create a new RGBASplitterBlock
  55020. * @param name defines the block name
  55021. */
  55022. constructor(name: string);
  55023. /**
  55024. * Gets the current class name
  55025. * @returns the class name
  55026. */
  55027. getClassName(): string;
  55028. /**
  55029. * Gets the input component
  55030. */
  55031. readonly input: NodeMaterialConnectionPoint;
  55032. protected _buildBlock(state: NodeMaterialBuildState): this;
  55033. }
  55034. }
  55035. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  55036. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55037. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55038. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55039. /**
  55040. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  55041. */
  55042. export class RGBSplitterBlock extends NodeMaterialBlock {
  55043. /**
  55044. * Create a new RGBSplitterBlock
  55045. * @param name defines the block name
  55046. */
  55047. constructor(name: string);
  55048. /**
  55049. * Gets the current class name
  55050. * @returns the class name
  55051. */
  55052. getClassName(): string;
  55053. /**
  55054. * Gets the input component
  55055. */
  55056. readonly input: NodeMaterialConnectionPoint;
  55057. protected _buildBlock(state: NodeMaterialBuildState): this;
  55058. }
  55059. }
  55060. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  55061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55065. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55066. import { Effect } from "babylonjs/Materials/effect";
  55067. import { Mesh } from "babylonjs/Meshes/mesh";
  55068. /**
  55069. * Block used to add image processing support to fragment shader
  55070. */
  55071. export class ImageProcessingBlock extends NodeMaterialBlock {
  55072. /**
  55073. * Create a new ImageProcessingBlock
  55074. * @param name defines the block name
  55075. */
  55076. constructor(name: string);
  55077. /**
  55078. * Gets the current class name
  55079. * @returns the class name
  55080. */
  55081. getClassName(): string;
  55082. /**
  55083. * Gets the color input component
  55084. */
  55085. readonly color: NodeMaterialConnectionPoint;
  55086. /**
  55087. * Gets the output component
  55088. */
  55089. readonly output: NodeMaterialConnectionPoint;
  55090. /**
  55091. * Initialize the block and prepare the context for build
  55092. * @param state defines the state that will be used for the build
  55093. */
  55094. initialize(state: NodeMaterialBuildState): void;
  55095. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  55096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55098. protected _buildBlock(state: NodeMaterialBuildState): this;
  55099. }
  55100. }
  55101. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  55102. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  55103. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  55104. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  55105. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  55106. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  55107. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  55108. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  55109. }
  55110. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  55111. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55112. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55113. import { Mesh } from "babylonjs/Meshes/mesh";
  55114. import { Effect } from "babylonjs/Materials/effect";
  55115. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55117. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55118. /**
  55119. * Block used to add support for scene fog
  55120. */
  55121. export class FogBlock extends NodeMaterialBlock {
  55122. private _fogDistanceName;
  55123. private _fogParameters;
  55124. /**
  55125. * Create a new FogBlock
  55126. * @param name defines the block name
  55127. */
  55128. constructor(name: string);
  55129. /**
  55130. * Gets the current class name
  55131. * @returns the class name
  55132. */
  55133. getClassName(): string;
  55134. /**
  55135. * Gets the world position input component
  55136. */
  55137. readonly worldPosition: NodeMaterialConnectionPoint;
  55138. /**
  55139. * Gets the view input component
  55140. */
  55141. readonly view: NodeMaterialConnectionPoint;
  55142. /**
  55143. * Gets the color input component
  55144. */
  55145. readonly color: NodeMaterialConnectionPoint;
  55146. /**
  55147. * Gets the fog color input component
  55148. */
  55149. readonly fogColor: NodeMaterialConnectionPoint;
  55150. /**
  55151. * Gets the output component
  55152. */
  55153. readonly output: NodeMaterialConnectionPoint;
  55154. autoConfigure(): void;
  55155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55156. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55157. protected _buildBlock(state: NodeMaterialBuildState): this;
  55158. }
  55159. }
  55160. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  55161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55165. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55166. import { Effect } from "babylonjs/Materials/effect";
  55167. import { Mesh } from "babylonjs/Meshes/mesh";
  55168. import { Light } from "babylonjs/Lights/light";
  55169. import { Nullable } from "babylonjs/types";
  55170. import { Scene } from "babylonjs/scene";
  55171. /**
  55172. * Block used to add light in the fragment shader
  55173. */
  55174. export class LightBlock extends NodeMaterialBlock {
  55175. private _lightId;
  55176. /**
  55177. * Gets or sets the light associated with this block
  55178. */
  55179. light: Nullable<Light>;
  55180. /**
  55181. * Create a new LightBlock
  55182. * @param name defines the block name
  55183. */
  55184. constructor(name: string);
  55185. /**
  55186. * Gets the current class name
  55187. * @returns the class name
  55188. */
  55189. getClassName(): string;
  55190. /**
  55191. * Gets the world position input component
  55192. */
  55193. readonly worldPosition: NodeMaterialConnectionPoint;
  55194. /**
  55195. * Gets the world normal input component
  55196. */
  55197. readonly worldNormal: NodeMaterialConnectionPoint;
  55198. /**
  55199. * Gets the camera (or eye) position component
  55200. */
  55201. readonly cameraPosition: NodeMaterialConnectionPoint;
  55202. /**
  55203. * Gets the diffuse output component
  55204. */
  55205. readonly diffuseOutput: NodeMaterialConnectionPoint;
  55206. /**
  55207. * Gets the specular output component
  55208. */
  55209. readonly specularOutput: NodeMaterialConnectionPoint;
  55210. autoConfigure(): void;
  55211. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55212. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55213. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55214. private _injectVertexCode;
  55215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55216. serialize(): any;
  55217. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55218. }
  55219. }
  55220. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  55221. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  55222. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  55223. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55224. }
  55225. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  55226. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55227. }
  55228. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  55229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55232. /**
  55233. * Block used to multiply 2 values
  55234. */
  55235. export class MultiplyBlock extends NodeMaterialBlock {
  55236. /**
  55237. * Creates a new MultiplyBlock
  55238. * @param name defines the block name
  55239. */
  55240. constructor(name: string);
  55241. /**
  55242. * Gets the current class name
  55243. * @returns the class name
  55244. */
  55245. getClassName(): string;
  55246. /**
  55247. * Gets the left operand input component
  55248. */
  55249. readonly left: NodeMaterialConnectionPoint;
  55250. /**
  55251. * Gets the right operand input component
  55252. */
  55253. readonly right: NodeMaterialConnectionPoint;
  55254. /**
  55255. * Gets the output component
  55256. */
  55257. readonly output: NodeMaterialConnectionPoint;
  55258. protected _buildBlock(state: NodeMaterialBuildState): this;
  55259. }
  55260. }
  55261. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  55262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55263. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55264. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55265. /**
  55266. * Block used to add 2 vectors
  55267. */
  55268. export class AddBlock extends NodeMaterialBlock {
  55269. /**
  55270. * Creates a new AddBlock
  55271. * @param name defines the block name
  55272. */
  55273. constructor(name: string);
  55274. /**
  55275. * Gets the current class name
  55276. * @returns the class name
  55277. */
  55278. getClassName(): string;
  55279. /**
  55280. * Gets the left operand input component
  55281. */
  55282. readonly left: NodeMaterialConnectionPoint;
  55283. /**
  55284. * Gets the right operand input component
  55285. */
  55286. readonly right: NodeMaterialConnectionPoint;
  55287. /**
  55288. * Gets the output component
  55289. */
  55290. readonly output: NodeMaterialConnectionPoint;
  55291. protected _buildBlock(state: NodeMaterialBuildState): this;
  55292. }
  55293. }
  55294. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  55295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55298. /**
  55299. * Block used to clamp a float
  55300. */
  55301. export class ClampBlock extends NodeMaterialBlock {
  55302. /** Gets or sets the minimum range */
  55303. minimum: number;
  55304. /** Gets or sets the maximum range */
  55305. maximum: number;
  55306. /**
  55307. * Creates a new ClampBlock
  55308. * @param name defines the block name
  55309. */
  55310. constructor(name: string);
  55311. /**
  55312. * Gets the current class name
  55313. * @returns the class name
  55314. */
  55315. getClassName(): string;
  55316. /**
  55317. * Gets the value input component
  55318. */
  55319. readonly value: NodeMaterialConnectionPoint;
  55320. /**
  55321. * Gets the output component
  55322. */
  55323. readonly output: NodeMaterialConnectionPoint;
  55324. protected _buildBlock(state: NodeMaterialBuildState): this;
  55325. }
  55326. }
  55327. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  55328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55331. /**
  55332. * Block used to apply a cross product between 2 vectors
  55333. */
  55334. export class CrossBlock extends NodeMaterialBlock {
  55335. /**
  55336. * Creates a new CrossBlock
  55337. * @param name defines the block name
  55338. */
  55339. constructor(name: string);
  55340. /**
  55341. * Gets the current class name
  55342. * @returns the class name
  55343. */
  55344. getClassName(): string;
  55345. /**
  55346. * Gets the left operand input component
  55347. */
  55348. readonly left: NodeMaterialConnectionPoint;
  55349. /**
  55350. * Gets the right operand input component
  55351. */
  55352. readonly right: NodeMaterialConnectionPoint;
  55353. /**
  55354. * Gets the output component
  55355. */
  55356. readonly output: NodeMaterialConnectionPoint;
  55357. protected _buildBlock(state: NodeMaterialBuildState): this;
  55358. }
  55359. }
  55360. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  55361. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55362. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55363. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55364. /**
  55365. * Block used to apply a dot product between 2 vectors
  55366. */
  55367. export class DotBlock extends NodeMaterialBlock {
  55368. /**
  55369. * Creates a new DotBlock
  55370. * @param name defines the block name
  55371. */
  55372. constructor(name: string);
  55373. /**
  55374. * Gets the current class name
  55375. * @returns the class name
  55376. */
  55377. getClassName(): string;
  55378. /**
  55379. * Gets the left operand input component
  55380. */
  55381. readonly left: NodeMaterialConnectionPoint;
  55382. /**
  55383. * Gets the right operand input component
  55384. */
  55385. readonly right: NodeMaterialConnectionPoint;
  55386. /**
  55387. * Gets the output component
  55388. */
  55389. readonly output: NodeMaterialConnectionPoint;
  55390. protected _buildBlock(state: NodeMaterialBuildState): this;
  55391. }
  55392. }
  55393. declare module "babylonjs/Materials/Node/Blocks/index" {
  55394. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  55395. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  55396. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  55397. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  55398. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  55399. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  55400. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  55401. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  55402. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  55403. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  55404. }
  55405. declare module "babylonjs/Materials/Node/Optimizers/index" {
  55406. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55407. }
  55408. declare module "babylonjs/Materials/Node/index" {
  55409. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  55410. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  55411. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55412. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  55413. export * from "babylonjs/Materials/Node/nodeMaterial";
  55414. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  55415. export * from "babylonjs/Materials/Node/Blocks/index";
  55416. export * from "babylonjs/Materials/Node/Optimizers/index";
  55417. }
  55418. declare module "babylonjs/Materials/effectRenderer" {
  55419. import { Nullable } from "babylonjs/types";
  55420. import { Texture } from "babylonjs/Materials/Textures/texture";
  55421. import { Engine } from "babylonjs/Engines/engine";
  55422. import { Viewport } from "babylonjs/Maths/math.viewport";
  55423. import { Observable } from "babylonjs/Misc/observable";
  55424. import { Effect } from "babylonjs/Materials/effect";
  55425. import "babylonjs/Shaders/postprocess.vertex";
  55426. /**
  55427. * Effect Render Options
  55428. */
  55429. export interface IEffectRendererOptions {
  55430. /**
  55431. * Defines the vertices positions.
  55432. */
  55433. positions?: number[];
  55434. /**
  55435. * Defines the indices.
  55436. */
  55437. indices?: number[];
  55438. }
  55439. /**
  55440. * Helper class to render one or more effects
  55441. */
  55442. export class EffectRenderer {
  55443. private engine;
  55444. private static _DefaultOptions;
  55445. private _vertexBuffers;
  55446. private _indexBuffer;
  55447. private _ringBufferIndex;
  55448. private _ringScreenBuffer;
  55449. private _fullscreenViewport;
  55450. private _getNextFrameBuffer;
  55451. /**
  55452. * Creates an effect renderer
  55453. * @param engine the engine to use for rendering
  55454. * @param options defines the options of the effect renderer
  55455. */
  55456. constructor(engine: Engine, options?: IEffectRendererOptions);
  55457. /**
  55458. * Sets the current viewport in normalized coordinates 0-1
  55459. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  55460. */
  55461. setViewport(viewport?: Viewport): void;
  55462. /**
  55463. * Sets the current effect wrapper to use during draw.
  55464. * The effect needs to be ready before calling this api.
  55465. * This also sets the default full screen position attribute.
  55466. * @param effectWrapper Defines the effect to draw with
  55467. */
  55468. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  55469. /**
  55470. * Draws a full screen quad.
  55471. */
  55472. draw(): void;
  55473. /**
  55474. * renders one or more effects to a specified texture
  55475. * @param effectWrappers list of effects to renderer
  55476. * @param outputTexture texture to draw to, if null it will render to the screen
  55477. */
  55478. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  55479. /**
  55480. * Disposes of the effect renderer
  55481. */
  55482. dispose(): void;
  55483. }
  55484. /**
  55485. * Options to create an EffectWrapper
  55486. */
  55487. interface EffectWrapperCreationOptions {
  55488. /**
  55489. * Engine to use to create the effect
  55490. */
  55491. engine: Engine;
  55492. /**
  55493. * Fragment shader for the effect
  55494. */
  55495. fragmentShader: string;
  55496. /**
  55497. * Vertex shader for the effect
  55498. */
  55499. vertexShader: string;
  55500. /**
  55501. * Attributes to use in the shader
  55502. */
  55503. attributeNames?: Array<string>;
  55504. /**
  55505. * Uniforms to use in the shader
  55506. */
  55507. uniformNames?: Array<string>;
  55508. /**
  55509. * Texture sampler names to use in the shader
  55510. */
  55511. samplerNames?: Array<string>;
  55512. /**
  55513. * The friendly name of the effect displayed in Spector.
  55514. */
  55515. name?: string;
  55516. }
  55517. /**
  55518. * Wraps an effect to be used for rendering
  55519. */
  55520. export class EffectWrapper {
  55521. /**
  55522. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  55523. */
  55524. onApplyObservable: Observable<{}>;
  55525. /**
  55526. * The underlying effect
  55527. */
  55528. effect: Effect;
  55529. /**
  55530. * Creates an effect to be renderer
  55531. * @param creationOptions options to create the effect
  55532. */
  55533. constructor(creationOptions: EffectWrapperCreationOptions);
  55534. /**
  55535. * Disposes of the effect wrapper
  55536. */
  55537. dispose(): void;
  55538. }
  55539. }
  55540. declare module "babylonjs/Materials/index" {
  55541. export * from "babylonjs/Materials/Background/index";
  55542. export * from "babylonjs/Materials/colorCurves";
  55543. export * from "babylonjs/Materials/effect";
  55544. export * from "babylonjs/Materials/fresnelParameters";
  55545. export * from "babylonjs/Materials/imageProcessingConfiguration";
  55546. export * from "babylonjs/Materials/material";
  55547. export * from "babylonjs/Materials/materialDefines";
  55548. export * from "babylonjs/Materials/materialHelper";
  55549. export * from "babylonjs/Materials/multiMaterial";
  55550. export * from "babylonjs/Materials/PBR/index";
  55551. export * from "babylonjs/Materials/pushMaterial";
  55552. export * from "babylonjs/Materials/shaderMaterial";
  55553. export * from "babylonjs/Materials/standardMaterial";
  55554. export * from "babylonjs/Materials/Textures/index";
  55555. export * from "babylonjs/Materials/uniformBuffer";
  55556. export * from "babylonjs/Materials/materialFlags";
  55557. export * from "babylonjs/Materials/Node/index";
  55558. export * from "babylonjs/Materials/effectRenderer";
  55559. }
  55560. declare module "babylonjs/Maths/index" {
  55561. export * from "babylonjs/Maths/math.scalar";
  55562. export * from "babylonjs/Maths/math";
  55563. export * from "babylonjs/Maths/sphericalPolynomial";
  55564. }
  55565. declare module "babylonjs/Misc/workerPool" {
  55566. import { IDisposable } from "babylonjs/scene";
  55567. /**
  55568. * Helper class to push actions to a pool of workers.
  55569. */
  55570. export class WorkerPool implements IDisposable {
  55571. private _workerInfos;
  55572. private _pendingActions;
  55573. /**
  55574. * Constructor
  55575. * @param workers Array of workers to use for actions
  55576. */
  55577. constructor(workers: Array<Worker>);
  55578. /**
  55579. * Terminates all workers and clears any pending actions.
  55580. */
  55581. dispose(): void;
  55582. /**
  55583. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55584. * pended until a worker has completed its action.
  55585. * @param action The action to perform. Call onComplete when the action is complete.
  55586. */
  55587. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55588. private _execute;
  55589. }
  55590. }
  55591. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  55592. import { IDisposable } from "babylonjs/scene";
  55593. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55594. /**
  55595. * Configuration for Draco compression
  55596. */
  55597. export interface IDracoCompressionConfiguration {
  55598. /**
  55599. * Configuration for the decoder.
  55600. */
  55601. decoder: {
  55602. /**
  55603. * The url to the WebAssembly module.
  55604. */
  55605. wasmUrl?: string;
  55606. /**
  55607. * The url to the WebAssembly binary.
  55608. */
  55609. wasmBinaryUrl?: string;
  55610. /**
  55611. * The url to the fallback JavaScript module.
  55612. */
  55613. fallbackUrl?: string;
  55614. };
  55615. }
  55616. /**
  55617. * Draco compression (https://google.github.io/draco/)
  55618. *
  55619. * This class wraps the Draco module.
  55620. *
  55621. * **Encoder**
  55622. *
  55623. * The encoder is not currently implemented.
  55624. *
  55625. * **Decoder**
  55626. *
  55627. * 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.
  55628. *
  55629. * To update the configuration, use the following code:
  55630. * ```javascript
  55631. * DracoCompression.Configuration = {
  55632. * decoder: {
  55633. * wasmUrl: "<url to the WebAssembly library>",
  55634. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  55635. * fallbackUrl: "<url to the fallback JavaScript library>",
  55636. * }
  55637. * };
  55638. * ```
  55639. *
  55640. * 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.
  55641. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  55642. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  55643. *
  55644. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  55645. * ```javascript
  55646. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  55647. * ```
  55648. *
  55649. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  55650. */
  55651. export class DracoCompression implements IDisposable {
  55652. private _workerPoolPromise?;
  55653. private _decoderModulePromise?;
  55654. /**
  55655. * The configuration. Defaults to the following urls:
  55656. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  55657. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  55658. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  55659. */
  55660. static Configuration: IDracoCompressionConfiguration;
  55661. /**
  55662. * Returns true if the decoder configuration is available.
  55663. */
  55664. static readonly DecoderAvailable: boolean;
  55665. /**
  55666. * Default number of workers to create when creating the draco compression object.
  55667. */
  55668. static DefaultNumWorkers: number;
  55669. private static GetDefaultNumWorkers;
  55670. private static _Default;
  55671. /**
  55672. * Default instance for the draco compression object.
  55673. */
  55674. static readonly Default: DracoCompression;
  55675. /**
  55676. * Constructor
  55677. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  55678. */
  55679. constructor(numWorkers?: number);
  55680. /**
  55681. * Stop all async operations and release resources.
  55682. */
  55683. dispose(): void;
  55684. /**
  55685. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  55686. * @returns a promise that resolves when ready
  55687. */
  55688. whenReadyAsync(): Promise<void>;
  55689. /**
  55690. * Decode Draco compressed mesh data to vertex data.
  55691. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  55692. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  55693. * @returns A promise that resolves with the decoded vertex data
  55694. */
  55695. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  55696. [kind: string]: number;
  55697. }): Promise<VertexData>;
  55698. }
  55699. }
  55700. declare module "babylonjs/Meshes/Compression/index" {
  55701. export * from "babylonjs/Meshes/Compression/dracoCompression";
  55702. }
  55703. declare module "babylonjs/Meshes/csg" {
  55704. import { Nullable } from "babylonjs/types";
  55705. import { Scene } from "babylonjs/scene";
  55706. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55707. import { Mesh } from "babylonjs/Meshes/mesh";
  55708. import { Material } from "babylonjs/Materials/material";
  55709. /**
  55710. * Class for building Constructive Solid Geometry
  55711. */
  55712. export class CSG {
  55713. private polygons;
  55714. /**
  55715. * The world matrix
  55716. */
  55717. matrix: Matrix;
  55718. /**
  55719. * Stores the position
  55720. */
  55721. position: Vector3;
  55722. /**
  55723. * Stores the rotation
  55724. */
  55725. rotation: Vector3;
  55726. /**
  55727. * Stores the rotation quaternion
  55728. */
  55729. rotationQuaternion: Nullable<Quaternion>;
  55730. /**
  55731. * Stores the scaling vector
  55732. */
  55733. scaling: Vector3;
  55734. /**
  55735. * Convert the Mesh to CSG
  55736. * @param mesh The Mesh to convert to CSG
  55737. * @returns A new CSG from the Mesh
  55738. */
  55739. static FromMesh(mesh: Mesh): CSG;
  55740. /**
  55741. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  55742. * @param polygons Polygons used to construct a CSG solid
  55743. */
  55744. private static FromPolygons;
  55745. /**
  55746. * Clones, or makes a deep copy, of the CSG
  55747. * @returns A new CSG
  55748. */
  55749. clone(): CSG;
  55750. /**
  55751. * Unions this CSG with another CSG
  55752. * @param csg The CSG to union against this CSG
  55753. * @returns The unioned CSG
  55754. */
  55755. union(csg: CSG): CSG;
  55756. /**
  55757. * Unions this CSG with another CSG in place
  55758. * @param csg The CSG to union against this CSG
  55759. */
  55760. unionInPlace(csg: CSG): void;
  55761. /**
  55762. * Subtracts this CSG with another CSG
  55763. * @param csg The CSG to subtract against this CSG
  55764. * @returns A new CSG
  55765. */
  55766. subtract(csg: CSG): CSG;
  55767. /**
  55768. * Subtracts this CSG with another CSG in place
  55769. * @param csg The CSG to subtact against this CSG
  55770. */
  55771. subtractInPlace(csg: CSG): void;
  55772. /**
  55773. * Intersect this CSG with another CSG
  55774. * @param csg The CSG to intersect against this CSG
  55775. * @returns A new CSG
  55776. */
  55777. intersect(csg: CSG): CSG;
  55778. /**
  55779. * Intersects this CSG with another CSG in place
  55780. * @param csg The CSG to intersect against this CSG
  55781. */
  55782. intersectInPlace(csg: CSG): void;
  55783. /**
  55784. * Return a new CSG solid with solid and empty space switched. This solid is
  55785. * not modified.
  55786. * @returns A new CSG solid with solid and empty space switched
  55787. */
  55788. inverse(): CSG;
  55789. /**
  55790. * Inverses the CSG in place
  55791. */
  55792. inverseInPlace(): void;
  55793. /**
  55794. * This is used to keep meshes transformations so they can be restored
  55795. * when we build back a Babylon Mesh
  55796. * NB : All CSG operations are performed in world coordinates
  55797. * @param csg The CSG to copy the transform attributes from
  55798. * @returns This CSG
  55799. */
  55800. copyTransformAttributes(csg: CSG): CSG;
  55801. /**
  55802. * Build Raw mesh from CSG
  55803. * Coordinates here are in world space
  55804. * @param name The name of the mesh geometry
  55805. * @param scene The Scene
  55806. * @param keepSubMeshes Specifies if the submeshes should be kept
  55807. * @returns A new Mesh
  55808. */
  55809. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55810. /**
  55811. * Build Mesh from CSG taking material and transforms into account
  55812. * @param name The name of the Mesh
  55813. * @param material The material of the Mesh
  55814. * @param scene The Scene
  55815. * @param keepSubMeshes Specifies if submeshes should be kept
  55816. * @returns The new Mesh
  55817. */
  55818. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55819. }
  55820. }
  55821. declare module "babylonjs/Meshes/trailMesh" {
  55822. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55823. import { Mesh } from "babylonjs/Meshes/mesh";
  55824. import { Scene } from "babylonjs/scene";
  55825. /**
  55826. * Class used to create a trail following a mesh
  55827. */
  55828. export class TrailMesh extends Mesh {
  55829. private _generator;
  55830. private _autoStart;
  55831. private _running;
  55832. private _diameter;
  55833. private _length;
  55834. private _sectionPolygonPointsCount;
  55835. private _sectionVectors;
  55836. private _sectionNormalVectors;
  55837. private _beforeRenderObserver;
  55838. /**
  55839. * @constructor
  55840. * @param name The value used by scene.getMeshByName() to do a lookup.
  55841. * @param generator The mesh to generate a trail.
  55842. * @param scene The scene to add this mesh to.
  55843. * @param diameter Diameter of trailing mesh. Default is 1.
  55844. * @param length Length of trailing mesh. Default is 60.
  55845. * @param autoStart Automatically start trailing mesh. Default true.
  55846. */
  55847. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55848. /**
  55849. * "TrailMesh"
  55850. * @returns "TrailMesh"
  55851. */
  55852. getClassName(): string;
  55853. private _createMesh;
  55854. /**
  55855. * Start trailing mesh.
  55856. */
  55857. start(): void;
  55858. /**
  55859. * Stop trailing mesh.
  55860. */
  55861. stop(): void;
  55862. /**
  55863. * Update trailing mesh geometry.
  55864. */
  55865. update(): void;
  55866. /**
  55867. * Returns a new TrailMesh object.
  55868. * @param name is a string, the name given to the new mesh
  55869. * @param newGenerator use new generator object for cloned trail mesh
  55870. * @returns a new mesh
  55871. */
  55872. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55873. /**
  55874. * Serializes this trail mesh
  55875. * @param serializationObject object to write serialization to
  55876. */
  55877. serialize(serializationObject: any): void;
  55878. /**
  55879. * Parses a serialized trail mesh
  55880. * @param parsedMesh the serialized mesh
  55881. * @param scene the scene to create the trail mesh in
  55882. * @returns the created trail mesh
  55883. */
  55884. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55885. }
  55886. }
  55887. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55888. import { Nullable } from "babylonjs/types";
  55889. import { Scene } from "babylonjs/scene";
  55890. import { Vector4 } from "babylonjs/Maths/math.vector";
  55891. import { Color4 } from "babylonjs/Maths/math.color";
  55892. import { Mesh } from "babylonjs/Meshes/mesh";
  55893. /**
  55894. * Class containing static functions to help procedurally build meshes
  55895. */
  55896. export class TiledBoxBuilder {
  55897. /**
  55898. * Creates a box mesh
  55899. * 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)
  55900. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55904. * @param name defines the name of the mesh
  55905. * @param options defines the options used to create the mesh
  55906. * @param scene defines the hosting scene
  55907. * @returns the box mesh
  55908. */
  55909. static CreateTiledBox(name: string, options: {
  55910. pattern?: number;
  55911. width?: number;
  55912. height?: number;
  55913. depth?: number;
  55914. tileSize?: number;
  55915. tileWidth?: number;
  55916. tileHeight?: number;
  55917. alignHorizontal?: number;
  55918. alignVertical?: number;
  55919. faceUV?: Vector4[];
  55920. faceColors?: Color4[];
  55921. sideOrientation?: number;
  55922. updatable?: boolean;
  55923. }, scene?: Nullable<Scene>): Mesh;
  55924. }
  55925. }
  55926. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55927. import { Vector4 } from "babylonjs/Maths/math.vector";
  55928. import { Mesh } from "babylonjs/Meshes/mesh";
  55929. /**
  55930. * Class containing static functions to help procedurally build meshes
  55931. */
  55932. export class TorusKnotBuilder {
  55933. /**
  55934. * Creates a torus knot mesh
  55935. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55936. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55937. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55938. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55942. * @param name defines the name of the mesh
  55943. * @param options defines the options used to create the mesh
  55944. * @param scene defines the hosting scene
  55945. * @returns the torus knot mesh
  55946. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55947. */
  55948. static CreateTorusKnot(name: string, options: {
  55949. radius?: number;
  55950. tube?: number;
  55951. radialSegments?: number;
  55952. tubularSegments?: number;
  55953. p?: number;
  55954. q?: number;
  55955. updatable?: boolean;
  55956. sideOrientation?: number;
  55957. frontUVs?: Vector4;
  55958. backUVs?: Vector4;
  55959. }, scene: any): Mesh;
  55960. }
  55961. }
  55962. declare module "babylonjs/Meshes/polygonMesh" {
  55963. import { Scene } from "babylonjs/scene";
  55964. import { Vector2 } from "babylonjs/Maths/math.vector";
  55965. import { Mesh } from "babylonjs/Meshes/mesh";
  55966. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55967. import { Path2 } from "babylonjs/Maths/math.path";
  55968. /**
  55969. * Polygon
  55970. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55971. */
  55972. export class Polygon {
  55973. /**
  55974. * Creates a rectangle
  55975. * @param xmin bottom X coord
  55976. * @param ymin bottom Y coord
  55977. * @param xmax top X coord
  55978. * @param ymax top Y coord
  55979. * @returns points that make the resulting rectation
  55980. */
  55981. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55982. /**
  55983. * Creates a circle
  55984. * @param radius radius of circle
  55985. * @param cx scale in x
  55986. * @param cy scale in y
  55987. * @param numberOfSides number of sides that make up the circle
  55988. * @returns points that make the resulting circle
  55989. */
  55990. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55991. /**
  55992. * Creates a polygon from input string
  55993. * @param input Input polygon data
  55994. * @returns the parsed points
  55995. */
  55996. static Parse(input: string): Vector2[];
  55997. /**
  55998. * Starts building a polygon from x and y coordinates
  55999. * @param x x coordinate
  56000. * @param y y coordinate
  56001. * @returns the started path2
  56002. */
  56003. static StartingAt(x: number, y: number): Path2;
  56004. }
  56005. /**
  56006. * Builds a polygon
  56007. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  56008. */
  56009. export class PolygonMeshBuilder {
  56010. private _points;
  56011. private _outlinepoints;
  56012. private _holes;
  56013. private _name;
  56014. private _scene;
  56015. private _epoints;
  56016. private _eholes;
  56017. private _addToepoint;
  56018. /**
  56019. * Babylon reference to the earcut plugin.
  56020. */
  56021. bjsEarcut: any;
  56022. /**
  56023. * Creates a PolygonMeshBuilder
  56024. * @param name name of the builder
  56025. * @param contours Path of the polygon
  56026. * @param scene scene to add to when creating the mesh
  56027. * @param earcutInjection can be used to inject your own earcut reference
  56028. */
  56029. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  56030. /**
  56031. * Adds a whole within the polygon
  56032. * @param hole Array of points defining the hole
  56033. * @returns this
  56034. */
  56035. addHole(hole: Vector2[]): PolygonMeshBuilder;
  56036. /**
  56037. * Creates the polygon
  56038. * @param updatable If the mesh should be updatable
  56039. * @param depth The depth of the mesh created
  56040. * @returns the created mesh
  56041. */
  56042. build(updatable?: boolean, depth?: number): Mesh;
  56043. /**
  56044. * Creates the polygon
  56045. * @param depth The depth of the mesh created
  56046. * @returns the created VertexData
  56047. */
  56048. buildVertexData(depth?: number): VertexData;
  56049. /**
  56050. * Adds a side to the polygon
  56051. * @param positions points that make the polygon
  56052. * @param normals normals of the polygon
  56053. * @param uvs uvs of the polygon
  56054. * @param indices indices of the polygon
  56055. * @param bounds bounds of the polygon
  56056. * @param points points of the polygon
  56057. * @param depth depth of the polygon
  56058. * @param flip flip of the polygon
  56059. */
  56060. private addSide;
  56061. }
  56062. }
  56063. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  56064. import { Scene } from "babylonjs/scene";
  56065. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56066. import { Color4 } from "babylonjs/Maths/math.color";
  56067. import { Mesh } from "babylonjs/Meshes/mesh";
  56068. import { Nullable } from "babylonjs/types";
  56069. /**
  56070. * Class containing static functions to help procedurally build meshes
  56071. */
  56072. export class PolygonBuilder {
  56073. /**
  56074. * Creates a polygon mesh
  56075. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56076. * * 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
  56077. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56080. * * Remember you can only change the shape positions, not their number when updating a polygon
  56081. * @param name defines the name of the mesh
  56082. * @param options defines the options used to create the mesh
  56083. * @param scene defines the hosting scene
  56084. * @param earcutInjection can be used to inject your own earcut reference
  56085. * @returns the polygon mesh
  56086. */
  56087. static CreatePolygon(name: string, options: {
  56088. shape: Vector3[];
  56089. holes?: Vector3[][];
  56090. depth?: number;
  56091. faceUV?: Vector4[];
  56092. faceColors?: Color4[];
  56093. updatable?: boolean;
  56094. sideOrientation?: number;
  56095. frontUVs?: Vector4;
  56096. backUVs?: Vector4;
  56097. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56098. /**
  56099. * Creates an extruded polygon mesh, with depth in the Y direction.
  56100. * * 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)
  56101. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56102. * @param name defines the name of the mesh
  56103. * @param options defines the options used to create the mesh
  56104. * @param scene defines the hosting scene
  56105. * @param earcutInjection can be used to inject your own earcut reference
  56106. * @returns the polygon mesh
  56107. */
  56108. static ExtrudePolygon(name: string, options: {
  56109. shape: Vector3[];
  56110. holes?: Vector3[][];
  56111. depth?: number;
  56112. faceUV?: Vector4[];
  56113. faceColors?: Color4[];
  56114. updatable?: boolean;
  56115. sideOrientation?: number;
  56116. frontUVs?: Vector4;
  56117. backUVs?: Vector4;
  56118. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56119. }
  56120. }
  56121. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  56122. import { Scene } from "babylonjs/scene";
  56123. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56124. import { Mesh } from "babylonjs/Meshes/mesh";
  56125. import { Nullable } from "babylonjs/types";
  56126. /**
  56127. * Class containing static functions to help procedurally build meshes
  56128. */
  56129. export class LatheBuilder {
  56130. /**
  56131. * Creates lathe mesh.
  56132. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56133. * * 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
  56134. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56135. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56136. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56137. * * 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
  56138. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56139. * * 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
  56140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56141. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56144. * @param name defines the name of the mesh
  56145. * @param options defines the options used to create the mesh
  56146. * @param scene defines the hosting scene
  56147. * @returns the lathe mesh
  56148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56149. */
  56150. static CreateLathe(name: string, options: {
  56151. shape: Vector3[];
  56152. radius?: number;
  56153. tessellation?: number;
  56154. clip?: number;
  56155. arc?: number;
  56156. closed?: boolean;
  56157. updatable?: boolean;
  56158. sideOrientation?: number;
  56159. frontUVs?: Vector4;
  56160. backUVs?: Vector4;
  56161. cap?: number;
  56162. invertUV?: boolean;
  56163. }, scene?: Nullable<Scene>): Mesh;
  56164. }
  56165. }
  56166. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  56167. import { Nullable } from "babylonjs/types";
  56168. import { Scene } from "babylonjs/scene";
  56169. import { Vector4 } from "babylonjs/Maths/math.vector";
  56170. import { Mesh } from "babylonjs/Meshes/mesh";
  56171. /**
  56172. * Class containing static functions to help procedurally build meshes
  56173. */
  56174. export class TiledPlaneBuilder {
  56175. /**
  56176. * Creates a tiled plane mesh
  56177. * * The parameter `pattern` will, depending on value, do nothing or
  56178. * * * flip (reflect about central vertical) alternate tiles across and up
  56179. * * * flip every tile on alternate rows
  56180. * * * rotate (180 degs) alternate tiles across and up
  56181. * * * rotate every tile on alternate rows
  56182. * * * flip and rotate alternate tiles across and up
  56183. * * * flip and rotate every tile on alternate rows
  56184. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  56185. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  56186. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56187. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56188. * * 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)
  56189. * * 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)
  56190. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56191. * @param name defines the name of the mesh
  56192. * @param options defines the options used to create the mesh
  56193. * @param scene defines the hosting scene
  56194. * @returns the box mesh
  56195. */
  56196. static CreateTiledPlane(name: string, options: {
  56197. pattern?: number;
  56198. tileSize?: number;
  56199. tileWidth?: number;
  56200. tileHeight?: number;
  56201. size?: number;
  56202. width?: number;
  56203. height?: number;
  56204. alignHorizontal?: number;
  56205. alignVertical?: number;
  56206. sideOrientation?: number;
  56207. frontUVs?: Vector4;
  56208. backUVs?: Vector4;
  56209. updatable?: boolean;
  56210. }, scene?: Nullable<Scene>): Mesh;
  56211. }
  56212. }
  56213. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  56214. import { Nullable } from "babylonjs/types";
  56215. import { Scene } from "babylonjs/scene";
  56216. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56217. import { Mesh } from "babylonjs/Meshes/mesh";
  56218. /**
  56219. * Class containing static functions to help procedurally build meshes
  56220. */
  56221. export class TubeBuilder {
  56222. /**
  56223. * Creates a tube mesh.
  56224. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56225. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56226. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56227. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56228. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56229. * * 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)
  56230. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56231. * * 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
  56232. * * 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
  56233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56237. * @param name defines the name of the mesh
  56238. * @param options defines the options used to create the mesh
  56239. * @param scene defines the hosting scene
  56240. * @returns the tube mesh
  56241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56242. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56243. */
  56244. static CreateTube(name: string, options: {
  56245. path: Vector3[];
  56246. radius?: number;
  56247. tessellation?: number;
  56248. radiusFunction?: {
  56249. (i: number, distance: number): number;
  56250. };
  56251. cap?: number;
  56252. arc?: number;
  56253. updatable?: boolean;
  56254. sideOrientation?: number;
  56255. frontUVs?: Vector4;
  56256. backUVs?: Vector4;
  56257. instance?: Mesh;
  56258. invertUV?: boolean;
  56259. }, scene?: Nullable<Scene>): Mesh;
  56260. }
  56261. }
  56262. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  56263. import { Scene } from "babylonjs/scene";
  56264. import { Vector4 } from "babylonjs/Maths/math.vector";
  56265. import { Mesh } from "babylonjs/Meshes/mesh";
  56266. import { Nullable } from "babylonjs/types";
  56267. /**
  56268. * Class containing static functions to help procedurally build meshes
  56269. */
  56270. export class IcoSphereBuilder {
  56271. /**
  56272. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56273. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56274. * * 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`)
  56275. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56276. * * 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
  56277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56278. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56280. * @param name defines the name of the mesh
  56281. * @param options defines the options used to create the mesh
  56282. * @param scene defines the hosting scene
  56283. * @returns the icosahedron mesh
  56284. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56285. */
  56286. static CreateIcoSphere(name: string, options: {
  56287. radius?: number;
  56288. radiusX?: number;
  56289. radiusY?: number;
  56290. radiusZ?: number;
  56291. flat?: boolean;
  56292. subdivisions?: number;
  56293. sideOrientation?: number;
  56294. frontUVs?: Vector4;
  56295. backUVs?: Vector4;
  56296. updatable?: boolean;
  56297. }, scene?: Nullable<Scene>): Mesh;
  56298. }
  56299. }
  56300. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  56301. import { Vector3 } from "babylonjs/Maths/math.vector";
  56302. import { Mesh } from "babylonjs/Meshes/mesh";
  56303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56304. /**
  56305. * Class containing static functions to help procedurally build meshes
  56306. */
  56307. export class DecalBuilder {
  56308. /**
  56309. * Creates a decal mesh.
  56310. * 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
  56311. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56312. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56313. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56314. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56315. * @param name defines the name of the mesh
  56316. * @param sourceMesh defines the mesh where the decal must be applied
  56317. * @param options defines the options used to create the mesh
  56318. * @param scene defines the hosting scene
  56319. * @returns the decal mesh
  56320. * @see https://doc.babylonjs.com/how_to/decals
  56321. */
  56322. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56323. position?: Vector3;
  56324. normal?: Vector3;
  56325. size?: Vector3;
  56326. angle?: number;
  56327. }): Mesh;
  56328. }
  56329. }
  56330. declare module "babylonjs/Meshes/meshBuilder" {
  56331. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  56332. import { Nullable } from "babylonjs/types";
  56333. import { Scene } from "babylonjs/scene";
  56334. import { Mesh } from "babylonjs/Meshes/mesh";
  56335. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56336. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  56337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56338. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56339. import { Plane } from "babylonjs/Maths/math.plane";
  56340. /**
  56341. * Class containing static functions to help procedurally build meshes
  56342. */
  56343. export class MeshBuilder {
  56344. /**
  56345. * Creates a box mesh
  56346. * * The parameter `size` sets the size (float) of each box side (default 1)
  56347. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56348. * * 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)
  56349. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56353. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56354. * @param name defines the name of the mesh
  56355. * @param options defines the options used to create the mesh
  56356. * @param scene defines the hosting scene
  56357. * @returns the box mesh
  56358. */
  56359. static CreateBox(name: string, options: {
  56360. size?: number;
  56361. width?: number;
  56362. height?: number;
  56363. depth?: number;
  56364. faceUV?: Vector4[];
  56365. faceColors?: Color4[];
  56366. sideOrientation?: number;
  56367. frontUVs?: Vector4;
  56368. backUVs?: Vector4;
  56369. updatable?: boolean;
  56370. }, scene?: Nullable<Scene>): Mesh;
  56371. /**
  56372. * Creates a tiled box mesh
  56373. * * faceTiles sets the pattern, tile size and number of tiles for a face
  56374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56375. * @param name defines the name of the mesh
  56376. * @param options defines the options used to create the mesh
  56377. * @param scene defines the hosting scene
  56378. * @returns the tiled box mesh
  56379. */
  56380. static CreateTiledBox(name: string, options: {
  56381. pattern?: number;
  56382. size?: number;
  56383. width?: number;
  56384. height?: number;
  56385. depth: number;
  56386. tileSize?: number;
  56387. tileWidth?: number;
  56388. tileHeight?: number;
  56389. faceUV?: Vector4[];
  56390. faceColors?: Color4[];
  56391. alignHorizontal?: number;
  56392. alignVertical?: number;
  56393. sideOrientation?: number;
  56394. updatable?: boolean;
  56395. }, scene?: Nullable<Scene>): Mesh;
  56396. /**
  56397. * Creates a sphere mesh
  56398. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  56399. * * 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`)
  56400. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  56401. * * 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
  56402. * * 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)
  56403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56406. * @param name defines the name of the mesh
  56407. * @param options defines the options used to create the mesh
  56408. * @param scene defines the hosting scene
  56409. * @returns the sphere mesh
  56410. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  56411. */
  56412. static CreateSphere(name: string, options: {
  56413. segments?: number;
  56414. diameter?: number;
  56415. diameterX?: number;
  56416. diameterY?: number;
  56417. diameterZ?: number;
  56418. arc?: number;
  56419. slice?: number;
  56420. sideOrientation?: number;
  56421. frontUVs?: Vector4;
  56422. backUVs?: Vector4;
  56423. updatable?: boolean;
  56424. }, scene?: Nullable<Scene>): Mesh;
  56425. /**
  56426. * Creates a plane polygonal mesh. By default, this is a disc
  56427. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  56428. * * 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
  56429. * * 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
  56430. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56431. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56433. * @param name defines the name of the mesh
  56434. * @param options defines the options used to create the mesh
  56435. * @param scene defines the hosting scene
  56436. * @returns the plane polygonal mesh
  56437. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  56438. */
  56439. static CreateDisc(name: string, options: {
  56440. radius?: number;
  56441. tessellation?: number;
  56442. arc?: number;
  56443. updatable?: boolean;
  56444. sideOrientation?: number;
  56445. frontUVs?: Vector4;
  56446. backUVs?: Vector4;
  56447. }, scene?: Nullable<Scene>): Mesh;
  56448. /**
  56449. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  56450. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  56451. * * 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`)
  56452. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  56453. * * 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
  56454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56457. * @param name defines the name of the mesh
  56458. * @param options defines the options used to create the mesh
  56459. * @param scene defines the hosting scene
  56460. * @returns the icosahedron mesh
  56461. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  56462. */
  56463. static CreateIcoSphere(name: string, options: {
  56464. radius?: number;
  56465. radiusX?: number;
  56466. radiusY?: number;
  56467. radiusZ?: number;
  56468. flat?: boolean;
  56469. subdivisions?: number;
  56470. sideOrientation?: number;
  56471. frontUVs?: Vector4;
  56472. backUVs?: Vector4;
  56473. updatable?: boolean;
  56474. }, scene?: Nullable<Scene>): Mesh;
  56475. /**
  56476. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56477. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56478. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56479. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56480. * * 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
  56481. * * 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
  56482. * * 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
  56483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56485. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56486. * * 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
  56487. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56488. * * 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
  56489. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56491. * @param name defines the name of the mesh
  56492. * @param options defines the options used to create the mesh
  56493. * @param scene defines the hosting scene
  56494. * @returns the ribbon mesh
  56495. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56497. */
  56498. static CreateRibbon(name: string, options: {
  56499. pathArray: Vector3[][];
  56500. closeArray?: boolean;
  56501. closePath?: boolean;
  56502. offset?: number;
  56503. updatable?: boolean;
  56504. sideOrientation?: number;
  56505. frontUVs?: Vector4;
  56506. backUVs?: Vector4;
  56507. instance?: Mesh;
  56508. invertUV?: boolean;
  56509. uvs?: Vector2[];
  56510. colors?: Color4[];
  56511. }, scene?: Nullable<Scene>): Mesh;
  56512. /**
  56513. * Creates a cylinder or a cone mesh
  56514. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  56515. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  56516. * * 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.
  56517. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  56518. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  56519. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  56520. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  56521. * * 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).
  56522. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  56523. * * 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).
  56524. * * 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
  56525. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  56526. * * 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
  56527. * * 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.
  56528. * * If `enclose` is false, a ring surface is one element.
  56529. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  56530. * * 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
  56531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56532. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56534. * @param name defines the name of the mesh
  56535. * @param options defines the options used to create the mesh
  56536. * @param scene defines the hosting scene
  56537. * @returns the cylinder mesh
  56538. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  56539. */
  56540. static CreateCylinder(name: string, options: {
  56541. height?: number;
  56542. diameterTop?: number;
  56543. diameterBottom?: number;
  56544. diameter?: number;
  56545. tessellation?: number;
  56546. subdivisions?: number;
  56547. arc?: number;
  56548. faceColors?: Color4[];
  56549. faceUV?: Vector4[];
  56550. updatable?: boolean;
  56551. hasRings?: boolean;
  56552. enclose?: boolean;
  56553. cap?: number;
  56554. sideOrientation?: number;
  56555. frontUVs?: Vector4;
  56556. backUVs?: Vector4;
  56557. }, scene?: Nullable<Scene>): Mesh;
  56558. /**
  56559. * Creates a torus mesh
  56560. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  56561. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  56562. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  56563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56564. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56566. * @param name defines the name of the mesh
  56567. * @param options defines the options used to create the mesh
  56568. * @param scene defines the hosting scene
  56569. * @returns the torus mesh
  56570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  56571. */
  56572. static CreateTorus(name: string, options: {
  56573. diameter?: number;
  56574. thickness?: number;
  56575. tessellation?: number;
  56576. updatable?: boolean;
  56577. sideOrientation?: number;
  56578. frontUVs?: Vector4;
  56579. backUVs?: Vector4;
  56580. }, scene?: Nullable<Scene>): Mesh;
  56581. /**
  56582. * Creates a torus knot mesh
  56583. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  56584. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  56585. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  56586. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  56587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56590. * @param name defines the name of the mesh
  56591. * @param options defines the options used to create the mesh
  56592. * @param scene defines the hosting scene
  56593. * @returns the torus knot mesh
  56594. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  56595. */
  56596. static CreateTorusKnot(name: string, options: {
  56597. radius?: number;
  56598. tube?: number;
  56599. radialSegments?: number;
  56600. tubularSegments?: number;
  56601. p?: number;
  56602. q?: number;
  56603. updatable?: boolean;
  56604. sideOrientation?: number;
  56605. frontUVs?: Vector4;
  56606. backUVs?: Vector4;
  56607. }, scene?: Nullable<Scene>): Mesh;
  56608. /**
  56609. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  56610. * * 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
  56611. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  56612. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  56613. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  56614. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  56615. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  56616. * * 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
  56617. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  56618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56619. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  56620. * @param name defines the name of the new line system
  56621. * @param options defines the options used to create the line system
  56622. * @param scene defines the hosting scene
  56623. * @returns a new line system mesh
  56624. */
  56625. static CreateLineSystem(name: string, options: {
  56626. lines: Vector3[][];
  56627. updatable?: boolean;
  56628. instance?: Nullable<LinesMesh>;
  56629. colors?: Nullable<Color4[][]>;
  56630. useVertexAlpha?: boolean;
  56631. }, scene: Nullable<Scene>): LinesMesh;
  56632. /**
  56633. * Creates a line mesh
  56634. * 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
  56635. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56636. * * The parameter `points` is an array successive Vector3
  56637. * * 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
  56638. * * The optional parameter `colors` is an array of successive Color4, one per line point
  56639. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  56640. * * When updating an instance, remember that only point positions can change, not the number of points
  56641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  56643. * @param name defines the name of the new line system
  56644. * @param options defines the options used to create the line system
  56645. * @param scene defines the hosting scene
  56646. * @returns a new line mesh
  56647. */
  56648. static CreateLines(name: string, options: {
  56649. points: Vector3[];
  56650. updatable?: boolean;
  56651. instance?: Nullable<LinesMesh>;
  56652. colors?: Color4[];
  56653. useVertexAlpha?: boolean;
  56654. }, scene?: Nullable<Scene>): LinesMesh;
  56655. /**
  56656. * Creates a dashed line mesh
  56657. * * 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
  56658. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  56659. * * The parameter `points` is an array successive Vector3
  56660. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  56661. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  56662. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  56663. * * 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
  56664. * * When updating an instance, remember that only point positions can change, not the number of points
  56665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56666. * @param name defines the name of the mesh
  56667. * @param options defines the options used to create the mesh
  56668. * @param scene defines the hosting scene
  56669. * @returns the dashed line mesh
  56670. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  56671. */
  56672. static CreateDashedLines(name: string, options: {
  56673. points: Vector3[];
  56674. dashSize?: number;
  56675. gapSize?: number;
  56676. dashNb?: number;
  56677. updatable?: boolean;
  56678. instance?: LinesMesh;
  56679. }, scene?: Nullable<Scene>): LinesMesh;
  56680. /**
  56681. * 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.
  56682. * * 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.
  56683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56684. * * 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.
  56685. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56686. * * 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
  56687. * * 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
  56688. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56689. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56690. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56691. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56693. * @param name defines the name of the mesh
  56694. * @param options defines the options used to create the mesh
  56695. * @param scene defines the hosting scene
  56696. * @returns the extruded shape mesh
  56697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56698. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56699. */
  56700. static ExtrudeShape(name: string, options: {
  56701. shape: Vector3[];
  56702. path: Vector3[];
  56703. scale?: number;
  56704. rotation?: number;
  56705. cap?: number;
  56706. updatable?: boolean;
  56707. sideOrientation?: number;
  56708. frontUVs?: Vector4;
  56709. backUVs?: Vector4;
  56710. instance?: Mesh;
  56711. invertUV?: boolean;
  56712. }, scene?: Nullable<Scene>): Mesh;
  56713. /**
  56714. * Creates an custom extruded shape mesh.
  56715. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56716. * * 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.
  56717. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56718. * * 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
  56719. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56720. * * 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
  56721. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56722. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56723. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56724. * * 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
  56725. * * 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
  56726. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56727. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56728. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56729. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56730. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56731. * @param name defines the name of the mesh
  56732. * @param options defines the options used to create the mesh
  56733. * @param scene defines the hosting scene
  56734. * @returns the custom extruded shape mesh
  56735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56736. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56737. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56738. */
  56739. static ExtrudeShapeCustom(name: string, options: {
  56740. shape: Vector3[];
  56741. path: Vector3[];
  56742. scaleFunction?: any;
  56743. rotationFunction?: any;
  56744. ribbonCloseArray?: boolean;
  56745. ribbonClosePath?: boolean;
  56746. cap?: number;
  56747. updatable?: boolean;
  56748. sideOrientation?: number;
  56749. frontUVs?: Vector4;
  56750. backUVs?: Vector4;
  56751. instance?: Mesh;
  56752. invertUV?: boolean;
  56753. }, scene?: Nullable<Scene>): Mesh;
  56754. /**
  56755. * Creates lathe mesh.
  56756. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  56757. * * 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
  56758. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  56759. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  56760. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  56761. * * 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
  56762. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  56763. * * 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
  56764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56766. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56768. * @param name defines the name of the mesh
  56769. * @param options defines the options used to create the mesh
  56770. * @param scene defines the hosting scene
  56771. * @returns the lathe mesh
  56772. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  56773. */
  56774. static CreateLathe(name: string, options: {
  56775. shape: Vector3[];
  56776. radius?: number;
  56777. tessellation?: number;
  56778. clip?: number;
  56779. arc?: number;
  56780. closed?: boolean;
  56781. updatable?: boolean;
  56782. sideOrientation?: number;
  56783. frontUVs?: Vector4;
  56784. backUVs?: Vector4;
  56785. cap?: number;
  56786. invertUV?: boolean;
  56787. }, scene?: Nullable<Scene>): Mesh;
  56788. /**
  56789. * Creates a tiled plane mesh
  56790. * * You can set a limited pattern arrangement with the tiles
  56791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56794. * @param name defines the name of the mesh
  56795. * @param options defines the options used to create the mesh
  56796. * @param scene defines the hosting scene
  56797. * @returns the plane mesh
  56798. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56799. */
  56800. static CreateTiledPlane(name: string, options: {
  56801. pattern?: number;
  56802. tileSize?: number;
  56803. tileWidth?: number;
  56804. tileHeight?: number;
  56805. size?: number;
  56806. width?: number;
  56807. height?: number;
  56808. alignHorizontal?: number;
  56809. alignVertical?: number;
  56810. sideOrientation?: number;
  56811. frontUVs?: Vector4;
  56812. backUVs?: Vector4;
  56813. updatable?: boolean;
  56814. }, scene?: Nullable<Scene>): Mesh;
  56815. /**
  56816. * Creates a plane mesh
  56817. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56818. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56819. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56823. * @param name defines the name of the mesh
  56824. * @param options defines the options used to create the mesh
  56825. * @param scene defines the hosting scene
  56826. * @returns the plane mesh
  56827. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56828. */
  56829. static CreatePlane(name: string, options: {
  56830. size?: number;
  56831. width?: number;
  56832. height?: number;
  56833. sideOrientation?: number;
  56834. frontUVs?: Vector4;
  56835. backUVs?: Vector4;
  56836. updatable?: boolean;
  56837. sourcePlane?: Plane;
  56838. }, scene?: Nullable<Scene>): Mesh;
  56839. /**
  56840. * Creates a ground mesh
  56841. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56842. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56844. * @param name defines the name of the mesh
  56845. * @param options defines the options used to create the mesh
  56846. * @param scene defines the hosting scene
  56847. * @returns the ground mesh
  56848. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56849. */
  56850. static CreateGround(name: string, options: {
  56851. width?: number;
  56852. height?: number;
  56853. subdivisions?: number;
  56854. subdivisionsX?: number;
  56855. subdivisionsY?: number;
  56856. updatable?: boolean;
  56857. }, scene?: Nullable<Scene>): Mesh;
  56858. /**
  56859. * Creates a tiled ground mesh
  56860. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56861. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56862. * * 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
  56863. * * 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
  56864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56865. * @param name defines the name of the mesh
  56866. * @param options defines the options used to create the mesh
  56867. * @param scene defines the hosting scene
  56868. * @returns the tiled ground mesh
  56869. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56870. */
  56871. static CreateTiledGround(name: string, options: {
  56872. xmin: number;
  56873. zmin: number;
  56874. xmax: number;
  56875. zmax: number;
  56876. subdivisions?: {
  56877. w: number;
  56878. h: number;
  56879. };
  56880. precision?: {
  56881. w: number;
  56882. h: number;
  56883. };
  56884. updatable?: boolean;
  56885. }, scene?: Nullable<Scene>): Mesh;
  56886. /**
  56887. * Creates a ground mesh from a height map
  56888. * * The parameter `url` sets the URL of the height map image resource.
  56889. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56890. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56891. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56892. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56893. * * 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.
  56894. * * 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).
  56895. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56897. * @param name defines the name of the mesh
  56898. * @param url defines the url to the height map
  56899. * @param options defines the options used to create the mesh
  56900. * @param scene defines the hosting scene
  56901. * @returns the ground mesh
  56902. * @see https://doc.babylonjs.com/babylon101/height_map
  56903. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56904. */
  56905. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56906. width?: number;
  56907. height?: number;
  56908. subdivisions?: number;
  56909. minHeight?: number;
  56910. maxHeight?: number;
  56911. colorFilter?: Color3;
  56912. alphaFilter?: number;
  56913. updatable?: boolean;
  56914. onReady?: (mesh: GroundMesh) => void;
  56915. }, scene?: Nullable<Scene>): GroundMesh;
  56916. /**
  56917. * Creates a polygon mesh
  56918. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56919. * * 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
  56920. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56923. * * Remember you can only change the shape positions, not their number when updating a polygon
  56924. * @param name defines the name of the mesh
  56925. * @param options defines the options used to create the mesh
  56926. * @param scene defines the hosting scene
  56927. * @param earcutInjection can be used to inject your own earcut reference
  56928. * @returns the polygon mesh
  56929. */
  56930. static CreatePolygon(name: string, options: {
  56931. shape: Vector3[];
  56932. holes?: Vector3[][];
  56933. depth?: number;
  56934. faceUV?: Vector4[];
  56935. faceColors?: Color4[];
  56936. updatable?: boolean;
  56937. sideOrientation?: number;
  56938. frontUVs?: Vector4;
  56939. backUVs?: Vector4;
  56940. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56941. /**
  56942. * Creates an extruded polygon mesh, with depth in the Y direction.
  56943. * * 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)
  56944. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56945. * @param name defines the name of the mesh
  56946. * @param options defines the options used to create the mesh
  56947. * @param scene defines the hosting scene
  56948. * @param earcutInjection can be used to inject your own earcut reference
  56949. * @returns the polygon mesh
  56950. */
  56951. static ExtrudePolygon(name: string, options: {
  56952. shape: Vector3[];
  56953. holes?: Vector3[][];
  56954. depth?: number;
  56955. faceUV?: Vector4[];
  56956. faceColors?: Color4[];
  56957. updatable?: boolean;
  56958. sideOrientation?: number;
  56959. frontUVs?: Vector4;
  56960. backUVs?: Vector4;
  56961. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56962. /**
  56963. * Creates a tube mesh.
  56964. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56965. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56966. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56967. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56968. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56969. * * 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)
  56970. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56971. * * 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
  56972. * * 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
  56973. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56974. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56975. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56976. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56977. * @param name defines the name of the mesh
  56978. * @param options defines the options used to create the mesh
  56979. * @param scene defines the hosting scene
  56980. * @returns the tube mesh
  56981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56982. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56983. */
  56984. static CreateTube(name: string, options: {
  56985. path: Vector3[];
  56986. radius?: number;
  56987. tessellation?: number;
  56988. radiusFunction?: {
  56989. (i: number, distance: number): number;
  56990. };
  56991. cap?: number;
  56992. arc?: number;
  56993. updatable?: boolean;
  56994. sideOrientation?: number;
  56995. frontUVs?: Vector4;
  56996. backUVs?: Vector4;
  56997. instance?: Mesh;
  56998. invertUV?: boolean;
  56999. }, scene?: Nullable<Scene>): Mesh;
  57000. /**
  57001. * Creates a polyhedron mesh
  57002. * * 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
  57003. * * The parameter `size` (positive float, default 1) sets the polygon size
  57004. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57005. * * 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`
  57006. * * 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
  57007. * * 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)`)
  57008. * * 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
  57009. * * 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
  57010. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57011. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57013. * @param name defines the name of the mesh
  57014. * @param options defines the options used to create the mesh
  57015. * @param scene defines the hosting scene
  57016. * @returns the polyhedron mesh
  57017. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57018. */
  57019. static CreatePolyhedron(name: string, options: {
  57020. type?: number;
  57021. size?: number;
  57022. sizeX?: number;
  57023. sizeY?: number;
  57024. sizeZ?: number;
  57025. custom?: any;
  57026. faceUV?: Vector4[];
  57027. faceColors?: Color4[];
  57028. flat?: boolean;
  57029. updatable?: boolean;
  57030. sideOrientation?: number;
  57031. frontUVs?: Vector4;
  57032. backUVs?: Vector4;
  57033. }, scene?: Nullable<Scene>): Mesh;
  57034. /**
  57035. * Creates a decal mesh.
  57036. * 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
  57037. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  57038. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  57039. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  57040. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  57041. * @param name defines the name of the mesh
  57042. * @param sourceMesh defines the mesh where the decal must be applied
  57043. * @param options defines the options used to create the mesh
  57044. * @param scene defines the hosting scene
  57045. * @returns the decal mesh
  57046. * @see https://doc.babylonjs.com/how_to/decals
  57047. */
  57048. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  57049. position?: Vector3;
  57050. normal?: Vector3;
  57051. size?: Vector3;
  57052. angle?: number;
  57053. }): Mesh;
  57054. }
  57055. }
  57056. declare module "babylonjs/Meshes/meshSimplification" {
  57057. import { Mesh } from "babylonjs/Meshes/mesh";
  57058. /**
  57059. * A simplifier interface for future simplification implementations
  57060. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57061. */
  57062. export interface ISimplifier {
  57063. /**
  57064. * Simplification of a given mesh according to the given settings.
  57065. * Since this requires computation, it is assumed that the function runs async.
  57066. * @param settings The settings of the simplification, including quality and distance
  57067. * @param successCallback A callback that will be called after the mesh was simplified.
  57068. * @param errorCallback in case of an error, this callback will be called. optional.
  57069. */
  57070. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  57071. }
  57072. /**
  57073. * Expected simplification settings.
  57074. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  57075. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57076. */
  57077. export interface ISimplificationSettings {
  57078. /**
  57079. * Gets or sets the expected quality
  57080. */
  57081. quality: number;
  57082. /**
  57083. * Gets or sets the distance when this optimized version should be used
  57084. */
  57085. distance: number;
  57086. /**
  57087. * Gets an already optimized mesh
  57088. */
  57089. optimizeMesh?: boolean;
  57090. }
  57091. /**
  57092. * Class used to specify simplification options
  57093. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57094. */
  57095. export class SimplificationSettings implements ISimplificationSettings {
  57096. /** expected quality */
  57097. quality: number;
  57098. /** distance when this optimized version should be used */
  57099. distance: number;
  57100. /** already optimized mesh */
  57101. optimizeMesh?: boolean | undefined;
  57102. /**
  57103. * Creates a SimplificationSettings
  57104. * @param quality expected quality
  57105. * @param distance distance when this optimized version should be used
  57106. * @param optimizeMesh already optimized mesh
  57107. */
  57108. constructor(
  57109. /** expected quality */
  57110. quality: number,
  57111. /** distance when this optimized version should be used */
  57112. distance: number,
  57113. /** already optimized mesh */
  57114. optimizeMesh?: boolean | undefined);
  57115. }
  57116. /**
  57117. * Interface used to define a simplification task
  57118. */
  57119. export interface ISimplificationTask {
  57120. /**
  57121. * Array of settings
  57122. */
  57123. settings: Array<ISimplificationSettings>;
  57124. /**
  57125. * Simplification type
  57126. */
  57127. simplificationType: SimplificationType;
  57128. /**
  57129. * Mesh to simplify
  57130. */
  57131. mesh: Mesh;
  57132. /**
  57133. * Callback called on success
  57134. */
  57135. successCallback?: () => void;
  57136. /**
  57137. * Defines if parallel processing can be used
  57138. */
  57139. parallelProcessing: boolean;
  57140. }
  57141. /**
  57142. * Queue used to order the simplification tasks
  57143. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57144. */
  57145. export class SimplificationQueue {
  57146. private _simplificationArray;
  57147. /**
  57148. * Gets a boolean indicating that the process is still running
  57149. */
  57150. running: boolean;
  57151. /**
  57152. * Creates a new queue
  57153. */
  57154. constructor();
  57155. /**
  57156. * Adds a new simplification task
  57157. * @param task defines a task to add
  57158. */
  57159. addTask(task: ISimplificationTask): void;
  57160. /**
  57161. * Execute next task
  57162. */
  57163. executeNext(): void;
  57164. /**
  57165. * Execute a simplification task
  57166. * @param task defines the task to run
  57167. */
  57168. runSimplification(task: ISimplificationTask): void;
  57169. private getSimplifier;
  57170. }
  57171. /**
  57172. * The implemented types of simplification
  57173. * At the moment only Quadratic Error Decimation is implemented
  57174. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57175. */
  57176. export enum SimplificationType {
  57177. /** Quadratic error decimation */
  57178. QUADRATIC = 0
  57179. }
  57180. }
  57181. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  57182. import { Scene } from "babylonjs/scene";
  57183. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  57184. import { ISceneComponent } from "babylonjs/sceneComponent";
  57185. module "babylonjs/scene" {
  57186. interface Scene {
  57187. /** @hidden (Backing field) */
  57188. _simplificationQueue: SimplificationQueue;
  57189. /**
  57190. * Gets or sets the simplification queue attached to the scene
  57191. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  57192. */
  57193. simplificationQueue: SimplificationQueue;
  57194. }
  57195. }
  57196. module "babylonjs/Meshes/mesh" {
  57197. interface Mesh {
  57198. /**
  57199. * Simplify the mesh according to the given array of settings.
  57200. * Function will return immediately and will simplify async
  57201. * @param settings a collection of simplification settings
  57202. * @param parallelProcessing should all levels calculate parallel or one after the other
  57203. * @param simplificationType the type of simplification to run
  57204. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  57205. * @returns the current mesh
  57206. */
  57207. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  57208. }
  57209. }
  57210. /**
  57211. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  57212. * created in a scene
  57213. */
  57214. export class SimplicationQueueSceneComponent implements ISceneComponent {
  57215. /**
  57216. * The component name helpfull to identify the component in the list of scene components.
  57217. */
  57218. readonly name: string;
  57219. /**
  57220. * The scene the component belongs to.
  57221. */
  57222. scene: Scene;
  57223. /**
  57224. * Creates a new instance of the component for the given scene
  57225. * @param scene Defines the scene to register the component in
  57226. */
  57227. constructor(scene: Scene);
  57228. /**
  57229. * Registers the component in a given scene
  57230. */
  57231. register(): void;
  57232. /**
  57233. * Rebuilds the elements related to this component in case of
  57234. * context lost for instance.
  57235. */
  57236. rebuild(): void;
  57237. /**
  57238. * Disposes the component and the associated ressources
  57239. */
  57240. dispose(): void;
  57241. private _beforeCameraUpdate;
  57242. }
  57243. }
  57244. declare module "babylonjs/Meshes/Builders/index" {
  57245. export * from "babylonjs/Meshes/Builders/boxBuilder";
  57246. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  57247. export * from "babylonjs/Meshes/Builders/discBuilder";
  57248. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  57249. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  57250. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  57251. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  57252. export * from "babylonjs/Meshes/Builders/torusBuilder";
  57253. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  57254. export * from "babylonjs/Meshes/Builders/linesBuilder";
  57255. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  57256. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  57257. export * from "babylonjs/Meshes/Builders/latheBuilder";
  57258. export * from "babylonjs/Meshes/Builders/planeBuilder";
  57259. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  57260. export * from "babylonjs/Meshes/Builders/groundBuilder";
  57261. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  57262. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  57263. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  57264. export * from "babylonjs/Meshes/Builders/decalBuilder";
  57265. }
  57266. declare module "babylonjs/Meshes/index" {
  57267. export * from "babylonjs/Meshes/abstractMesh";
  57268. export * from "babylonjs/Meshes/buffer";
  57269. export * from "babylonjs/Meshes/Compression/index";
  57270. export * from "babylonjs/Meshes/csg";
  57271. export * from "babylonjs/Meshes/geometry";
  57272. export * from "babylonjs/Meshes/groundMesh";
  57273. export * from "babylonjs/Meshes/trailMesh";
  57274. export * from "babylonjs/Meshes/instancedMesh";
  57275. export * from "babylonjs/Meshes/linesMesh";
  57276. export * from "babylonjs/Meshes/mesh";
  57277. export * from "babylonjs/Meshes/mesh.vertexData";
  57278. export * from "babylonjs/Meshes/meshBuilder";
  57279. export * from "babylonjs/Meshes/meshSimplification";
  57280. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  57281. export * from "babylonjs/Meshes/polygonMesh";
  57282. export * from "babylonjs/Meshes/subMesh";
  57283. export * from "babylonjs/Meshes/meshLODLevel";
  57284. export * from "babylonjs/Meshes/transformNode";
  57285. export * from "babylonjs/Meshes/Builders/index";
  57286. export * from "babylonjs/Meshes/dataBuffer";
  57287. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  57288. }
  57289. declare module "babylonjs/Morph/index" {
  57290. export * from "babylonjs/Morph/morphTarget";
  57291. export * from "babylonjs/Morph/morphTargetManager";
  57292. }
  57293. declare module "babylonjs/Navigation/INavigationEngine" {
  57294. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57295. import { Vector3 } from "babylonjs/Maths/math";
  57296. import { Mesh } from "babylonjs/Meshes/mesh";
  57297. import { Scene } from "babylonjs/scene";
  57298. /**
  57299. * Navigation plugin interface to add navigation constrained by a navigation mesh
  57300. */
  57301. export interface INavigationEnginePlugin {
  57302. /**
  57303. * plugin name
  57304. */
  57305. name: string;
  57306. /**
  57307. * Creates a navigation mesh
  57308. * @param meshes array of all the geometry used to compute the navigatio mesh
  57309. * @param parameters bunch of parameters used to filter geometry
  57310. */
  57311. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57312. /**
  57313. * Create a navigation mesh debug mesh
  57314. * @param scene is where the mesh will be added
  57315. * @returns debug display mesh
  57316. */
  57317. createDebugNavMesh(scene: Scene): Mesh;
  57318. /**
  57319. * Get a navigation mesh constrained position, closest to the parameter position
  57320. * @param position world position
  57321. * @returns the closest point to position constrained by the navigation mesh
  57322. */
  57323. getClosestPoint(position: Vector3): Vector3;
  57324. /**
  57325. * Get a navigation mesh constrained position, within a particular radius
  57326. * @param position world position
  57327. * @param maxRadius the maximum distance to the constrained world position
  57328. * @returns the closest point to position constrained by the navigation mesh
  57329. */
  57330. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57331. /**
  57332. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57333. * @param start world position
  57334. * @param end world position
  57335. * @returns array containing world position composing the path
  57336. */
  57337. computePath(start: Vector3, end: Vector3): Vector3[];
  57338. /**
  57339. * If this plugin is supported
  57340. * @returns true if plugin is supported
  57341. */
  57342. isSupported(): boolean;
  57343. /**
  57344. * Create a new Crowd so you can add agents
  57345. * @param maxAgents the maximum agent count in the crowd
  57346. * @param maxAgentRadius the maximum radius an agent can have
  57347. * @param scene to attach the crowd to
  57348. * @returns the crowd you can add agents to
  57349. */
  57350. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57351. /**
  57352. * Release all resources
  57353. */
  57354. dispose(): void;
  57355. }
  57356. /**
  57357. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  57358. */
  57359. export interface ICrowd {
  57360. /**
  57361. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57362. * You can attach anything to that node. The node position is updated in the scene update tick.
  57363. * @param pos world position that will be constrained by the navigation mesh
  57364. * @param parameters agent parameters
  57365. * @param transform hooked to the agent that will be update by the scene
  57366. * @returns agent index
  57367. */
  57368. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57369. /**
  57370. * Returns the agent position in world space
  57371. * @param index agent index returned by addAgent
  57372. * @returns world space position
  57373. */
  57374. getAgentPosition(index: number): Vector3;
  57375. /**
  57376. * Gets the agent velocity in world space
  57377. * @param index agent index returned by addAgent
  57378. * @returns world space velocity
  57379. */
  57380. getAgentVelocity(index: number): Vector3;
  57381. /**
  57382. * remove a particular agent previously created
  57383. * @param index agent index returned by addAgent
  57384. */
  57385. removeAgent(index: number): void;
  57386. /**
  57387. * get the list of all agents attached to this crowd
  57388. * @returns list of agent indices
  57389. */
  57390. getAgents(): number[];
  57391. /**
  57392. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57393. * @param deltaTime in seconds
  57394. */
  57395. update(deltaTime: number): void;
  57396. /**
  57397. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57398. * @param index agent index returned by addAgent
  57399. * @param destination targeted world position
  57400. */
  57401. agentGoto(index: number, destination: Vector3): void;
  57402. /**
  57403. * Release all resources
  57404. */
  57405. dispose(): void;
  57406. }
  57407. /**
  57408. * Configures an agent
  57409. */
  57410. export interface IAgentParameters {
  57411. /**
  57412. * Agent radius. [Limit: >= 0]
  57413. */
  57414. radius: number;
  57415. /**
  57416. * Agent height. [Limit: > 0]
  57417. */
  57418. height: number;
  57419. /**
  57420. * Maximum allowed acceleration. [Limit: >= 0]
  57421. */
  57422. maxAcceleration: number;
  57423. /**
  57424. * Maximum allowed speed. [Limit: >= 0]
  57425. */
  57426. maxSpeed: number;
  57427. /**
  57428. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  57429. */
  57430. collisionQueryRange: number;
  57431. /**
  57432. * The path visibility optimization range. [Limit: > 0]
  57433. */
  57434. pathOptimizationRange: number;
  57435. /**
  57436. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  57437. */
  57438. separationWeight: number;
  57439. }
  57440. /**
  57441. * Configures the navigation mesh creation
  57442. */
  57443. export interface INavMeshParameters {
  57444. /**
  57445. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  57446. */
  57447. cs: number;
  57448. /**
  57449. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  57450. */
  57451. ch: number;
  57452. /**
  57453. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  57454. */
  57455. walkableSlopeAngle: number;
  57456. /**
  57457. * Minimum floor to 'ceiling' height that will still allow the floor area to
  57458. * be considered walkable. [Limit: >= 3] [Units: vx]
  57459. */
  57460. walkableHeight: number;
  57461. /**
  57462. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  57463. */
  57464. walkableClimb: number;
  57465. /**
  57466. * The distance to erode/shrink the walkable area of the heightfield away from
  57467. * obstructions. [Limit: >=0] [Units: vx]
  57468. */
  57469. walkableRadius: number;
  57470. /**
  57471. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  57472. */
  57473. maxEdgeLen: number;
  57474. /**
  57475. * The maximum distance a simplfied contour's border edges should deviate
  57476. * the original raw contour. [Limit: >=0] [Units: vx]
  57477. */
  57478. maxSimplificationError: number;
  57479. /**
  57480. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  57481. */
  57482. minRegionArea: number;
  57483. /**
  57484. * Any regions with a span count smaller than this value will, if possible,
  57485. * be merged with larger regions. [Limit: >=0] [Units: vx]
  57486. */
  57487. mergeRegionArea: number;
  57488. /**
  57489. * The maximum number of vertices allowed for polygons generated during the
  57490. * contour to polygon conversion process. [Limit: >= 3]
  57491. */
  57492. maxVertsPerPoly: number;
  57493. /**
  57494. * Sets the sampling distance to use when generating the detail mesh.
  57495. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  57496. */
  57497. detailSampleDist: number;
  57498. /**
  57499. * The maximum distance the detail mesh surface should deviate from heightfield
  57500. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  57501. */
  57502. detailSampleMaxError: number;
  57503. }
  57504. }
  57505. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  57506. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  57507. import { Mesh } from "babylonjs/Meshes/mesh";
  57508. import { Scene } from "babylonjs/scene";
  57509. import { Vector3 } from "babylonjs/Maths/math";
  57510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57511. /**
  57512. * RecastJS navigation plugin
  57513. */
  57514. export class RecastJSPlugin implements INavigationEnginePlugin {
  57515. /**
  57516. * Reference to the Recast library
  57517. */
  57518. bjsRECAST: any;
  57519. /**
  57520. * plugin name
  57521. */
  57522. name: string;
  57523. /**
  57524. * the first navmesh created. We might extend this to support multiple navmeshes
  57525. */
  57526. navMesh: any;
  57527. /**
  57528. * Initializes the recastJS plugin
  57529. * @param recastInjection can be used to inject your own recast reference
  57530. */
  57531. constructor(recastInjection?: any);
  57532. /**
  57533. * Creates a navigation mesh
  57534. * @param meshes array of all the geometry used to compute the navigatio mesh
  57535. * @param parameters bunch of parameters used to filter geometry
  57536. */
  57537. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  57538. /**
  57539. * Create a navigation mesh debug mesh
  57540. * @param scene is where the mesh will be added
  57541. * @returns debug display mesh
  57542. */
  57543. createDebugNavMesh(scene: Scene): Mesh;
  57544. /**
  57545. * Get a navigation mesh constrained position, closest to the parameter position
  57546. * @param position world position
  57547. * @returns the closest point to position constrained by the navigation mesh
  57548. */
  57549. getClosestPoint(position: Vector3): Vector3;
  57550. /**
  57551. * Get a navigation mesh constrained position, within a particular radius
  57552. * @param position world position
  57553. * @param maxRadius the maximum distance to the constrained world position
  57554. * @returns the closest point to position constrained by the navigation mesh
  57555. */
  57556. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  57557. /**
  57558. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  57559. * @param start world position
  57560. * @param end world position
  57561. * @returns array containing world position composing the path
  57562. */
  57563. computePath(start: Vector3, end: Vector3): Vector3[];
  57564. /**
  57565. * Create a new Crowd so you can add agents
  57566. * @param maxAgents the maximum agent count in the crowd
  57567. * @param maxAgentRadius the maximum radius an agent can have
  57568. * @param scene to attach the crowd to
  57569. * @returns the crowd you can add agents to
  57570. */
  57571. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  57572. /**
  57573. * Disposes
  57574. */
  57575. dispose(): void;
  57576. /**
  57577. * If this plugin is supported
  57578. * @returns true if plugin is supported
  57579. */
  57580. isSupported(): boolean;
  57581. }
  57582. /**
  57583. * Recast detour crowd implementation
  57584. */
  57585. export class RecastJSCrowd implements ICrowd {
  57586. /**
  57587. * Recast/detour plugin
  57588. */
  57589. bjsRECASTPlugin: RecastJSPlugin;
  57590. /**
  57591. * Link to the detour crowd
  57592. */
  57593. recastCrowd: any;
  57594. /**
  57595. * One transform per agent
  57596. */
  57597. transforms: TransformNode[];
  57598. /**
  57599. * All agents created
  57600. */
  57601. agents: number[];
  57602. /**
  57603. * Link to the scene is kept to unregister the crowd from the scene
  57604. */
  57605. private _scene;
  57606. /**
  57607. * Observer for crowd updates
  57608. */
  57609. private _onBeforeAnimationsObserver;
  57610. /**
  57611. * Constructor
  57612. * @param plugin recastJS plugin
  57613. * @param maxAgents the maximum agent count in the crowd
  57614. * @param maxAgentRadius the maximum radius an agent can have
  57615. * @param scene to attach the crowd to
  57616. * @returns the crowd you can add agents to
  57617. */
  57618. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  57619. /**
  57620. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  57621. * You can attach anything to that node. The node position is updated in the scene update tick.
  57622. * @param pos world position that will be constrained by the navigation mesh
  57623. * @param parameters agent parameters
  57624. * @param transform hooked to the agent that will be update by the scene
  57625. * @returns agent index
  57626. */
  57627. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  57628. /**
  57629. * Returns the agent position in world space
  57630. * @param index agent index returned by addAgent
  57631. * @returns world space position
  57632. */
  57633. getAgentPosition(index: number): Vector3;
  57634. /**
  57635. * Returns the agent velocity in world space
  57636. * @param index agent index returned by addAgent
  57637. * @returns world space velocity
  57638. */
  57639. getAgentVelocity(index: number): Vector3;
  57640. /**
  57641. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  57642. * @param index agent index returned by addAgent
  57643. * @param destination targeted world position
  57644. */
  57645. agentGoto(index: number, destination: Vector3): void;
  57646. /**
  57647. * remove a particular agent previously created
  57648. * @param index agent index returned by addAgent
  57649. */
  57650. removeAgent(index: number): void;
  57651. /**
  57652. * get the list of all agents attached to this crowd
  57653. * @returns list of agent indices
  57654. */
  57655. getAgents(): number[];
  57656. /**
  57657. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  57658. * @param deltaTime in seconds
  57659. */
  57660. update(deltaTime: number): void;
  57661. /**
  57662. * Release all resources
  57663. */
  57664. dispose(): void;
  57665. }
  57666. }
  57667. declare module "babylonjs/Navigation/Plugins/index" {
  57668. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  57669. }
  57670. declare module "babylonjs/Navigation/index" {
  57671. export * from "babylonjs/Navigation/INavigationEngine";
  57672. export * from "babylonjs/Navigation/Plugins/index";
  57673. }
  57674. declare module "babylonjs/Offline/database" {
  57675. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  57676. /**
  57677. * Class used to enable access to IndexedDB
  57678. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  57679. */
  57680. export class Database implements IOfflineProvider {
  57681. private _callbackManifestChecked;
  57682. private _currentSceneUrl;
  57683. private _db;
  57684. private _enableSceneOffline;
  57685. private _enableTexturesOffline;
  57686. private _manifestVersionFound;
  57687. private _mustUpdateRessources;
  57688. private _hasReachedQuota;
  57689. private _isSupported;
  57690. private _idbFactory;
  57691. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  57692. private static IsUASupportingBlobStorage;
  57693. /**
  57694. * Gets a boolean indicating if Database storate is enabled (off by default)
  57695. */
  57696. static IDBStorageEnabled: boolean;
  57697. /**
  57698. * Gets a boolean indicating if scene must be saved in the database
  57699. */
  57700. readonly enableSceneOffline: boolean;
  57701. /**
  57702. * Gets a boolean indicating if textures must be saved in the database
  57703. */
  57704. readonly enableTexturesOffline: boolean;
  57705. /**
  57706. * Creates a new Database
  57707. * @param urlToScene defines the url to load the scene
  57708. * @param callbackManifestChecked defines the callback to use when manifest is checked
  57709. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  57710. */
  57711. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  57712. private static _ParseURL;
  57713. private static _ReturnFullUrlLocation;
  57714. private _checkManifestFile;
  57715. /**
  57716. * Open the database and make it available
  57717. * @param successCallback defines the callback to call on success
  57718. * @param errorCallback defines the callback to call on error
  57719. */
  57720. open(successCallback: () => void, errorCallback: () => void): void;
  57721. /**
  57722. * Loads an image from the database
  57723. * @param url defines the url to load from
  57724. * @param image defines the target DOM image
  57725. */
  57726. loadImage(url: string, image: HTMLImageElement): void;
  57727. private _loadImageFromDBAsync;
  57728. private _saveImageIntoDBAsync;
  57729. private _checkVersionFromDB;
  57730. private _loadVersionFromDBAsync;
  57731. private _saveVersionIntoDBAsync;
  57732. /**
  57733. * Loads a file from database
  57734. * @param url defines the URL to load from
  57735. * @param sceneLoaded defines a callback to call on success
  57736. * @param progressCallBack defines a callback to call when progress changed
  57737. * @param errorCallback defines a callback to call on error
  57738. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  57739. */
  57740. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  57741. private _loadFileAsync;
  57742. private _saveFileAsync;
  57743. /**
  57744. * Validates if xhr data is correct
  57745. * @param xhr defines the request to validate
  57746. * @param dataType defines the expected data type
  57747. * @returns true if data is correct
  57748. */
  57749. private static _ValidateXHRData;
  57750. }
  57751. }
  57752. declare module "babylonjs/Offline/index" {
  57753. export * from "babylonjs/Offline/database";
  57754. export * from "babylonjs/Offline/IOfflineProvider";
  57755. }
  57756. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  57757. /** @hidden */
  57758. export var gpuUpdateParticlesPixelShader: {
  57759. name: string;
  57760. shader: string;
  57761. };
  57762. }
  57763. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  57764. /** @hidden */
  57765. export var gpuUpdateParticlesVertexShader: {
  57766. name: string;
  57767. shader: string;
  57768. };
  57769. }
  57770. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  57771. /** @hidden */
  57772. export var clipPlaneFragmentDeclaration2: {
  57773. name: string;
  57774. shader: string;
  57775. };
  57776. }
  57777. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  57778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  57779. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57780. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57781. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57783. /** @hidden */
  57784. export var gpuRenderParticlesPixelShader: {
  57785. name: string;
  57786. shader: string;
  57787. };
  57788. }
  57789. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  57790. /** @hidden */
  57791. export var clipPlaneVertexDeclaration2: {
  57792. name: string;
  57793. shader: string;
  57794. };
  57795. }
  57796. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  57797. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  57798. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57799. /** @hidden */
  57800. export var gpuRenderParticlesVertexShader: {
  57801. name: string;
  57802. shader: string;
  57803. };
  57804. }
  57805. declare module "babylonjs/Particles/gpuParticleSystem" {
  57806. import { Nullable } from "babylonjs/types";
  57807. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  57808. import { Observable } from "babylonjs/Misc/observable";
  57809. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  57810. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57811. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  57812. import { Scene, IDisposable } from "babylonjs/scene";
  57813. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  57814. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57815. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  57816. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  57817. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  57818. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  57819. /**
  57820. * This represents a GPU particle system in Babylon
  57821. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  57822. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  57823. */
  57824. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  57825. /**
  57826. * The layer mask we are rendering the particles through.
  57827. */
  57828. layerMask: number;
  57829. private _capacity;
  57830. private _activeCount;
  57831. private _currentActiveCount;
  57832. private _accumulatedCount;
  57833. private _renderEffect;
  57834. private _updateEffect;
  57835. private _buffer0;
  57836. private _buffer1;
  57837. private _spriteBuffer;
  57838. private _updateVAO;
  57839. private _renderVAO;
  57840. private _targetIndex;
  57841. private _sourceBuffer;
  57842. private _targetBuffer;
  57843. private _engine;
  57844. private _currentRenderId;
  57845. private _started;
  57846. private _stopped;
  57847. private _timeDelta;
  57848. private _randomTexture;
  57849. private _randomTexture2;
  57850. private _attributesStrideSize;
  57851. private _updateEffectOptions;
  57852. private _randomTextureSize;
  57853. private _actualFrame;
  57854. private readonly _rawTextureWidth;
  57855. /**
  57856. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  57857. */
  57858. static readonly IsSupported: boolean;
  57859. /**
  57860. * An event triggered when the system is disposed.
  57861. */
  57862. onDisposeObservable: Observable<GPUParticleSystem>;
  57863. /**
  57864. * Gets the maximum number of particles active at the same time.
  57865. * @returns The max number of active particles.
  57866. */
  57867. getCapacity(): number;
  57868. /**
  57869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  57870. * to override the particles.
  57871. */
  57872. forceDepthWrite: boolean;
  57873. /**
  57874. * Gets or set the number of active particles
  57875. */
  57876. activeParticleCount: number;
  57877. private _preWarmDone;
  57878. /**
  57879. * Is this system ready to be used/rendered
  57880. * @return true if the system is ready
  57881. */
  57882. isReady(): boolean;
  57883. /**
  57884. * Gets if the system has been started. (Note: this will still be true after stop is called)
  57885. * @returns True if it has been started, otherwise false.
  57886. */
  57887. isStarted(): boolean;
  57888. /**
  57889. * Starts the particle system and begins to emit
  57890. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  57891. */
  57892. start(delay?: number): void;
  57893. /**
  57894. * Stops the particle system.
  57895. */
  57896. stop(): void;
  57897. /**
  57898. * Remove all active particles
  57899. */
  57900. reset(): void;
  57901. /**
  57902. * Returns the string "GPUParticleSystem"
  57903. * @returns a string containing the class name
  57904. */
  57905. getClassName(): string;
  57906. private _colorGradientsTexture;
  57907. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  57908. /**
  57909. * Adds a new color gradient
  57910. * @param gradient defines the gradient to use (between 0 and 1)
  57911. * @param color1 defines the color to affect to the specified gradient
  57912. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  57913. * @returns the current particle system
  57914. */
  57915. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  57916. /**
  57917. * Remove a specific color gradient
  57918. * @param gradient defines the gradient to remove
  57919. * @returns the current particle system
  57920. */
  57921. removeColorGradient(gradient: number): GPUParticleSystem;
  57922. private _angularSpeedGradientsTexture;
  57923. private _sizeGradientsTexture;
  57924. private _velocityGradientsTexture;
  57925. private _limitVelocityGradientsTexture;
  57926. private _dragGradientsTexture;
  57927. private _addFactorGradient;
  57928. /**
  57929. * Adds a new size gradient
  57930. * @param gradient defines the gradient to use (between 0 and 1)
  57931. * @param factor defines the size factor to affect to the specified gradient
  57932. * @returns the current particle system
  57933. */
  57934. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  57935. /**
  57936. * Remove a specific size gradient
  57937. * @param gradient defines the gradient to remove
  57938. * @returns the current particle system
  57939. */
  57940. removeSizeGradient(gradient: number): GPUParticleSystem;
  57941. /**
  57942. * Adds a new angular speed gradient
  57943. * @param gradient defines the gradient to use (between 0 and 1)
  57944. * @param factor defines the angular speed to affect to the specified gradient
  57945. * @returns the current particle system
  57946. */
  57947. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  57948. /**
  57949. * Remove a specific angular speed gradient
  57950. * @param gradient defines the gradient to remove
  57951. * @returns the current particle system
  57952. */
  57953. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  57954. /**
  57955. * Adds a new velocity gradient
  57956. * @param gradient defines the gradient to use (between 0 and 1)
  57957. * @param factor defines the velocity to affect to the specified gradient
  57958. * @returns the current particle system
  57959. */
  57960. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57961. /**
  57962. * Remove a specific velocity gradient
  57963. * @param gradient defines the gradient to remove
  57964. * @returns the current particle system
  57965. */
  57966. removeVelocityGradient(gradient: number): GPUParticleSystem;
  57967. /**
  57968. * Adds a new limit velocity gradient
  57969. * @param gradient defines the gradient to use (between 0 and 1)
  57970. * @param factor defines the limit velocity value to affect to the specified gradient
  57971. * @returns the current particle system
  57972. */
  57973. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  57974. /**
  57975. * Remove a specific limit velocity gradient
  57976. * @param gradient defines the gradient to remove
  57977. * @returns the current particle system
  57978. */
  57979. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  57980. /**
  57981. * Adds a new drag gradient
  57982. * @param gradient defines the gradient to use (between 0 and 1)
  57983. * @param factor defines the drag value to affect to the specified gradient
  57984. * @returns the current particle system
  57985. */
  57986. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  57987. /**
  57988. * Remove a specific drag gradient
  57989. * @param gradient defines the gradient to remove
  57990. * @returns the current particle system
  57991. */
  57992. removeDragGradient(gradient: number): GPUParticleSystem;
  57993. /**
  57994. * Not supported by GPUParticleSystem
  57995. * @param gradient defines the gradient to use (between 0 and 1)
  57996. * @param factor defines the emit rate value to affect to the specified gradient
  57997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  57998. * @returns the current particle system
  57999. */
  58000. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58001. /**
  58002. * Not supported by GPUParticleSystem
  58003. * @param gradient defines the gradient to remove
  58004. * @returns the current particle system
  58005. */
  58006. removeEmitRateGradient(gradient: number): IParticleSystem;
  58007. /**
  58008. * Not supported by GPUParticleSystem
  58009. * @param gradient defines the gradient to use (between 0 and 1)
  58010. * @param factor defines the start size value to affect to the specified gradient
  58011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58012. * @returns the current particle system
  58013. */
  58014. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58015. /**
  58016. * Not supported by GPUParticleSystem
  58017. * @param gradient defines the gradient to remove
  58018. * @returns the current particle system
  58019. */
  58020. removeStartSizeGradient(gradient: number): IParticleSystem;
  58021. /**
  58022. * Not supported by GPUParticleSystem
  58023. * @param gradient defines the gradient to use (between 0 and 1)
  58024. * @param min defines the color remap minimal range
  58025. * @param max defines the color remap maximal range
  58026. * @returns the current particle system
  58027. */
  58028. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58029. /**
  58030. * Not supported by GPUParticleSystem
  58031. * @param gradient defines the gradient to remove
  58032. * @returns the current particle system
  58033. */
  58034. removeColorRemapGradient(): IParticleSystem;
  58035. /**
  58036. * Not supported by GPUParticleSystem
  58037. * @param gradient defines the gradient to use (between 0 and 1)
  58038. * @param min defines the alpha remap minimal range
  58039. * @param max defines the alpha remap maximal range
  58040. * @returns the current particle system
  58041. */
  58042. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  58043. /**
  58044. * Not supported by GPUParticleSystem
  58045. * @param gradient defines the gradient to remove
  58046. * @returns the current particle system
  58047. */
  58048. removeAlphaRemapGradient(): IParticleSystem;
  58049. /**
  58050. * Not supported by GPUParticleSystem
  58051. * @param gradient defines the gradient to use (between 0 and 1)
  58052. * @param color defines the color to affect to the specified gradient
  58053. * @returns the current particle system
  58054. */
  58055. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  58056. /**
  58057. * Not supported by GPUParticleSystem
  58058. * @param gradient defines the gradient to remove
  58059. * @returns the current particle system
  58060. */
  58061. removeRampGradient(): IParticleSystem;
  58062. /**
  58063. * Not supported by GPUParticleSystem
  58064. * @returns the list of ramp gradients
  58065. */
  58066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  58067. /**
  58068. * Not supported by GPUParticleSystem
  58069. * Gets or sets a boolean indicating that ramp gradients must be used
  58070. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  58071. */
  58072. useRampGradients: boolean;
  58073. /**
  58074. * Not supported by GPUParticleSystem
  58075. * @param gradient defines the gradient to use (between 0 and 1)
  58076. * @param factor defines the life time factor to affect to the specified gradient
  58077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  58078. * @returns the current particle system
  58079. */
  58080. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  58081. /**
  58082. * Not supported by GPUParticleSystem
  58083. * @param gradient defines the gradient to remove
  58084. * @returns the current particle system
  58085. */
  58086. removeLifeTimeGradient(gradient: number): IParticleSystem;
  58087. /**
  58088. * Instantiates a GPU particle system.
  58089. * 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.
  58090. * @param name The name of the particle system
  58091. * @param options The options used to create the system
  58092. * @param scene The scene the particle system belongs to
  58093. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  58094. */
  58095. constructor(name: string, options: Partial<{
  58096. capacity: number;
  58097. randomTextureSize: number;
  58098. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  58099. protected _reset(): void;
  58100. private _createUpdateVAO;
  58101. private _createRenderVAO;
  58102. private _initialize;
  58103. /** @hidden */
  58104. _recreateUpdateEffect(): void;
  58105. /** @hidden */
  58106. _recreateRenderEffect(): void;
  58107. /**
  58108. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  58109. * @param preWarm defines if we are in the pre-warmimg phase
  58110. */
  58111. animate(preWarm?: boolean): void;
  58112. private _createFactorGradientTexture;
  58113. private _createSizeGradientTexture;
  58114. private _createAngularSpeedGradientTexture;
  58115. private _createVelocityGradientTexture;
  58116. private _createLimitVelocityGradientTexture;
  58117. private _createDragGradientTexture;
  58118. private _createColorGradientTexture;
  58119. /**
  58120. * Renders the particle system in its current state
  58121. * @param preWarm defines if the system should only update the particles but not render them
  58122. * @returns the current number of particles
  58123. */
  58124. render(preWarm?: boolean): number;
  58125. /**
  58126. * Rebuilds the particle system
  58127. */
  58128. rebuild(): void;
  58129. private _releaseBuffers;
  58130. private _releaseVAOs;
  58131. /**
  58132. * Disposes the particle system and free the associated resources
  58133. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  58134. */
  58135. dispose(disposeTexture?: boolean): void;
  58136. /**
  58137. * Clones the particle system.
  58138. * @param name The name of the cloned object
  58139. * @param newEmitter The new emitter to use
  58140. * @returns the cloned particle system
  58141. */
  58142. clone(name: string, newEmitter: any): GPUParticleSystem;
  58143. /**
  58144. * Serializes the particle system to a JSON object.
  58145. * @returns the JSON object
  58146. */
  58147. serialize(): any;
  58148. /**
  58149. * Parses a JSON object to create a GPU particle system.
  58150. * @param parsedParticleSystem The JSON object to parse
  58151. * @param scene The scene to create the particle system in
  58152. * @param rootUrl The root url to use to load external dependencies like texture
  58153. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  58154. * @returns the parsed GPU particle system
  58155. */
  58156. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  58157. }
  58158. }
  58159. declare module "babylonjs/Particles/particleSystemSet" {
  58160. import { Nullable } from "babylonjs/types";
  58161. import { Color3 } from "babylonjs/Maths/math.color";
  58162. import { TransformNode } from "babylonjs/Meshes/transformNode";
  58163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58164. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58165. import { Scene, IDisposable } from "babylonjs/scene";
  58166. /**
  58167. * Represents a set of particle systems working together to create a specific effect
  58168. */
  58169. export class ParticleSystemSet implements IDisposable {
  58170. private _emitterCreationOptions;
  58171. private _emitterNode;
  58172. /**
  58173. * Gets the particle system list
  58174. */
  58175. systems: IParticleSystem[];
  58176. /**
  58177. * Gets the emitter node used with this set
  58178. */
  58179. readonly emitterNode: Nullable<TransformNode>;
  58180. /**
  58181. * Creates a new emitter mesh as a sphere
  58182. * @param options defines the options used to create the sphere
  58183. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  58184. * @param scene defines the hosting scene
  58185. */
  58186. setEmitterAsSphere(options: {
  58187. diameter: number;
  58188. segments: number;
  58189. color: Color3;
  58190. }, renderingGroupId: number, scene: Scene): void;
  58191. /**
  58192. * Starts all particle systems of the set
  58193. * @param emitter defines an optional mesh to use as emitter for the particle systems
  58194. */
  58195. start(emitter?: AbstractMesh): void;
  58196. /**
  58197. * Release all associated resources
  58198. */
  58199. dispose(): void;
  58200. /**
  58201. * Serialize the set into a JSON compatible object
  58202. * @returns a JSON compatible representation of the set
  58203. */
  58204. serialize(): any;
  58205. /**
  58206. * Parse a new ParticleSystemSet from a serialized source
  58207. * @param data defines a JSON compatible representation of the set
  58208. * @param scene defines the hosting scene
  58209. * @param gpu defines if we want GPU particles or CPU particles
  58210. * @returns a new ParticleSystemSet
  58211. */
  58212. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  58213. }
  58214. }
  58215. declare module "babylonjs/Particles/particleHelper" {
  58216. import { Nullable } from "babylonjs/types";
  58217. import { Scene } from "babylonjs/scene";
  58218. import { Vector3 } from "babylonjs/Maths/math.vector";
  58219. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58220. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58221. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  58222. /**
  58223. * This class is made for on one-liner static method to help creating particle system set.
  58224. */
  58225. export class ParticleHelper {
  58226. /**
  58227. * Gets or sets base Assets URL
  58228. */
  58229. static BaseAssetsUrl: string;
  58230. /**
  58231. * Create a default particle system that you can tweak
  58232. * @param emitter defines the emitter to use
  58233. * @param capacity defines the system capacity (default is 500 particles)
  58234. * @param scene defines the hosting scene
  58235. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  58236. * @returns the new Particle system
  58237. */
  58238. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  58239. /**
  58240. * This is the main static method (one-liner) of this helper to create different particle systems
  58241. * @param type This string represents the type to the particle system to create
  58242. * @param scene The scene where the particle system should live
  58243. * @param gpu If the system will use gpu
  58244. * @returns the ParticleSystemSet created
  58245. */
  58246. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  58247. /**
  58248. * Static function used to export a particle system to a ParticleSystemSet variable.
  58249. * Please note that the emitter shape is not exported
  58250. * @param systems defines the particle systems to export
  58251. * @returns the created particle system set
  58252. */
  58253. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  58254. }
  58255. }
  58256. declare module "babylonjs/Particles/particleSystemComponent" {
  58257. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  58258. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  58259. import "babylonjs/Shaders/particles.vertex";
  58260. module "babylonjs/Engines/engine" {
  58261. interface Engine {
  58262. /**
  58263. * Create an effect to use with particle systems.
  58264. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  58265. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  58266. * @param uniformsNames defines a list of attribute names
  58267. * @param samplers defines an array of string used to represent textures
  58268. * @param defines defines the string containing the defines to use to compile the shaders
  58269. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  58270. * @param onCompiled defines a function to call when the effect creation is successful
  58271. * @param onError defines a function to call when the effect creation has failed
  58272. * @returns the new Effect
  58273. */
  58274. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  58275. }
  58276. }
  58277. module "babylonjs/Meshes/mesh" {
  58278. interface Mesh {
  58279. /**
  58280. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  58281. * @returns an array of IParticleSystem
  58282. */
  58283. getEmittedParticleSystems(): IParticleSystem[];
  58284. /**
  58285. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  58286. * @returns an array of IParticleSystem
  58287. */
  58288. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  58289. }
  58290. }
  58291. /**
  58292. * @hidden
  58293. */
  58294. export var _IDoNeedToBeInTheBuild: number;
  58295. }
  58296. declare module "babylonjs/Particles/index" {
  58297. export * from "babylonjs/Particles/baseParticleSystem";
  58298. export * from "babylonjs/Particles/EmitterTypes/index";
  58299. export * from "babylonjs/Particles/gpuParticleSystem";
  58300. export * from "babylonjs/Particles/IParticleSystem";
  58301. export * from "babylonjs/Particles/particle";
  58302. export * from "babylonjs/Particles/particleHelper";
  58303. export * from "babylonjs/Particles/particleSystem";
  58304. export * from "babylonjs/Particles/particleSystemComponent";
  58305. export * from "babylonjs/Particles/particleSystemSet";
  58306. export * from "babylonjs/Particles/solidParticle";
  58307. export * from "babylonjs/Particles/solidParticleSystem";
  58308. export * from "babylonjs/Particles/subEmitter";
  58309. }
  58310. declare module "babylonjs/Physics/physicsEngineComponent" {
  58311. import { Nullable } from "babylonjs/types";
  58312. import { Observable, Observer } from "babylonjs/Misc/observable";
  58313. import { Vector3 } from "babylonjs/Maths/math.vector";
  58314. import { Mesh } from "babylonjs/Meshes/mesh";
  58315. import { ISceneComponent } from "babylonjs/sceneComponent";
  58316. import { Scene } from "babylonjs/scene";
  58317. import { Node } from "babylonjs/node";
  58318. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  58319. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58320. module "babylonjs/scene" {
  58321. interface Scene {
  58322. /** @hidden (Backing field) */
  58323. _physicsEngine: Nullable<IPhysicsEngine>;
  58324. /**
  58325. * Gets the current physics engine
  58326. * @returns a IPhysicsEngine or null if none attached
  58327. */
  58328. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  58329. /**
  58330. * Enables physics to the current scene
  58331. * @param gravity defines the scene's gravity for the physics engine
  58332. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  58333. * @return a boolean indicating if the physics engine was initialized
  58334. */
  58335. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  58336. /**
  58337. * Disables and disposes the physics engine associated with the scene
  58338. */
  58339. disablePhysicsEngine(): void;
  58340. /**
  58341. * Gets a boolean indicating if there is an active physics engine
  58342. * @returns a boolean indicating if there is an active physics engine
  58343. */
  58344. isPhysicsEnabled(): boolean;
  58345. /**
  58346. * Deletes a physics compound impostor
  58347. * @param compound defines the compound to delete
  58348. */
  58349. deleteCompoundImpostor(compound: any): void;
  58350. /**
  58351. * An event triggered when physic simulation is about to be run
  58352. */
  58353. onBeforePhysicsObservable: Observable<Scene>;
  58354. /**
  58355. * An event triggered when physic simulation has been done
  58356. */
  58357. onAfterPhysicsObservable: Observable<Scene>;
  58358. }
  58359. }
  58360. module "babylonjs/Meshes/abstractMesh" {
  58361. interface AbstractMesh {
  58362. /** @hidden */
  58363. _physicsImpostor: Nullable<PhysicsImpostor>;
  58364. /**
  58365. * Gets or sets impostor used for physic simulation
  58366. * @see http://doc.babylonjs.com/features/physics_engine
  58367. */
  58368. physicsImpostor: Nullable<PhysicsImpostor>;
  58369. /**
  58370. * Gets the current physics impostor
  58371. * @see http://doc.babylonjs.com/features/physics_engine
  58372. * @returns a physics impostor or null
  58373. */
  58374. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  58375. /** Apply a physic impulse to the mesh
  58376. * @param force defines the force to apply
  58377. * @param contactPoint defines where to apply the force
  58378. * @returns the current mesh
  58379. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  58380. */
  58381. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  58382. /**
  58383. * Creates a physic joint between two meshes
  58384. * @param otherMesh defines the other mesh to use
  58385. * @param pivot1 defines the pivot to use on this mesh
  58386. * @param pivot2 defines the pivot to use on the other mesh
  58387. * @param options defines additional options (can be plugin dependent)
  58388. * @returns the current mesh
  58389. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  58390. */
  58391. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  58392. /** @hidden */
  58393. _disposePhysicsObserver: Nullable<Observer<Node>>;
  58394. }
  58395. }
  58396. /**
  58397. * Defines the physics engine scene component responsible to manage a physics engine
  58398. */
  58399. export class PhysicsEngineSceneComponent implements ISceneComponent {
  58400. /**
  58401. * The component name helpful to identify the component in the list of scene components.
  58402. */
  58403. readonly name: string;
  58404. /**
  58405. * The scene the component belongs to.
  58406. */
  58407. scene: Scene;
  58408. /**
  58409. * Creates a new instance of the component for the given scene
  58410. * @param scene Defines the scene to register the component in
  58411. */
  58412. constructor(scene: Scene);
  58413. /**
  58414. * Registers the component in a given scene
  58415. */
  58416. register(): void;
  58417. /**
  58418. * Rebuilds the elements related to this component in case of
  58419. * context lost for instance.
  58420. */
  58421. rebuild(): void;
  58422. /**
  58423. * Disposes the component and the associated ressources
  58424. */
  58425. dispose(): void;
  58426. }
  58427. }
  58428. declare module "babylonjs/Physics/physicsHelper" {
  58429. import { Nullable } from "babylonjs/types";
  58430. import { Vector3 } from "babylonjs/Maths/math.vector";
  58431. import { Mesh } from "babylonjs/Meshes/mesh";
  58432. import { Scene } from "babylonjs/scene";
  58433. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58434. /**
  58435. * A helper for physics simulations
  58436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58437. */
  58438. export class PhysicsHelper {
  58439. private _scene;
  58440. private _physicsEngine;
  58441. /**
  58442. * Initializes the Physics helper
  58443. * @param scene Babylon.js scene
  58444. */
  58445. constructor(scene: Scene);
  58446. /**
  58447. * Applies a radial explosion impulse
  58448. * @param origin the origin of the explosion
  58449. * @param radiusOrEventOptions the radius or the options of radial explosion
  58450. * @param strength the explosion strength
  58451. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58452. * @returns A physics radial explosion event, or null
  58453. */
  58454. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58455. /**
  58456. * Applies a radial explosion force
  58457. * @param origin the origin of the explosion
  58458. * @param radiusOrEventOptions the radius or the options of radial explosion
  58459. * @param strength the explosion strength
  58460. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58461. * @returns A physics radial explosion event, or null
  58462. */
  58463. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  58464. /**
  58465. * Creates a gravitational field
  58466. * @param origin the origin of the explosion
  58467. * @param radiusOrEventOptions the radius or the options of radial explosion
  58468. * @param strength the explosion strength
  58469. * @param falloff possible options: Constant & Linear. Defaults to Constant
  58470. * @returns A physics gravitational field event, or null
  58471. */
  58472. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  58473. /**
  58474. * Creates a physics updraft event
  58475. * @param origin the origin of the updraft
  58476. * @param radiusOrEventOptions the radius or the options of the updraft
  58477. * @param strength the strength of the updraft
  58478. * @param height the height of the updraft
  58479. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  58480. * @returns A physics updraft event, or null
  58481. */
  58482. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  58483. /**
  58484. * Creates a physics vortex event
  58485. * @param origin the of the vortex
  58486. * @param radiusOrEventOptions the radius or the options of the vortex
  58487. * @param strength the strength of the vortex
  58488. * @param height the height of the vortex
  58489. * @returns a Physics vortex event, or null
  58490. * A physics vortex event or null
  58491. */
  58492. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  58493. }
  58494. /**
  58495. * Represents a physics radial explosion event
  58496. */
  58497. class PhysicsRadialExplosionEvent {
  58498. private _scene;
  58499. private _options;
  58500. private _sphere;
  58501. private _dataFetched;
  58502. /**
  58503. * Initializes a radial explosioin event
  58504. * @param _scene BabylonJS scene
  58505. * @param _options The options for the vortex event
  58506. */
  58507. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  58508. /**
  58509. * Returns the data related to the radial explosion event (sphere).
  58510. * @returns The radial explosion event data
  58511. */
  58512. getData(): PhysicsRadialExplosionEventData;
  58513. /**
  58514. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  58515. * @param impostor A physics imposter
  58516. * @param origin the origin of the explosion
  58517. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  58518. */
  58519. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  58520. /**
  58521. * Triggers affecterd impostors callbacks
  58522. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  58523. */
  58524. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  58525. /**
  58526. * Disposes the sphere.
  58527. * @param force Specifies if the sphere should be disposed by force
  58528. */
  58529. dispose(force?: boolean): void;
  58530. /*** Helpers ***/
  58531. private _prepareSphere;
  58532. private _intersectsWithSphere;
  58533. }
  58534. /**
  58535. * Represents a gravitational field event
  58536. */
  58537. class PhysicsGravitationalFieldEvent {
  58538. private _physicsHelper;
  58539. private _scene;
  58540. private _origin;
  58541. private _options;
  58542. private _tickCallback;
  58543. private _sphere;
  58544. private _dataFetched;
  58545. /**
  58546. * Initializes the physics gravitational field event
  58547. * @param _physicsHelper A physics helper
  58548. * @param _scene BabylonJS scene
  58549. * @param _origin The origin position of the gravitational field event
  58550. * @param _options The options for the vortex event
  58551. */
  58552. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  58553. /**
  58554. * Returns the data related to the gravitational field event (sphere).
  58555. * @returns A gravitational field event
  58556. */
  58557. getData(): PhysicsGravitationalFieldEventData;
  58558. /**
  58559. * Enables the gravitational field.
  58560. */
  58561. enable(): void;
  58562. /**
  58563. * Disables the gravitational field.
  58564. */
  58565. disable(): void;
  58566. /**
  58567. * Disposes the sphere.
  58568. * @param force The force to dispose from the gravitational field event
  58569. */
  58570. dispose(force?: boolean): void;
  58571. private _tick;
  58572. }
  58573. /**
  58574. * Represents a physics updraft event
  58575. */
  58576. class PhysicsUpdraftEvent {
  58577. private _scene;
  58578. private _origin;
  58579. private _options;
  58580. private _physicsEngine;
  58581. private _originTop;
  58582. private _originDirection;
  58583. private _tickCallback;
  58584. private _cylinder;
  58585. private _cylinderPosition;
  58586. private _dataFetched;
  58587. /**
  58588. * Initializes the physics updraft event
  58589. * @param _scene BabylonJS scene
  58590. * @param _origin The origin position of the updraft
  58591. * @param _options The options for the updraft event
  58592. */
  58593. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  58594. /**
  58595. * Returns the data related to the updraft event (cylinder).
  58596. * @returns A physics updraft event
  58597. */
  58598. getData(): PhysicsUpdraftEventData;
  58599. /**
  58600. * Enables the updraft.
  58601. */
  58602. enable(): void;
  58603. /**
  58604. * Disables the updraft.
  58605. */
  58606. disable(): void;
  58607. /**
  58608. * Disposes the cylinder.
  58609. * @param force Specifies if the updraft should be disposed by force
  58610. */
  58611. dispose(force?: boolean): void;
  58612. private getImpostorHitData;
  58613. private _tick;
  58614. /*** Helpers ***/
  58615. private _prepareCylinder;
  58616. private _intersectsWithCylinder;
  58617. }
  58618. /**
  58619. * Represents a physics vortex event
  58620. */
  58621. class PhysicsVortexEvent {
  58622. private _scene;
  58623. private _origin;
  58624. private _options;
  58625. private _physicsEngine;
  58626. private _originTop;
  58627. private _tickCallback;
  58628. private _cylinder;
  58629. private _cylinderPosition;
  58630. private _dataFetched;
  58631. /**
  58632. * Initializes the physics vortex event
  58633. * @param _scene The BabylonJS scene
  58634. * @param _origin The origin position of the vortex
  58635. * @param _options The options for the vortex event
  58636. */
  58637. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  58638. /**
  58639. * Returns the data related to the vortex event (cylinder).
  58640. * @returns The physics vortex event data
  58641. */
  58642. getData(): PhysicsVortexEventData;
  58643. /**
  58644. * Enables the vortex.
  58645. */
  58646. enable(): void;
  58647. /**
  58648. * Disables the cortex.
  58649. */
  58650. disable(): void;
  58651. /**
  58652. * Disposes the sphere.
  58653. * @param force
  58654. */
  58655. dispose(force?: boolean): void;
  58656. private getImpostorHitData;
  58657. private _tick;
  58658. /*** Helpers ***/
  58659. private _prepareCylinder;
  58660. private _intersectsWithCylinder;
  58661. }
  58662. /**
  58663. * Options fot the radial explosion event
  58664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58665. */
  58666. export class PhysicsRadialExplosionEventOptions {
  58667. /**
  58668. * The radius of the sphere for the radial explosion.
  58669. */
  58670. radius: number;
  58671. /**
  58672. * The strenth of the explosion.
  58673. */
  58674. strength: number;
  58675. /**
  58676. * The strenght of the force in correspondence to the distance of the affected object
  58677. */
  58678. falloff: PhysicsRadialImpulseFalloff;
  58679. /**
  58680. * Sphere options for the radial explosion.
  58681. */
  58682. sphere: {
  58683. segments: number;
  58684. diameter: number;
  58685. };
  58686. /**
  58687. * Sphere options for the radial explosion.
  58688. */
  58689. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  58690. }
  58691. /**
  58692. * Options fot the updraft event
  58693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58694. */
  58695. export class PhysicsUpdraftEventOptions {
  58696. /**
  58697. * The radius of the cylinder for the vortex
  58698. */
  58699. radius: number;
  58700. /**
  58701. * The strenth of the updraft.
  58702. */
  58703. strength: number;
  58704. /**
  58705. * The height of the cylinder for the updraft.
  58706. */
  58707. height: number;
  58708. /**
  58709. * The mode for the the updraft.
  58710. */
  58711. updraftMode: PhysicsUpdraftMode;
  58712. }
  58713. /**
  58714. * Options fot the vortex event
  58715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58716. */
  58717. export class PhysicsVortexEventOptions {
  58718. /**
  58719. * The radius of the cylinder for the vortex
  58720. */
  58721. radius: number;
  58722. /**
  58723. * The strenth of the vortex.
  58724. */
  58725. strength: number;
  58726. /**
  58727. * The height of the cylinder for the vortex.
  58728. */
  58729. height: number;
  58730. /**
  58731. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  58732. */
  58733. centripetalForceThreshold: number;
  58734. /**
  58735. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  58736. */
  58737. centripetalForceMultiplier: number;
  58738. /**
  58739. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  58740. */
  58741. centrifugalForceMultiplier: number;
  58742. /**
  58743. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  58744. */
  58745. updraftForceMultiplier: number;
  58746. }
  58747. /**
  58748. * The strenght of the force in correspondence to the distance of the affected object
  58749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58750. */
  58751. export enum PhysicsRadialImpulseFalloff {
  58752. /** Defines that impulse is constant in strength across it's whole radius */
  58753. Constant = 0,
  58754. /** Defines that impulse gets weaker if it's further from the origin */
  58755. Linear = 1
  58756. }
  58757. /**
  58758. * The strength of the force in correspondence to the distance of the affected object
  58759. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58760. */
  58761. export enum PhysicsUpdraftMode {
  58762. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  58763. Center = 0,
  58764. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  58765. Perpendicular = 1
  58766. }
  58767. /**
  58768. * Interface for a physics hit data
  58769. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58770. */
  58771. export interface PhysicsHitData {
  58772. /**
  58773. * The force applied at the contact point
  58774. */
  58775. force: Vector3;
  58776. /**
  58777. * The contact point
  58778. */
  58779. contactPoint: Vector3;
  58780. /**
  58781. * The distance from the origin to the contact point
  58782. */
  58783. distanceFromOrigin: number;
  58784. }
  58785. /**
  58786. * Interface for radial explosion event data
  58787. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58788. */
  58789. export interface PhysicsRadialExplosionEventData {
  58790. /**
  58791. * A sphere used for the radial explosion event
  58792. */
  58793. sphere: Mesh;
  58794. }
  58795. /**
  58796. * Interface for gravitational field event data
  58797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58798. */
  58799. export interface PhysicsGravitationalFieldEventData {
  58800. /**
  58801. * A sphere mesh used for the gravitational field event
  58802. */
  58803. sphere: Mesh;
  58804. }
  58805. /**
  58806. * Interface for updraft event data
  58807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58808. */
  58809. export interface PhysicsUpdraftEventData {
  58810. /**
  58811. * A cylinder used for the updraft event
  58812. */
  58813. cylinder: Mesh;
  58814. }
  58815. /**
  58816. * Interface for vortex event data
  58817. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58818. */
  58819. export interface PhysicsVortexEventData {
  58820. /**
  58821. * A cylinder used for the vortex event
  58822. */
  58823. cylinder: Mesh;
  58824. }
  58825. /**
  58826. * Interface for an affected physics impostor
  58827. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  58828. */
  58829. export interface PhysicsAffectedImpostorWithData {
  58830. /**
  58831. * The impostor affected by the effect
  58832. */
  58833. impostor: PhysicsImpostor;
  58834. /**
  58835. * The data about the hit/horce from the explosion
  58836. */
  58837. hitData: PhysicsHitData;
  58838. }
  58839. }
  58840. declare module "babylonjs/Physics/Plugins/index" {
  58841. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  58842. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  58843. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  58844. }
  58845. declare module "babylonjs/Physics/index" {
  58846. export * from "babylonjs/Physics/IPhysicsEngine";
  58847. export * from "babylonjs/Physics/physicsEngine";
  58848. export * from "babylonjs/Physics/physicsEngineComponent";
  58849. export * from "babylonjs/Physics/physicsHelper";
  58850. export * from "babylonjs/Physics/physicsImpostor";
  58851. export * from "babylonjs/Physics/physicsJoint";
  58852. export * from "babylonjs/Physics/Plugins/index";
  58853. }
  58854. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  58855. /** @hidden */
  58856. export var blackAndWhitePixelShader: {
  58857. name: string;
  58858. shader: string;
  58859. };
  58860. }
  58861. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  58862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58863. import { Camera } from "babylonjs/Cameras/camera";
  58864. import { Engine } from "babylonjs/Engines/engine";
  58865. import "babylonjs/Shaders/blackAndWhite.fragment";
  58866. /**
  58867. * Post process used to render in black and white
  58868. */
  58869. export class BlackAndWhitePostProcess extends PostProcess {
  58870. /**
  58871. * Linear about to convert he result to black and white (default: 1)
  58872. */
  58873. degree: number;
  58874. /**
  58875. * Creates a black and white post process
  58876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  58877. * @param name The name of the effect.
  58878. * @param options The required width/height ratio to downsize to before computing the render pass.
  58879. * @param camera The camera to apply the render pass to.
  58880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58881. * @param engine The engine which the post process will be applied. (default: current engine)
  58882. * @param reusable If the post process can be reused on the same frame. (default: false)
  58883. */
  58884. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58885. }
  58886. }
  58887. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  58888. import { Nullable } from "babylonjs/types";
  58889. import { Camera } from "babylonjs/Cameras/camera";
  58890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58891. import { Engine } from "babylonjs/Engines/engine";
  58892. /**
  58893. * This represents a set of one or more post processes in Babylon.
  58894. * A post process can be used to apply a shader to a texture after it is rendered.
  58895. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58896. */
  58897. export class PostProcessRenderEffect {
  58898. private _postProcesses;
  58899. private _getPostProcesses;
  58900. private _singleInstance;
  58901. private _cameras;
  58902. private _indicesForCamera;
  58903. /**
  58904. * Name of the effect
  58905. * @hidden
  58906. */
  58907. _name: string;
  58908. /**
  58909. * Instantiates a post process render effect.
  58910. * A post process can be used to apply a shader to a texture after it is rendered.
  58911. * @param engine The engine the effect is tied to
  58912. * @param name The name of the effect
  58913. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  58914. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  58915. */
  58916. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  58917. /**
  58918. * Checks if all the post processes in the effect are supported.
  58919. */
  58920. readonly isSupported: boolean;
  58921. /**
  58922. * Updates the current state of the effect
  58923. * @hidden
  58924. */
  58925. _update(): void;
  58926. /**
  58927. * Attaches the effect on cameras
  58928. * @param cameras The camera to attach to.
  58929. * @hidden
  58930. */
  58931. _attachCameras(cameras: Camera): void;
  58932. /**
  58933. * Attaches the effect on cameras
  58934. * @param cameras The camera to attach to.
  58935. * @hidden
  58936. */
  58937. _attachCameras(cameras: Camera[]): void;
  58938. /**
  58939. * Detaches the effect on cameras
  58940. * @param cameras The camera to detatch from.
  58941. * @hidden
  58942. */
  58943. _detachCameras(cameras: Camera): void;
  58944. /**
  58945. * Detatches the effect on cameras
  58946. * @param cameras The camera to detatch from.
  58947. * @hidden
  58948. */
  58949. _detachCameras(cameras: Camera[]): void;
  58950. /**
  58951. * Enables the effect on given cameras
  58952. * @param cameras The camera to enable.
  58953. * @hidden
  58954. */
  58955. _enable(cameras: Camera): void;
  58956. /**
  58957. * Enables the effect on given cameras
  58958. * @param cameras The camera to enable.
  58959. * @hidden
  58960. */
  58961. _enable(cameras: Nullable<Camera[]>): void;
  58962. /**
  58963. * Disables the effect on the given cameras
  58964. * @param cameras The camera to disable.
  58965. * @hidden
  58966. */
  58967. _disable(cameras: Camera): void;
  58968. /**
  58969. * Disables the effect on the given cameras
  58970. * @param cameras The camera to disable.
  58971. * @hidden
  58972. */
  58973. _disable(cameras: Nullable<Camera[]>): void;
  58974. /**
  58975. * Gets a list of the post processes contained in the effect.
  58976. * @param camera The camera to get the post processes on.
  58977. * @returns The list of the post processes in the effect.
  58978. */
  58979. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  58980. }
  58981. }
  58982. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  58983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58984. /** @hidden */
  58985. export var extractHighlightsPixelShader: {
  58986. name: string;
  58987. shader: string;
  58988. };
  58989. }
  58990. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  58991. import { Nullable } from "babylonjs/types";
  58992. import { Camera } from "babylonjs/Cameras/camera";
  58993. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58994. import { Engine } from "babylonjs/Engines/engine";
  58995. import "babylonjs/Shaders/extractHighlights.fragment";
  58996. /**
  58997. * 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.
  58998. */
  58999. export class ExtractHighlightsPostProcess extends PostProcess {
  59000. /**
  59001. * The luminance threshold, pixels below this value will be set to black.
  59002. */
  59003. threshold: number;
  59004. /** @hidden */
  59005. _exposure: number;
  59006. /**
  59007. * Post process which has the input texture to be used when performing highlight extraction
  59008. * @hidden
  59009. */
  59010. _inputPostProcess: Nullable<PostProcess>;
  59011. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59012. }
  59013. }
  59014. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  59015. /** @hidden */
  59016. export var bloomMergePixelShader: {
  59017. name: string;
  59018. shader: string;
  59019. };
  59020. }
  59021. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  59022. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59023. import { Nullable } from "babylonjs/types";
  59024. import { Engine } from "babylonjs/Engines/engine";
  59025. import { Camera } from "babylonjs/Cameras/camera";
  59026. import "babylonjs/Shaders/bloomMerge.fragment";
  59027. /**
  59028. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59029. */
  59030. export class BloomMergePostProcess extends PostProcess {
  59031. /** Weight of the bloom to be added to the original input. */
  59032. weight: number;
  59033. /**
  59034. * Creates a new instance of @see BloomMergePostProcess
  59035. * @param name The name of the effect.
  59036. * @param originalFromInput Post process which's input will be used for the merge.
  59037. * @param blurred Blurred highlights post process which's output will be used.
  59038. * @param weight Weight of the bloom to be added to the original input.
  59039. * @param options The required width/height ratio to downsize to before computing the render pass.
  59040. * @param camera The camera to apply the render pass to.
  59041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59042. * @param engine The engine which the post process will be applied. (default: current engine)
  59043. * @param reusable If the post process can be reused on the same frame. (default: false)
  59044. * @param textureType Type of textures used when performing the post process. (default: 0)
  59045. * @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)
  59046. */
  59047. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  59048. /** Weight of the bloom to be added to the original input. */
  59049. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59050. }
  59051. }
  59052. declare module "babylonjs/PostProcesses/bloomEffect" {
  59053. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59054. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59055. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59056. import { Camera } from "babylonjs/Cameras/camera";
  59057. import { Scene } from "babylonjs/scene";
  59058. /**
  59059. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  59060. */
  59061. export class BloomEffect extends PostProcessRenderEffect {
  59062. private bloomScale;
  59063. /**
  59064. * @hidden Internal
  59065. */
  59066. _effects: Array<PostProcess>;
  59067. /**
  59068. * @hidden Internal
  59069. */
  59070. _downscale: ExtractHighlightsPostProcess;
  59071. private _blurX;
  59072. private _blurY;
  59073. private _merge;
  59074. /**
  59075. * The luminance threshold to find bright areas of the image to bloom.
  59076. */
  59077. threshold: number;
  59078. /**
  59079. * The strength of the bloom.
  59080. */
  59081. weight: number;
  59082. /**
  59083. * Specifies the size of the bloom blur kernel, relative to the final output size
  59084. */
  59085. kernel: number;
  59086. /**
  59087. * Creates a new instance of @see BloomEffect
  59088. * @param scene The scene the effect belongs to.
  59089. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  59090. * @param bloomKernel The size of the kernel to be used when applying the blur.
  59091. * @param bloomWeight The the strength of bloom.
  59092. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59093. * @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)
  59094. */
  59095. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  59096. /**
  59097. * Disposes each of the internal effects for a given camera.
  59098. * @param camera The camera to dispose the effect on.
  59099. */
  59100. disposeEffects(camera: Camera): void;
  59101. /**
  59102. * @hidden Internal
  59103. */
  59104. _updateEffects(): void;
  59105. /**
  59106. * Internal
  59107. * @returns if all the contained post processes are ready.
  59108. * @hidden
  59109. */
  59110. _isReady(): boolean;
  59111. }
  59112. }
  59113. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  59114. /** @hidden */
  59115. export var chromaticAberrationPixelShader: {
  59116. name: string;
  59117. shader: string;
  59118. };
  59119. }
  59120. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  59121. import { Vector2 } from "babylonjs/Maths/math.vector";
  59122. import { Nullable } from "babylonjs/types";
  59123. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59124. import { Camera } from "babylonjs/Cameras/camera";
  59125. import { Engine } from "babylonjs/Engines/engine";
  59126. import "babylonjs/Shaders/chromaticAberration.fragment";
  59127. /**
  59128. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  59129. */
  59130. export class ChromaticAberrationPostProcess extends PostProcess {
  59131. /**
  59132. * The amount of seperation of rgb channels (default: 30)
  59133. */
  59134. aberrationAmount: number;
  59135. /**
  59136. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  59137. */
  59138. radialIntensity: number;
  59139. /**
  59140. * 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))
  59141. */
  59142. direction: Vector2;
  59143. /**
  59144. * 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))
  59145. */
  59146. centerPosition: Vector2;
  59147. /**
  59148. * Creates a new instance ChromaticAberrationPostProcess
  59149. * @param name The name of the effect.
  59150. * @param screenWidth The width of the screen to apply the effect on.
  59151. * @param screenHeight The height of the screen to apply the effect on.
  59152. * @param options The required width/height ratio to downsize to before computing the render pass.
  59153. * @param camera The camera to apply the render pass to.
  59154. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59155. * @param engine The engine which the post process will be applied. (default: current engine)
  59156. * @param reusable If the post process can be reused on the same frame. (default: false)
  59157. * @param textureType Type of textures used when performing the post process. (default: 0)
  59158. * @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)
  59159. */
  59160. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59161. }
  59162. }
  59163. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  59164. /** @hidden */
  59165. export var circleOfConfusionPixelShader: {
  59166. name: string;
  59167. shader: string;
  59168. };
  59169. }
  59170. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  59171. import { Nullable } from "babylonjs/types";
  59172. import { Engine } from "babylonjs/Engines/engine";
  59173. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59174. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59175. import { Camera } from "babylonjs/Cameras/camera";
  59176. import "babylonjs/Shaders/circleOfConfusion.fragment";
  59177. /**
  59178. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  59179. */
  59180. export class CircleOfConfusionPostProcess extends PostProcess {
  59181. /**
  59182. * 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.
  59183. */
  59184. lensSize: number;
  59185. /**
  59186. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59187. */
  59188. fStop: number;
  59189. /**
  59190. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59191. */
  59192. focusDistance: number;
  59193. /**
  59194. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  59195. */
  59196. focalLength: number;
  59197. private _depthTexture;
  59198. /**
  59199. * Creates a new instance CircleOfConfusionPostProcess
  59200. * @param name The name of the effect.
  59201. * @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.
  59202. * @param options The required width/height ratio to downsize to before computing the render pass.
  59203. * @param camera The camera to apply the render pass to.
  59204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59205. * @param engine The engine which the post process will be applied. (default: current engine)
  59206. * @param reusable If the post process can be reused on the same frame. (default: false)
  59207. * @param textureType Type of textures used when performing the post process. (default: 0)
  59208. * @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)
  59209. */
  59210. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59211. /**
  59212. * 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.
  59213. */
  59214. depthTexture: RenderTargetTexture;
  59215. }
  59216. }
  59217. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  59218. /** @hidden */
  59219. export var colorCorrectionPixelShader: {
  59220. name: string;
  59221. shader: string;
  59222. };
  59223. }
  59224. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  59225. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59226. import { Engine } from "babylonjs/Engines/engine";
  59227. import { Camera } from "babylonjs/Cameras/camera";
  59228. import "babylonjs/Shaders/colorCorrection.fragment";
  59229. /**
  59230. *
  59231. * This post-process allows the modification of rendered colors by using
  59232. * a 'look-up table' (LUT). This effect is also called Color Grading.
  59233. *
  59234. * The object needs to be provided an url to a texture containing the color
  59235. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  59236. * Use an image editing software to tweak the LUT to match your needs.
  59237. *
  59238. * For an example of a color LUT, see here:
  59239. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  59240. * For explanations on color grading, see here:
  59241. * @see http://udn.epicgames.com/Three/ColorGrading.html
  59242. *
  59243. */
  59244. export class ColorCorrectionPostProcess extends PostProcess {
  59245. private _colorTableTexture;
  59246. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59247. }
  59248. }
  59249. declare module "babylonjs/Shaders/convolution.fragment" {
  59250. /** @hidden */
  59251. export var convolutionPixelShader: {
  59252. name: string;
  59253. shader: string;
  59254. };
  59255. }
  59256. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  59257. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59258. import { Nullable } from "babylonjs/types";
  59259. import { Camera } from "babylonjs/Cameras/camera";
  59260. import { Engine } from "babylonjs/Engines/engine";
  59261. import "babylonjs/Shaders/convolution.fragment";
  59262. /**
  59263. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  59264. * input texture to perform effects such as edge detection or sharpening
  59265. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  59266. */
  59267. export class ConvolutionPostProcess extends PostProcess {
  59268. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59269. kernel: number[];
  59270. /**
  59271. * Creates a new instance ConvolutionPostProcess
  59272. * @param name The name of the effect.
  59273. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  59274. * @param options The required width/height ratio to downsize to before computing the render pass.
  59275. * @param camera The camera to apply the render pass to.
  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. */
  59281. constructor(name: string,
  59282. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  59283. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59284. /**
  59285. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59286. */
  59287. static EdgeDetect0Kernel: number[];
  59288. /**
  59289. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59290. */
  59291. static EdgeDetect1Kernel: number[];
  59292. /**
  59293. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59294. */
  59295. static EdgeDetect2Kernel: number[];
  59296. /**
  59297. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59298. */
  59299. static SharpenKernel: number[];
  59300. /**
  59301. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59302. */
  59303. static EmbossKernel: number[];
  59304. /**
  59305. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  59306. */
  59307. static GaussianKernel: number[];
  59308. }
  59309. }
  59310. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  59311. import { Nullable } from "babylonjs/types";
  59312. import { Vector2 } from "babylonjs/Maths/math.vector";
  59313. import { Camera } from "babylonjs/Cameras/camera";
  59314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59315. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59316. import { Engine } from "babylonjs/Engines/engine";
  59317. import { Scene } from "babylonjs/scene";
  59318. /**
  59319. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  59320. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  59321. * based on samples that have a large difference in distance than the center pixel.
  59322. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  59323. */
  59324. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  59325. direction: Vector2;
  59326. /**
  59327. * Creates a new instance CircleOfConfusionPostProcess
  59328. * @param name The name of the effect.
  59329. * @param scene The scene the effect belongs to.
  59330. * @param direction The direction the blur should be applied.
  59331. * @param kernel The size of the kernel used to blur.
  59332. * @param options The required width/height ratio to downsize to before computing the render pass.
  59333. * @param camera The camera to apply the render pass to.
  59334. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  59335. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  59336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59337. * @param engine The engine which the post process will be applied. (default: current engine)
  59338. * @param reusable If the post process can be reused on the same frame. (default: false)
  59339. * @param textureType Type of textures used when performing the post process. (default: 0)
  59340. * @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)
  59341. */
  59342. 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);
  59343. }
  59344. }
  59345. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  59346. /** @hidden */
  59347. export var depthOfFieldMergePixelShader: {
  59348. name: string;
  59349. shader: string;
  59350. };
  59351. }
  59352. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  59353. import { Nullable } from "babylonjs/types";
  59354. import { Camera } from "babylonjs/Cameras/camera";
  59355. import { Effect } from "babylonjs/Materials/effect";
  59356. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59357. import { Engine } from "babylonjs/Engines/engine";
  59358. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  59359. /**
  59360. * Options to be set when merging outputs from the default pipeline.
  59361. */
  59362. export class DepthOfFieldMergePostProcessOptions {
  59363. /**
  59364. * The original image to merge on top of
  59365. */
  59366. originalFromInput: PostProcess;
  59367. /**
  59368. * Parameters to perform the merge of the depth of field effect
  59369. */
  59370. depthOfField?: {
  59371. circleOfConfusion: PostProcess;
  59372. blurSteps: Array<PostProcess>;
  59373. };
  59374. /**
  59375. * Parameters to perform the merge of bloom effect
  59376. */
  59377. bloom?: {
  59378. blurred: PostProcess;
  59379. weight: number;
  59380. };
  59381. }
  59382. /**
  59383. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  59384. */
  59385. export class DepthOfFieldMergePostProcess extends PostProcess {
  59386. private blurSteps;
  59387. /**
  59388. * Creates a new instance of DepthOfFieldMergePostProcess
  59389. * @param name The name of the effect.
  59390. * @param originalFromInput Post process which's input will be used for the merge.
  59391. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  59392. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  59393. * @param options The required width/height ratio to downsize to before computing the render pass.
  59394. * @param camera The camera to apply the render pass to.
  59395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59396. * @param engine The engine which the post process will be applied. (default: current engine)
  59397. * @param reusable If the post process can be reused on the same frame. (default: false)
  59398. * @param textureType Type of textures used when performing the post process. (default: 0)
  59399. * @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)
  59400. */
  59401. 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);
  59402. /**
  59403. * Updates the effect with the current post process compile time values and recompiles the shader.
  59404. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  59405. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  59406. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  59407. * @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
  59408. * @param onCompiled Called when the shader has been compiled.
  59409. * @param onError Called if there is an error when compiling a shader.
  59410. */
  59411. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  59412. }
  59413. }
  59414. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  59415. import { Nullable } from "babylonjs/types";
  59416. import { Camera } from "babylonjs/Cameras/camera";
  59417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59418. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59419. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59420. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59421. import { Scene } from "babylonjs/scene";
  59422. /**
  59423. * Specifies the level of max blur that should be applied when using the depth of field effect
  59424. */
  59425. export enum DepthOfFieldEffectBlurLevel {
  59426. /**
  59427. * Subtle blur
  59428. */
  59429. Low = 0,
  59430. /**
  59431. * Medium blur
  59432. */
  59433. Medium = 1,
  59434. /**
  59435. * Large blur
  59436. */
  59437. High = 2
  59438. }
  59439. /**
  59440. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  59441. */
  59442. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  59443. private _circleOfConfusion;
  59444. /**
  59445. * @hidden Internal, blurs from high to low
  59446. */
  59447. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  59448. private _depthOfFieldBlurY;
  59449. private _dofMerge;
  59450. /**
  59451. * @hidden Internal post processes in depth of field effect
  59452. */
  59453. _effects: Array<PostProcess>;
  59454. /**
  59455. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  59456. */
  59457. focalLength: number;
  59458. /**
  59459. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  59460. */
  59461. fStop: number;
  59462. /**
  59463. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  59464. */
  59465. focusDistance: number;
  59466. /**
  59467. * 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.
  59468. */
  59469. lensSize: number;
  59470. /**
  59471. * Creates a new instance DepthOfFieldEffect
  59472. * @param scene The scene the effect belongs to.
  59473. * @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.
  59474. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  59475. * @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)
  59476. */
  59477. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  59478. /**
  59479. * Get the current class name of the current effet
  59480. * @returns "DepthOfFieldEffect"
  59481. */
  59482. getClassName(): string;
  59483. /**
  59484. * 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.
  59485. */
  59486. depthTexture: RenderTargetTexture;
  59487. /**
  59488. * Disposes each of the internal effects for a given camera.
  59489. * @param camera The camera to dispose the effect on.
  59490. */
  59491. disposeEffects(camera: Camera): void;
  59492. /**
  59493. * @hidden Internal
  59494. */
  59495. _updateEffects(): void;
  59496. /**
  59497. * Internal
  59498. * @returns if all the contained post processes are ready.
  59499. * @hidden
  59500. */
  59501. _isReady(): boolean;
  59502. }
  59503. }
  59504. declare module "babylonjs/Shaders/displayPass.fragment" {
  59505. /** @hidden */
  59506. export var displayPassPixelShader: {
  59507. name: string;
  59508. shader: string;
  59509. };
  59510. }
  59511. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  59512. import { Nullable } from "babylonjs/types";
  59513. import { Camera } from "babylonjs/Cameras/camera";
  59514. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59515. import { Engine } from "babylonjs/Engines/engine";
  59516. import "babylonjs/Shaders/displayPass.fragment";
  59517. /**
  59518. * DisplayPassPostProcess which produces an output the same as it's input
  59519. */
  59520. export class DisplayPassPostProcess extends PostProcess {
  59521. /**
  59522. * Creates the DisplayPassPostProcess
  59523. * @param name The name of the effect.
  59524. * @param options The required width/height ratio to downsize to before computing the render pass.
  59525. * @param camera The camera to apply the render pass to.
  59526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59527. * @param engine The engine which the post process will be applied. (default: current engine)
  59528. * @param reusable If the post process can be reused on the same frame. (default: false)
  59529. */
  59530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59531. }
  59532. }
  59533. declare module "babylonjs/Shaders/filter.fragment" {
  59534. /** @hidden */
  59535. export var filterPixelShader: {
  59536. name: string;
  59537. shader: string;
  59538. };
  59539. }
  59540. declare module "babylonjs/PostProcesses/filterPostProcess" {
  59541. import { Nullable } from "babylonjs/types";
  59542. import { Matrix } from "babylonjs/Maths/math.vector";
  59543. import { Camera } from "babylonjs/Cameras/camera";
  59544. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59545. import { Engine } from "babylonjs/Engines/engine";
  59546. import "babylonjs/Shaders/filter.fragment";
  59547. /**
  59548. * Applies a kernel filter to the image
  59549. */
  59550. export class FilterPostProcess extends PostProcess {
  59551. /** The matrix to be applied to the image */
  59552. kernelMatrix: Matrix;
  59553. /**
  59554. *
  59555. * @param name The name of the effect.
  59556. * @param kernelMatrix The matrix to be applied to the image
  59557. * @param options The required width/height ratio to downsize to before computing the render pass.
  59558. * @param camera The camera to apply the render pass to.
  59559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59560. * @param engine The engine which the post process will be applied. (default: current engine)
  59561. * @param reusable If the post process can be reused on the same frame. (default: false)
  59562. */
  59563. constructor(name: string,
  59564. /** The matrix to be applied to the image */
  59565. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  59566. }
  59567. }
  59568. declare module "babylonjs/Shaders/fxaa.fragment" {
  59569. /** @hidden */
  59570. export var fxaaPixelShader: {
  59571. name: string;
  59572. shader: string;
  59573. };
  59574. }
  59575. declare module "babylonjs/Shaders/fxaa.vertex" {
  59576. /** @hidden */
  59577. export var fxaaVertexShader: {
  59578. name: string;
  59579. shader: string;
  59580. };
  59581. }
  59582. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  59583. import { Nullable } from "babylonjs/types";
  59584. import { Camera } from "babylonjs/Cameras/camera";
  59585. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59586. import { Engine } from "babylonjs/Engines/engine";
  59587. import "babylonjs/Shaders/fxaa.fragment";
  59588. import "babylonjs/Shaders/fxaa.vertex";
  59589. /**
  59590. * Fxaa post process
  59591. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  59592. */
  59593. export class FxaaPostProcess extends PostProcess {
  59594. /** @hidden */
  59595. texelWidth: number;
  59596. /** @hidden */
  59597. texelHeight: number;
  59598. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59599. private _getDefines;
  59600. }
  59601. }
  59602. declare module "babylonjs/Shaders/grain.fragment" {
  59603. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59604. /** @hidden */
  59605. export var grainPixelShader: {
  59606. name: string;
  59607. shader: string;
  59608. };
  59609. }
  59610. declare module "babylonjs/PostProcesses/grainPostProcess" {
  59611. import { Nullable } from "babylonjs/types";
  59612. import { Camera } from "babylonjs/Cameras/camera";
  59613. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59614. import { Engine } from "babylonjs/Engines/engine";
  59615. import "babylonjs/Shaders/grain.fragment";
  59616. /**
  59617. * The GrainPostProcess adds noise to the image at mid luminance levels
  59618. */
  59619. export class GrainPostProcess extends PostProcess {
  59620. /**
  59621. * The intensity of the grain added (default: 30)
  59622. */
  59623. intensity: number;
  59624. /**
  59625. * If the grain should be randomized on every frame
  59626. */
  59627. animated: boolean;
  59628. /**
  59629. * Creates a new instance of @see GrainPostProcess
  59630. * @param name The name of the effect.
  59631. * @param options The required width/height ratio to downsize to before computing the render pass.
  59632. * @param camera The camera to apply the render pass to.
  59633. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59634. * @param engine The engine which the post process will be applied. (default: current engine)
  59635. * @param reusable If the post process can be reused on the same frame. (default: false)
  59636. * @param textureType Type of textures used when performing the post process. (default: 0)
  59637. * @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)
  59638. */
  59639. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59640. }
  59641. }
  59642. declare module "babylonjs/Shaders/highlights.fragment" {
  59643. /** @hidden */
  59644. export var highlightsPixelShader: {
  59645. name: string;
  59646. shader: string;
  59647. };
  59648. }
  59649. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  59650. import { Nullable } from "babylonjs/types";
  59651. import { Camera } from "babylonjs/Cameras/camera";
  59652. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59653. import { Engine } from "babylonjs/Engines/engine";
  59654. import "babylonjs/Shaders/highlights.fragment";
  59655. /**
  59656. * Extracts highlights from the image
  59657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59658. */
  59659. export class HighlightsPostProcess extends PostProcess {
  59660. /**
  59661. * Extracts highlights from the image
  59662. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  59663. * @param name The name of the effect.
  59664. * @param options The required width/height ratio to downsize to before computing the render pass.
  59665. * @param camera The camera to apply the render pass to.
  59666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59667. * @param engine The engine which the post process will be applied. (default: current engine)
  59668. * @param reusable If the post process can be reused on the same frame. (default: false)
  59669. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  59670. */
  59671. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  59672. }
  59673. }
  59674. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  59675. /** @hidden */
  59676. export var mrtFragmentDeclaration: {
  59677. name: string;
  59678. shader: string;
  59679. };
  59680. }
  59681. declare module "babylonjs/Shaders/geometry.fragment" {
  59682. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  59683. /** @hidden */
  59684. export var geometryPixelShader: {
  59685. name: string;
  59686. shader: string;
  59687. };
  59688. }
  59689. declare module "babylonjs/Shaders/geometry.vertex" {
  59690. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59691. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59692. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59693. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59694. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59695. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59696. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59697. /** @hidden */
  59698. export var geometryVertexShader: {
  59699. name: string;
  59700. shader: string;
  59701. };
  59702. }
  59703. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  59704. import { Matrix } from "babylonjs/Maths/math.vector";
  59705. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59706. import { Mesh } from "babylonjs/Meshes/mesh";
  59707. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  59708. import { Effect } from "babylonjs/Materials/effect";
  59709. import { Scene } from "babylonjs/scene";
  59710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59711. import "babylonjs/Shaders/geometry.fragment";
  59712. import "babylonjs/Shaders/geometry.vertex";
  59713. /** @hidden */
  59714. interface ISavedTransformationMatrix {
  59715. world: Matrix;
  59716. viewProjection: Matrix;
  59717. }
  59718. /**
  59719. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  59720. */
  59721. export class GeometryBufferRenderer {
  59722. /**
  59723. * Constant used to retrieve the position texture index in the G-Buffer textures array
  59724. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  59725. */
  59726. static readonly POSITION_TEXTURE_TYPE: number;
  59727. /**
  59728. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  59729. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  59730. */
  59731. static readonly VELOCITY_TEXTURE_TYPE: number;
  59732. /**
  59733. * Dictionary used to store the previous transformation matrices of each rendered mesh
  59734. * in order to compute objects velocities when enableVelocity is set to "true"
  59735. * @hidden
  59736. */
  59737. _previousTransformationMatrices: {
  59738. [index: number]: ISavedTransformationMatrix;
  59739. };
  59740. /**
  59741. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  59742. * in order to compute objects velocities when enableVelocity is set to "true"
  59743. * @hidden
  59744. */
  59745. _previousBonesTransformationMatrices: {
  59746. [index: number]: Float32Array;
  59747. };
  59748. /**
  59749. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  59750. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  59751. */
  59752. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  59753. private _scene;
  59754. private _multiRenderTarget;
  59755. private _ratio;
  59756. private _enablePosition;
  59757. private _enableVelocity;
  59758. private _positionIndex;
  59759. private _velocityIndex;
  59760. protected _effect: Effect;
  59761. protected _cachedDefines: string;
  59762. /**
  59763. * Set the render list (meshes to be rendered) used in the G buffer.
  59764. */
  59765. renderList: Mesh[];
  59766. /**
  59767. * Gets wether or not G buffer are supported by the running hardware.
  59768. * This requires draw buffer supports
  59769. */
  59770. readonly isSupported: boolean;
  59771. /**
  59772. * Returns the index of the given texture type in the G-Buffer textures array
  59773. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  59774. * @returns the index of the given texture type in the G-Buffer textures array
  59775. */
  59776. getTextureIndex(textureType: number): number;
  59777. /**
  59778. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  59779. */
  59780. /**
  59781. * Sets whether or not objects positions are enabled for the G buffer.
  59782. */
  59783. enablePosition: boolean;
  59784. /**
  59785. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  59786. */
  59787. /**
  59788. * Sets wether or not objects velocities are enabled for the G buffer.
  59789. */
  59790. enableVelocity: boolean;
  59791. /**
  59792. * Gets the scene associated with the buffer.
  59793. */
  59794. readonly scene: Scene;
  59795. /**
  59796. * Gets the ratio used by the buffer during its creation.
  59797. * How big is the buffer related to the main canvas.
  59798. */
  59799. readonly ratio: number;
  59800. /** @hidden */
  59801. static _SceneComponentInitialization: (scene: Scene) => void;
  59802. /**
  59803. * Creates a new G Buffer for the scene
  59804. * @param scene The scene the buffer belongs to
  59805. * @param ratio How big is the buffer related to the main canvas.
  59806. */
  59807. constructor(scene: Scene, ratio?: number);
  59808. /**
  59809. * Checks wether everything is ready to render a submesh to the G buffer.
  59810. * @param subMesh the submesh to check readiness for
  59811. * @param useInstances is the mesh drawn using instance or not
  59812. * @returns true if ready otherwise false
  59813. */
  59814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59815. /**
  59816. * Gets the current underlying G Buffer.
  59817. * @returns the buffer
  59818. */
  59819. getGBuffer(): MultiRenderTarget;
  59820. /**
  59821. * Gets the number of samples used to render the buffer (anti aliasing).
  59822. */
  59823. /**
  59824. * Sets the number of samples used to render the buffer (anti aliasing).
  59825. */
  59826. samples: number;
  59827. /**
  59828. * Disposes the renderer and frees up associated resources.
  59829. */
  59830. dispose(): void;
  59831. protected _createRenderTargets(): void;
  59832. private _copyBonesTransformationMatrices;
  59833. }
  59834. }
  59835. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  59836. import { Nullable } from "babylonjs/types";
  59837. import { Scene } from "babylonjs/scene";
  59838. import { ISceneComponent } from "babylonjs/sceneComponent";
  59839. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  59840. module "babylonjs/scene" {
  59841. interface Scene {
  59842. /** @hidden (Backing field) */
  59843. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59844. /**
  59845. * Gets or Sets the current geometry buffer associated to the scene.
  59846. */
  59847. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  59848. /**
  59849. * Enables a GeometryBufferRender and associates it with the scene
  59850. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  59851. * @returns the GeometryBufferRenderer
  59852. */
  59853. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  59854. /**
  59855. * Disables the GeometryBufferRender associated with the scene
  59856. */
  59857. disableGeometryBufferRenderer(): void;
  59858. }
  59859. }
  59860. /**
  59861. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  59862. * in several rendering techniques.
  59863. */
  59864. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  59865. /**
  59866. * The component name helpful to identify the component in the list of scene components.
  59867. */
  59868. readonly name: string;
  59869. /**
  59870. * The scene the component belongs to.
  59871. */
  59872. scene: Scene;
  59873. /**
  59874. * Creates a new instance of the component for the given scene
  59875. * @param scene Defines the scene to register the component in
  59876. */
  59877. constructor(scene: Scene);
  59878. /**
  59879. * Registers the component in a given scene
  59880. */
  59881. register(): void;
  59882. /**
  59883. * Rebuilds the elements related to this component in case of
  59884. * context lost for instance.
  59885. */
  59886. rebuild(): void;
  59887. /**
  59888. * Disposes the component and the associated ressources
  59889. */
  59890. dispose(): void;
  59891. private _gatherRenderTargets;
  59892. }
  59893. }
  59894. declare module "babylonjs/Shaders/motionBlur.fragment" {
  59895. /** @hidden */
  59896. export var motionBlurPixelShader: {
  59897. name: string;
  59898. shader: string;
  59899. };
  59900. }
  59901. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  59902. import { Nullable } from "babylonjs/types";
  59903. import { Camera } from "babylonjs/Cameras/camera";
  59904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59905. import { Scene } from "babylonjs/scene";
  59906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59907. import "babylonjs/Animations/animatable";
  59908. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59909. import "babylonjs/Shaders/motionBlur.fragment";
  59910. import { Engine } from "babylonjs/Engines/engine";
  59911. /**
  59912. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  59913. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  59914. * As an example, all you have to do is to create the post-process:
  59915. * var mb = new BABYLON.MotionBlurPostProcess(
  59916. * 'mb', // The name of the effect.
  59917. * scene, // The scene containing the objects to blur according to their velocity.
  59918. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  59919. * camera // The camera to apply the render pass to.
  59920. * );
  59921. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  59922. */
  59923. export class MotionBlurPostProcess extends PostProcess {
  59924. /**
  59925. * Defines how much the image is blurred by the movement. Default value is equal to 1
  59926. */
  59927. motionStrength: number;
  59928. /**
  59929. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  59930. */
  59931. /**
  59932. * Sets the number of iterations to be used for motion blur quality
  59933. */
  59934. motionBlurSamples: number;
  59935. private _motionBlurSamples;
  59936. private _geometryBufferRenderer;
  59937. /**
  59938. * Creates a new instance MotionBlurPostProcess
  59939. * @param name The name of the effect.
  59940. * @param scene The scene containing the objects to blur according to their velocity.
  59941. * @param options The required width/height ratio to downsize to before computing the render pass.
  59942. * @param camera The camera to apply the render pass to.
  59943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  59944. * @param engine The engine which the post process will be applied. (default: current engine)
  59945. * @param reusable If the post process can be reused on the same frame. (default: false)
  59946. * @param textureType Type of textures used when performing the post process. (default: 0)
  59947. * @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)
  59948. */
  59949. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  59950. /**
  59951. * Excludes the given skinned mesh from computing bones velocities.
  59952. * 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.
  59953. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  59954. */
  59955. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59956. /**
  59957. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  59958. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  59959. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  59960. */
  59961. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  59962. /**
  59963. * Disposes the post process.
  59964. * @param camera The camera to dispose the post process on.
  59965. */
  59966. dispose(camera?: Camera): void;
  59967. }
  59968. }
  59969. declare module "babylonjs/Shaders/refraction.fragment" {
  59970. /** @hidden */
  59971. export var refractionPixelShader: {
  59972. name: string;
  59973. shader: string;
  59974. };
  59975. }
  59976. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  59977. import { Color3 } from "babylonjs/Maths/math.color";
  59978. import { Camera } from "babylonjs/Cameras/camera";
  59979. import { Texture } from "babylonjs/Materials/Textures/texture";
  59980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  59981. import { Engine } from "babylonjs/Engines/engine";
  59982. import "babylonjs/Shaders/refraction.fragment";
  59983. /**
  59984. * Post process which applies a refractin texture
  59985. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  59986. */
  59987. export class RefractionPostProcess extends PostProcess {
  59988. /** the base color of the refraction (used to taint the rendering) */
  59989. color: Color3;
  59990. /** simulated refraction depth */
  59991. depth: number;
  59992. /** the coefficient of the base color (0 to remove base color tainting) */
  59993. colorLevel: number;
  59994. private _refTexture;
  59995. private _ownRefractionTexture;
  59996. /**
  59997. * Gets or sets the refraction texture
  59998. * Please note that you are responsible for disposing the texture if you set it manually
  59999. */
  60000. refractionTexture: Texture;
  60001. /**
  60002. * Initializes the RefractionPostProcess
  60003. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  60004. * @param name The name of the effect.
  60005. * @param refractionTextureUrl Url of the refraction texture to use
  60006. * @param color the base color of the refraction (used to taint the rendering)
  60007. * @param depth simulated refraction depth
  60008. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  60009. * @param camera The camera to apply the render pass to.
  60010. * @param options The required width/height ratio to downsize to before computing the render pass.
  60011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60012. * @param engine The engine which the post process will be applied. (default: current engine)
  60013. * @param reusable If the post process can be reused on the same frame. (default: false)
  60014. */
  60015. constructor(name: string, refractionTextureUrl: string,
  60016. /** the base color of the refraction (used to taint the rendering) */
  60017. color: Color3,
  60018. /** simulated refraction depth */
  60019. depth: number,
  60020. /** the coefficient of the base color (0 to remove base color tainting) */
  60021. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  60022. /**
  60023. * Disposes of the post process
  60024. * @param camera Camera to dispose post process on
  60025. */
  60026. dispose(camera: Camera): void;
  60027. }
  60028. }
  60029. declare module "babylonjs/Shaders/sharpen.fragment" {
  60030. /** @hidden */
  60031. export var sharpenPixelShader: {
  60032. name: string;
  60033. shader: string;
  60034. };
  60035. }
  60036. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  60037. import { Nullable } from "babylonjs/types";
  60038. import { Camera } from "babylonjs/Cameras/camera";
  60039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  60040. import "babylonjs/Shaders/sharpen.fragment";
  60041. import { Engine } from "babylonjs/Engines/engine";
  60042. /**
  60043. * The SharpenPostProcess applies a sharpen kernel to every pixel
  60044. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  60045. */
  60046. export class SharpenPostProcess extends PostProcess {
  60047. /**
  60048. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  60049. */
  60050. colorAmount: number;
  60051. /**
  60052. * How much sharpness should be applied (default: 0.3)
  60053. */
  60054. edgeAmount: number;
  60055. /**
  60056. * Creates a new instance ConvolutionPostProcess
  60057. * @param name The name of the effect.
  60058. * @param options The required width/height ratio to downsize to before computing the render pass.
  60059. * @param camera The camera to apply the render pass to.
  60060. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  60061. * @param engine The engine which the post process will be applied. (default: current engine)
  60062. * @param reusable If the post process can be reused on the same frame. (default: false)
  60063. * @param textureType Type of textures used when performing the post process. (default: 0)
  60064. * @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)
  60065. */
  60066. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  60067. }
  60068. }
  60069. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  60070. import { Nullable } from "babylonjs/types";
  60071. import { Camera } from "babylonjs/Cameras/camera";
  60072. import { Engine } from "babylonjs/Engines/engine";
  60073. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60074. import { IInspectable } from "babylonjs/Misc/iInspectable";
  60075. /**
  60076. * PostProcessRenderPipeline
  60077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60078. */
  60079. export class PostProcessRenderPipeline {
  60080. private engine;
  60081. private _renderEffects;
  60082. private _renderEffectsForIsolatedPass;
  60083. /**
  60084. * List of inspectable custom properties (used by the Inspector)
  60085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  60086. */
  60087. inspectableCustomProperties: IInspectable[];
  60088. /**
  60089. * @hidden
  60090. */
  60091. protected _cameras: Camera[];
  60092. /** @hidden */
  60093. _name: string;
  60094. /**
  60095. * Gets pipeline name
  60096. */
  60097. readonly name: string;
  60098. /**
  60099. * Initializes a PostProcessRenderPipeline
  60100. * @param engine engine to add the pipeline to
  60101. * @param name name of the pipeline
  60102. */
  60103. constructor(engine: Engine, name: string);
  60104. /**
  60105. * Gets the class name
  60106. * @returns "PostProcessRenderPipeline"
  60107. */
  60108. getClassName(): string;
  60109. /**
  60110. * If all the render effects in the pipeline are supported
  60111. */
  60112. readonly isSupported: boolean;
  60113. /**
  60114. * Adds an effect to the pipeline
  60115. * @param renderEffect the effect to add
  60116. */
  60117. addEffect(renderEffect: PostProcessRenderEffect): void;
  60118. /** @hidden */
  60119. _rebuild(): void;
  60120. /** @hidden */
  60121. _enableEffect(renderEffectName: string, cameras: Camera): void;
  60122. /** @hidden */
  60123. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  60124. /** @hidden */
  60125. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60126. /** @hidden */
  60127. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  60128. /** @hidden */
  60129. _attachCameras(cameras: Camera, unique: boolean): void;
  60130. /** @hidden */
  60131. _attachCameras(cameras: Camera[], unique: boolean): void;
  60132. /** @hidden */
  60133. _detachCameras(cameras: Camera): void;
  60134. /** @hidden */
  60135. _detachCameras(cameras: Nullable<Camera[]>): void;
  60136. /** @hidden */
  60137. _update(): void;
  60138. /** @hidden */
  60139. _reset(): void;
  60140. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  60141. /**
  60142. * Disposes of the pipeline
  60143. */
  60144. dispose(): void;
  60145. }
  60146. }
  60147. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  60148. import { Camera } from "babylonjs/Cameras/camera";
  60149. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60150. /**
  60151. * PostProcessRenderPipelineManager class
  60152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60153. */
  60154. export class PostProcessRenderPipelineManager {
  60155. private _renderPipelines;
  60156. /**
  60157. * Initializes a PostProcessRenderPipelineManager
  60158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60159. */
  60160. constructor();
  60161. /**
  60162. * Gets the list of supported render pipelines
  60163. */
  60164. readonly supportedPipelines: PostProcessRenderPipeline[];
  60165. /**
  60166. * Adds a pipeline to the manager
  60167. * @param renderPipeline The pipeline to add
  60168. */
  60169. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  60170. /**
  60171. * Attaches a camera to the pipeline
  60172. * @param renderPipelineName The name of the pipeline to attach to
  60173. * @param cameras the camera to attach
  60174. * @param unique if the camera can be attached multiple times to the pipeline
  60175. */
  60176. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  60177. /**
  60178. * Detaches a camera from the pipeline
  60179. * @param renderPipelineName The name of the pipeline to detach from
  60180. * @param cameras the camera to detach
  60181. */
  60182. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  60183. /**
  60184. * Enables an effect by name on a pipeline
  60185. * @param renderPipelineName the name of the pipeline to enable the effect in
  60186. * @param renderEffectName the name of the effect to enable
  60187. * @param cameras the cameras that the effect should be enabled on
  60188. */
  60189. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60190. /**
  60191. * Disables an effect by name on a pipeline
  60192. * @param renderPipelineName the name of the pipeline to disable the effect in
  60193. * @param renderEffectName the name of the effect to disable
  60194. * @param cameras the cameras that the effect should be disabled on
  60195. */
  60196. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  60197. /**
  60198. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  60199. */
  60200. update(): void;
  60201. /** @hidden */
  60202. _rebuild(): void;
  60203. /**
  60204. * Disposes of the manager and pipelines
  60205. */
  60206. dispose(): void;
  60207. }
  60208. }
  60209. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  60210. import { ISceneComponent } from "babylonjs/sceneComponent";
  60211. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60212. import { Scene } from "babylonjs/scene";
  60213. module "babylonjs/scene" {
  60214. interface Scene {
  60215. /** @hidden (Backing field) */
  60216. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60217. /**
  60218. * Gets the postprocess render pipeline manager
  60219. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  60220. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60221. */
  60222. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  60223. }
  60224. }
  60225. /**
  60226. * Defines the Render Pipeline scene component responsible to rendering pipelines
  60227. */
  60228. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  60229. /**
  60230. * The component name helpfull to identify the component in the list of scene components.
  60231. */
  60232. readonly name: string;
  60233. /**
  60234. * The scene the component belongs to.
  60235. */
  60236. scene: Scene;
  60237. /**
  60238. * Creates a new instance of the component for the given scene
  60239. * @param scene Defines the scene to register the component in
  60240. */
  60241. constructor(scene: Scene);
  60242. /**
  60243. * Registers the component in a given scene
  60244. */
  60245. register(): void;
  60246. /**
  60247. * Rebuilds the elements related to this component in case of
  60248. * context lost for instance.
  60249. */
  60250. rebuild(): void;
  60251. /**
  60252. * Disposes the component and the associated ressources
  60253. */
  60254. dispose(): void;
  60255. private _gatherRenderTargets;
  60256. }
  60257. }
  60258. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  60259. import { Nullable } from "babylonjs/types";
  60260. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60261. import { Camera } from "babylonjs/Cameras/camera";
  60262. import { IDisposable } from "babylonjs/scene";
  60263. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  60264. import { Scene } from "babylonjs/scene";
  60265. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  60266. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60267. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60268. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  60269. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  60270. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60271. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  60272. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60273. import { Animation } from "babylonjs/Animations/animation";
  60274. /**
  60275. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  60276. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  60277. */
  60278. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  60279. private _scene;
  60280. private _camerasToBeAttached;
  60281. /**
  60282. * ID of the sharpen post process,
  60283. */
  60284. private readonly SharpenPostProcessId;
  60285. /**
  60286. * @ignore
  60287. * ID of the image processing post process;
  60288. */
  60289. readonly ImageProcessingPostProcessId: string;
  60290. /**
  60291. * @ignore
  60292. * ID of the Fast Approximate Anti-Aliasing post process;
  60293. */
  60294. readonly FxaaPostProcessId: string;
  60295. /**
  60296. * ID of the chromatic aberration post process,
  60297. */
  60298. private readonly ChromaticAberrationPostProcessId;
  60299. /**
  60300. * ID of the grain post process
  60301. */
  60302. private readonly GrainPostProcessId;
  60303. /**
  60304. * Sharpen post process which will apply a sharpen convolution to enhance edges
  60305. */
  60306. sharpen: SharpenPostProcess;
  60307. private _sharpenEffect;
  60308. private bloom;
  60309. /**
  60310. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  60311. */
  60312. depthOfField: DepthOfFieldEffect;
  60313. /**
  60314. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  60315. */
  60316. fxaa: FxaaPostProcess;
  60317. /**
  60318. * Image post processing pass used to perform operations such as tone mapping or color grading.
  60319. */
  60320. imageProcessing: ImageProcessingPostProcess;
  60321. /**
  60322. * Chromatic aberration post process which will shift rgb colors in the image
  60323. */
  60324. chromaticAberration: ChromaticAberrationPostProcess;
  60325. private _chromaticAberrationEffect;
  60326. /**
  60327. * Grain post process which add noise to the image
  60328. */
  60329. grain: GrainPostProcess;
  60330. private _grainEffect;
  60331. /**
  60332. * Glow post process which adds a glow to emissive areas of the image
  60333. */
  60334. private _glowLayer;
  60335. /**
  60336. * Animations which can be used to tweak settings over a period of time
  60337. */
  60338. animations: Animation[];
  60339. private _imageProcessingConfigurationObserver;
  60340. private _sharpenEnabled;
  60341. private _bloomEnabled;
  60342. private _depthOfFieldEnabled;
  60343. private _depthOfFieldBlurLevel;
  60344. private _fxaaEnabled;
  60345. private _imageProcessingEnabled;
  60346. private _defaultPipelineTextureType;
  60347. private _bloomScale;
  60348. private _chromaticAberrationEnabled;
  60349. private _grainEnabled;
  60350. private _buildAllowed;
  60351. /**
  60352. * Gets active scene
  60353. */
  60354. readonly scene: Scene;
  60355. /**
  60356. * Enable or disable the sharpen process from the pipeline
  60357. */
  60358. sharpenEnabled: boolean;
  60359. private _resizeObserver;
  60360. private _hardwareScaleLevel;
  60361. private _bloomKernel;
  60362. /**
  60363. * Specifies the size of the bloom blur kernel, relative to the final output size
  60364. */
  60365. bloomKernel: number;
  60366. /**
  60367. * Specifies the weight of the bloom in the final rendering
  60368. */
  60369. private _bloomWeight;
  60370. /**
  60371. * Specifies the luma threshold for the area that will be blurred by the bloom
  60372. */
  60373. private _bloomThreshold;
  60374. private _hdr;
  60375. /**
  60376. * The strength of the bloom.
  60377. */
  60378. bloomWeight: number;
  60379. /**
  60380. * The strength of the bloom.
  60381. */
  60382. bloomThreshold: number;
  60383. /**
  60384. * The scale of the bloom, lower value will provide better performance.
  60385. */
  60386. bloomScale: number;
  60387. /**
  60388. * Enable or disable the bloom from the pipeline
  60389. */
  60390. bloomEnabled: boolean;
  60391. private _rebuildBloom;
  60392. /**
  60393. * If the depth of field is enabled.
  60394. */
  60395. depthOfFieldEnabled: boolean;
  60396. /**
  60397. * Blur level of the depth of field effect. (Higher blur will effect performance)
  60398. */
  60399. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  60400. /**
  60401. * If the anti aliasing is enabled.
  60402. */
  60403. fxaaEnabled: boolean;
  60404. private _samples;
  60405. /**
  60406. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60407. */
  60408. samples: number;
  60409. /**
  60410. * If image processing is enabled.
  60411. */
  60412. imageProcessingEnabled: boolean;
  60413. /**
  60414. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  60415. */
  60416. glowLayerEnabled: boolean;
  60417. /**
  60418. * Gets the glow layer (or null if not defined)
  60419. */
  60420. readonly glowLayer: Nullable<GlowLayer>;
  60421. /**
  60422. * Enable or disable the chromaticAberration process from the pipeline
  60423. */
  60424. chromaticAberrationEnabled: boolean;
  60425. /**
  60426. * Enable or disable the grain process from the pipeline
  60427. */
  60428. grainEnabled: boolean;
  60429. /**
  60430. * @constructor
  60431. * @param name - The rendering pipeline name (default: "")
  60432. * @param hdr - If high dynamic range textures should be used (default: true)
  60433. * @param scene - The scene linked to this pipeline (default: the last created scene)
  60434. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  60435. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  60436. */
  60437. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  60438. /**
  60439. * Get the class name
  60440. * @returns "DefaultRenderingPipeline"
  60441. */
  60442. getClassName(): string;
  60443. /**
  60444. * Force the compilation of the entire pipeline.
  60445. */
  60446. prepare(): void;
  60447. private _hasCleared;
  60448. private _prevPostProcess;
  60449. private _prevPrevPostProcess;
  60450. private _setAutoClearAndTextureSharing;
  60451. private _depthOfFieldSceneObserver;
  60452. private _buildPipeline;
  60453. private _disposePostProcesses;
  60454. /**
  60455. * Adds a camera to the pipeline
  60456. * @param camera the camera to be added
  60457. */
  60458. addCamera(camera: Camera): void;
  60459. /**
  60460. * Removes a camera from the pipeline
  60461. * @param camera the camera to remove
  60462. */
  60463. removeCamera(camera: Camera): void;
  60464. /**
  60465. * Dispose of the pipeline and stop all post processes
  60466. */
  60467. dispose(): void;
  60468. /**
  60469. * Serialize the rendering pipeline (Used when exporting)
  60470. * @returns the serialized object
  60471. */
  60472. serialize(): any;
  60473. /**
  60474. * Parse the serialized pipeline
  60475. * @param source Source pipeline.
  60476. * @param scene The scene to load the pipeline to.
  60477. * @param rootUrl The URL of the serialized pipeline.
  60478. * @returns An instantiated pipeline from the serialized object.
  60479. */
  60480. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  60481. }
  60482. }
  60483. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  60484. /** @hidden */
  60485. export var lensHighlightsPixelShader: {
  60486. name: string;
  60487. shader: string;
  60488. };
  60489. }
  60490. declare module "babylonjs/Shaders/depthOfField.fragment" {
  60491. /** @hidden */
  60492. export var depthOfFieldPixelShader: {
  60493. name: string;
  60494. shader: string;
  60495. };
  60496. }
  60497. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  60498. import { Camera } from "babylonjs/Cameras/camera";
  60499. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60500. import { Scene } from "babylonjs/scene";
  60501. import "babylonjs/Shaders/chromaticAberration.fragment";
  60502. import "babylonjs/Shaders/lensHighlights.fragment";
  60503. import "babylonjs/Shaders/depthOfField.fragment";
  60504. /**
  60505. * BABYLON.JS Chromatic Aberration GLSL Shader
  60506. * Author: Olivier Guyot
  60507. * Separates very slightly R, G and B colors on the edges of the screen
  60508. * Inspired by Francois Tarlier & Martins Upitis
  60509. */
  60510. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  60511. /**
  60512. * @ignore
  60513. * The chromatic aberration PostProcess id in the pipeline
  60514. */
  60515. LensChromaticAberrationEffect: string;
  60516. /**
  60517. * @ignore
  60518. * The highlights enhancing PostProcess id in the pipeline
  60519. */
  60520. HighlightsEnhancingEffect: string;
  60521. /**
  60522. * @ignore
  60523. * The depth-of-field PostProcess id in the pipeline
  60524. */
  60525. LensDepthOfFieldEffect: string;
  60526. private _scene;
  60527. private _depthTexture;
  60528. private _grainTexture;
  60529. private _chromaticAberrationPostProcess;
  60530. private _highlightsPostProcess;
  60531. private _depthOfFieldPostProcess;
  60532. private _edgeBlur;
  60533. private _grainAmount;
  60534. private _chromaticAberration;
  60535. private _distortion;
  60536. private _highlightsGain;
  60537. private _highlightsThreshold;
  60538. private _dofDistance;
  60539. private _dofAperture;
  60540. private _dofDarken;
  60541. private _dofPentagon;
  60542. private _blurNoise;
  60543. /**
  60544. * @constructor
  60545. *
  60546. * Effect parameters are as follow:
  60547. * {
  60548. * chromatic_aberration: number; // from 0 to x (1 for realism)
  60549. * edge_blur: number; // from 0 to x (1 for realism)
  60550. * distortion: number; // from 0 to x (1 for realism)
  60551. * grain_amount: number; // from 0 to 1
  60552. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  60553. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  60554. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  60555. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  60556. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  60557. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  60558. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  60559. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  60560. * }
  60561. * Note: if an effect parameter is unset, effect is disabled
  60562. *
  60563. * @param name The rendering pipeline name
  60564. * @param parameters - An object containing all parameters (see above)
  60565. * @param scene The scene linked to this pipeline
  60566. * @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)
  60567. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60568. */
  60569. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  60570. /**
  60571. * Get the class name
  60572. * @returns "LensRenderingPipeline"
  60573. */
  60574. getClassName(): string;
  60575. /**
  60576. * Gets associated scene
  60577. */
  60578. readonly scene: Scene;
  60579. /**
  60580. * Gets or sets the edge blur
  60581. */
  60582. edgeBlur: number;
  60583. /**
  60584. * Gets or sets the grain amount
  60585. */
  60586. grainAmount: number;
  60587. /**
  60588. * Gets or sets the chromatic aberration amount
  60589. */
  60590. chromaticAberration: number;
  60591. /**
  60592. * Gets or sets the depth of field aperture
  60593. */
  60594. dofAperture: number;
  60595. /**
  60596. * Gets or sets the edge distortion
  60597. */
  60598. edgeDistortion: number;
  60599. /**
  60600. * Gets or sets the depth of field distortion
  60601. */
  60602. dofDistortion: number;
  60603. /**
  60604. * Gets or sets the darken out of focus amount
  60605. */
  60606. darkenOutOfFocus: number;
  60607. /**
  60608. * Gets or sets a boolean indicating if blur noise is enabled
  60609. */
  60610. blurNoise: boolean;
  60611. /**
  60612. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  60613. */
  60614. pentagonBokeh: boolean;
  60615. /**
  60616. * Gets or sets the highlight grain amount
  60617. */
  60618. highlightsGain: number;
  60619. /**
  60620. * Gets or sets the highlight threshold
  60621. */
  60622. highlightsThreshold: number;
  60623. /**
  60624. * Sets the amount of blur at the edges
  60625. * @param amount blur amount
  60626. */
  60627. setEdgeBlur(amount: number): void;
  60628. /**
  60629. * Sets edge blur to 0
  60630. */
  60631. disableEdgeBlur(): void;
  60632. /**
  60633. * Sets the amout of grain
  60634. * @param amount Amount of grain
  60635. */
  60636. setGrainAmount(amount: number): void;
  60637. /**
  60638. * Set grain amount to 0
  60639. */
  60640. disableGrain(): void;
  60641. /**
  60642. * Sets the chromatic aberration amount
  60643. * @param amount amount of chromatic aberration
  60644. */
  60645. setChromaticAberration(amount: number): void;
  60646. /**
  60647. * Sets chromatic aberration amount to 0
  60648. */
  60649. disableChromaticAberration(): void;
  60650. /**
  60651. * Sets the EdgeDistortion amount
  60652. * @param amount amount of EdgeDistortion
  60653. */
  60654. setEdgeDistortion(amount: number): void;
  60655. /**
  60656. * Sets edge distortion to 0
  60657. */
  60658. disableEdgeDistortion(): void;
  60659. /**
  60660. * Sets the FocusDistance amount
  60661. * @param amount amount of FocusDistance
  60662. */
  60663. setFocusDistance(amount: number): void;
  60664. /**
  60665. * Disables depth of field
  60666. */
  60667. disableDepthOfField(): void;
  60668. /**
  60669. * Sets the Aperture amount
  60670. * @param amount amount of Aperture
  60671. */
  60672. setAperture(amount: number): void;
  60673. /**
  60674. * Sets the DarkenOutOfFocus amount
  60675. * @param amount amount of DarkenOutOfFocus
  60676. */
  60677. setDarkenOutOfFocus(amount: number): void;
  60678. private _pentagonBokehIsEnabled;
  60679. /**
  60680. * Creates a pentagon bokeh effect
  60681. */
  60682. enablePentagonBokeh(): void;
  60683. /**
  60684. * Disables the pentagon bokeh effect
  60685. */
  60686. disablePentagonBokeh(): void;
  60687. /**
  60688. * Enables noise blur
  60689. */
  60690. enableNoiseBlur(): void;
  60691. /**
  60692. * Disables noise blur
  60693. */
  60694. disableNoiseBlur(): void;
  60695. /**
  60696. * Sets the HighlightsGain amount
  60697. * @param amount amount of HighlightsGain
  60698. */
  60699. setHighlightsGain(amount: number): void;
  60700. /**
  60701. * Sets the HighlightsThreshold amount
  60702. * @param amount amount of HighlightsThreshold
  60703. */
  60704. setHighlightsThreshold(amount: number): void;
  60705. /**
  60706. * Disables highlights
  60707. */
  60708. disableHighlights(): void;
  60709. /**
  60710. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  60711. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  60712. */
  60713. dispose(disableDepthRender?: boolean): void;
  60714. private _createChromaticAberrationPostProcess;
  60715. private _createHighlightsPostProcess;
  60716. private _createDepthOfFieldPostProcess;
  60717. private _createGrainTexture;
  60718. }
  60719. }
  60720. declare module "babylonjs/Shaders/ssao2.fragment" {
  60721. /** @hidden */
  60722. export var ssao2PixelShader: {
  60723. name: string;
  60724. shader: string;
  60725. };
  60726. }
  60727. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  60728. /** @hidden */
  60729. export var ssaoCombinePixelShader: {
  60730. name: string;
  60731. shader: string;
  60732. };
  60733. }
  60734. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  60735. import { Camera } from "babylonjs/Cameras/camera";
  60736. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60737. import { Scene } from "babylonjs/scene";
  60738. import "babylonjs/Shaders/ssao2.fragment";
  60739. import "babylonjs/Shaders/ssaoCombine.fragment";
  60740. /**
  60741. * Render pipeline to produce ssao effect
  60742. */
  60743. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  60744. /**
  60745. * @ignore
  60746. * The PassPostProcess id in the pipeline that contains the original scene color
  60747. */
  60748. SSAOOriginalSceneColorEffect: string;
  60749. /**
  60750. * @ignore
  60751. * The SSAO PostProcess id in the pipeline
  60752. */
  60753. SSAORenderEffect: string;
  60754. /**
  60755. * @ignore
  60756. * The horizontal blur PostProcess id in the pipeline
  60757. */
  60758. SSAOBlurHRenderEffect: string;
  60759. /**
  60760. * @ignore
  60761. * The vertical blur PostProcess id in the pipeline
  60762. */
  60763. SSAOBlurVRenderEffect: string;
  60764. /**
  60765. * @ignore
  60766. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60767. */
  60768. SSAOCombineRenderEffect: string;
  60769. /**
  60770. * The output strength of the SSAO post-process. Default value is 1.0.
  60771. */
  60772. totalStrength: number;
  60773. /**
  60774. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  60775. */
  60776. maxZ: number;
  60777. /**
  60778. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  60779. */
  60780. minZAspect: number;
  60781. private _samples;
  60782. /**
  60783. * Number of samples used for the SSAO calculations. Default value is 8
  60784. */
  60785. samples: number;
  60786. private _textureSamples;
  60787. /**
  60788. * Number of samples to use for antialiasing
  60789. */
  60790. textureSamples: number;
  60791. /**
  60792. * Ratio object used for SSAO ratio and blur ratio
  60793. */
  60794. private _ratio;
  60795. /**
  60796. * Dynamically generated sphere sampler.
  60797. */
  60798. private _sampleSphere;
  60799. /**
  60800. * Blur filter offsets
  60801. */
  60802. private _samplerOffsets;
  60803. private _expensiveBlur;
  60804. /**
  60805. * If bilateral blur should be used
  60806. */
  60807. expensiveBlur: boolean;
  60808. /**
  60809. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  60810. */
  60811. radius: number;
  60812. /**
  60813. * The base color of the SSAO post-process
  60814. * The final result is "base + ssao" between [0, 1]
  60815. */
  60816. base: number;
  60817. /**
  60818. * Support test.
  60819. */
  60820. static readonly IsSupported: boolean;
  60821. private _scene;
  60822. private _depthTexture;
  60823. private _normalTexture;
  60824. private _randomTexture;
  60825. private _originalColorPostProcess;
  60826. private _ssaoPostProcess;
  60827. private _blurHPostProcess;
  60828. private _blurVPostProcess;
  60829. private _ssaoCombinePostProcess;
  60830. private _firstUpdate;
  60831. /**
  60832. * Gets active scene
  60833. */
  60834. readonly scene: Scene;
  60835. /**
  60836. * @constructor
  60837. * @param name The rendering pipeline name
  60838. * @param scene The scene linked to this pipeline
  60839. * @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 }
  60840. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60841. */
  60842. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60843. /**
  60844. * Get the class name
  60845. * @returns "SSAO2RenderingPipeline"
  60846. */
  60847. getClassName(): string;
  60848. /**
  60849. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60850. */
  60851. dispose(disableGeometryBufferRenderer?: boolean): void;
  60852. private _createBlurPostProcess;
  60853. /** @hidden */
  60854. _rebuild(): void;
  60855. private _bits;
  60856. private _radicalInverse_VdC;
  60857. private _hammersley;
  60858. private _hemisphereSample_uniform;
  60859. private _generateHemisphere;
  60860. private _createSSAOPostProcess;
  60861. private _createSSAOCombinePostProcess;
  60862. private _createRandomTexture;
  60863. /**
  60864. * Serialize the rendering pipeline (Used when exporting)
  60865. * @returns the serialized object
  60866. */
  60867. serialize(): any;
  60868. /**
  60869. * Parse the serialized pipeline
  60870. * @param source Source pipeline.
  60871. * @param scene The scene to load the pipeline to.
  60872. * @param rootUrl The URL of the serialized pipeline.
  60873. * @returns An instantiated pipeline from the serialized object.
  60874. */
  60875. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  60876. }
  60877. }
  60878. declare module "babylonjs/Shaders/ssao.fragment" {
  60879. /** @hidden */
  60880. export var ssaoPixelShader: {
  60881. name: string;
  60882. shader: string;
  60883. };
  60884. }
  60885. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  60886. import { Camera } from "babylonjs/Cameras/camera";
  60887. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60888. import { Scene } from "babylonjs/scene";
  60889. import "babylonjs/Shaders/ssao.fragment";
  60890. import "babylonjs/Shaders/ssaoCombine.fragment";
  60891. /**
  60892. * Render pipeline to produce ssao effect
  60893. */
  60894. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  60895. /**
  60896. * @ignore
  60897. * The PassPostProcess id in the pipeline that contains the original scene color
  60898. */
  60899. SSAOOriginalSceneColorEffect: string;
  60900. /**
  60901. * @ignore
  60902. * The SSAO PostProcess id in the pipeline
  60903. */
  60904. SSAORenderEffect: string;
  60905. /**
  60906. * @ignore
  60907. * The horizontal blur PostProcess id in the pipeline
  60908. */
  60909. SSAOBlurHRenderEffect: string;
  60910. /**
  60911. * @ignore
  60912. * The vertical blur PostProcess id in the pipeline
  60913. */
  60914. SSAOBlurVRenderEffect: string;
  60915. /**
  60916. * @ignore
  60917. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  60918. */
  60919. SSAOCombineRenderEffect: string;
  60920. /**
  60921. * The output strength of the SSAO post-process. Default value is 1.0.
  60922. */
  60923. totalStrength: number;
  60924. /**
  60925. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  60926. */
  60927. radius: number;
  60928. /**
  60929. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  60930. * Must not be equal to fallOff and superior to fallOff.
  60931. * Default value is 0.0075
  60932. */
  60933. area: number;
  60934. /**
  60935. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  60936. * Must not be equal to area and inferior to area.
  60937. * Default value is 0.000001
  60938. */
  60939. fallOff: number;
  60940. /**
  60941. * The base color of the SSAO post-process
  60942. * The final result is "base + ssao" between [0, 1]
  60943. */
  60944. base: number;
  60945. private _scene;
  60946. private _depthTexture;
  60947. private _randomTexture;
  60948. private _originalColorPostProcess;
  60949. private _ssaoPostProcess;
  60950. private _blurHPostProcess;
  60951. private _blurVPostProcess;
  60952. private _ssaoCombinePostProcess;
  60953. private _firstUpdate;
  60954. /**
  60955. * Gets active scene
  60956. */
  60957. readonly scene: Scene;
  60958. /**
  60959. * @constructor
  60960. * @param name - The rendering pipeline name
  60961. * @param scene - The scene linked to this pipeline
  60962. * @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 }
  60963. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  60964. */
  60965. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  60966. /**
  60967. * Get the class name
  60968. * @returns "SSAORenderingPipeline"
  60969. */
  60970. getClassName(): string;
  60971. /**
  60972. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  60973. */
  60974. dispose(disableDepthRender?: boolean): void;
  60975. private _createBlurPostProcess;
  60976. /** @hidden */
  60977. _rebuild(): void;
  60978. private _createSSAOPostProcess;
  60979. private _createSSAOCombinePostProcess;
  60980. private _createRandomTexture;
  60981. }
  60982. }
  60983. declare module "babylonjs/Shaders/standard.fragment" {
  60984. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  60985. /** @hidden */
  60986. export var standardPixelShader: {
  60987. name: string;
  60988. shader: string;
  60989. };
  60990. }
  60991. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  60992. import { Nullable } from "babylonjs/types";
  60993. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60994. import { Camera } from "babylonjs/Cameras/camera";
  60995. import { Texture } from "babylonjs/Materials/Textures/texture";
  60996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60997. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60998. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  60999. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  61000. import { IDisposable } from "babylonjs/scene";
  61001. import { SpotLight } from "babylonjs/Lights/spotLight";
  61002. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61003. import { Scene } from "babylonjs/scene";
  61004. import { Animation } from "babylonjs/Animations/animation";
  61005. import "babylonjs/Shaders/standard.fragment";
  61006. /**
  61007. * Standard rendering pipeline
  61008. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61009. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  61010. */
  61011. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  61012. /**
  61013. * Public members
  61014. */
  61015. /**
  61016. * Post-process which contains the original scene color before the pipeline applies all the effects
  61017. */
  61018. originalPostProcess: Nullable<PostProcess>;
  61019. /**
  61020. * Post-process used to down scale an image x4
  61021. */
  61022. downSampleX4PostProcess: Nullable<PostProcess>;
  61023. /**
  61024. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  61025. */
  61026. brightPassPostProcess: Nullable<PostProcess>;
  61027. /**
  61028. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  61029. */
  61030. blurHPostProcesses: PostProcess[];
  61031. /**
  61032. * Post-process array storing all the vertical blur post-processes used by the pipeline
  61033. */
  61034. blurVPostProcesses: PostProcess[];
  61035. /**
  61036. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  61037. */
  61038. textureAdderPostProcess: Nullable<PostProcess>;
  61039. /**
  61040. * Post-process used to create volumetric lighting effect
  61041. */
  61042. volumetricLightPostProcess: Nullable<PostProcess>;
  61043. /**
  61044. * Post-process used to smooth the previous volumetric light post-process on the X axis
  61045. */
  61046. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  61047. /**
  61048. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  61049. */
  61050. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  61051. /**
  61052. * Post-process used to merge the volumetric light effect and the real scene color
  61053. */
  61054. volumetricLightMergePostProces: Nullable<PostProcess>;
  61055. /**
  61056. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  61057. */
  61058. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  61059. /**
  61060. * Base post-process used to calculate the average luminance of the final image for HDR
  61061. */
  61062. luminancePostProcess: Nullable<PostProcess>;
  61063. /**
  61064. * Post-processes used to create down sample post-processes in order to get
  61065. * the average luminance of the final image for HDR
  61066. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  61067. */
  61068. luminanceDownSamplePostProcesses: PostProcess[];
  61069. /**
  61070. * Post-process used to create a HDR effect (light adaptation)
  61071. */
  61072. hdrPostProcess: Nullable<PostProcess>;
  61073. /**
  61074. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  61075. */
  61076. textureAdderFinalPostProcess: Nullable<PostProcess>;
  61077. /**
  61078. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  61079. */
  61080. lensFlareFinalPostProcess: Nullable<PostProcess>;
  61081. /**
  61082. * Post-process used to merge the final HDR post-process and the real scene color
  61083. */
  61084. hdrFinalPostProcess: Nullable<PostProcess>;
  61085. /**
  61086. * Post-process used to create a lens flare effect
  61087. */
  61088. lensFlarePostProcess: Nullable<PostProcess>;
  61089. /**
  61090. * Post-process that merges the result of the lens flare post-process and the real scene color
  61091. */
  61092. lensFlareComposePostProcess: Nullable<PostProcess>;
  61093. /**
  61094. * Post-process used to create a motion blur effect
  61095. */
  61096. motionBlurPostProcess: Nullable<PostProcess>;
  61097. /**
  61098. * Post-process used to create a depth of field effect
  61099. */
  61100. depthOfFieldPostProcess: Nullable<PostProcess>;
  61101. /**
  61102. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  61103. */
  61104. fxaaPostProcess: Nullable<FxaaPostProcess>;
  61105. /**
  61106. * Represents the brightness threshold in order to configure the illuminated surfaces
  61107. */
  61108. brightThreshold: number;
  61109. /**
  61110. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  61111. */
  61112. blurWidth: number;
  61113. /**
  61114. * Sets if the blur for highlighted surfaces must be only horizontal
  61115. */
  61116. horizontalBlur: boolean;
  61117. /**
  61118. * Gets the overall exposure used by the pipeline
  61119. */
  61120. /**
  61121. * Sets the overall exposure used by the pipeline
  61122. */
  61123. exposure: number;
  61124. /**
  61125. * Texture used typically to simulate "dirty" on camera lens
  61126. */
  61127. lensTexture: Nullable<Texture>;
  61128. /**
  61129. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  61130. */
  61131. volumetricLightCoefficient: number;
  61132. /**
  61133. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  61134. */
  61135. volumetricLightPower: number;
  61136. /**
  61137. * Used the set the blur intensity to smooth the volumetric lights
  61138. */
  61139. volumetricLightBlurScale: number;
  61140. /**
  61141. * Light (spot or directional) used to generate the volumetric lights rays
  61142. * The source light must have a shadow generate so the pipeline can get its
  61143. * depth map
  61144. */
  61145. sourceLight: Nullable<SpotLight | DirectionalLight>;
  61146. /**
  61147. * For eye adaptation, represents the minimum luminance the eye can see
  61148. */
  61149. hdrMinimumLuminance: number;
  61150. /**
  61151. * For eye adaptation, represents the decrease luminance speed
  61152. */
  61153. hdrDecreaseRate: number;
  61154. /**
  61155. * For eye adaptation, represents the increase luminance speed
  61156. */
  61157. hdrIncreaseRate: number;
  61158. /**
  61159. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61160. */
  61161. /**
  61162. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  61163. */
  61164. hdrAutoExposure: boolean;
  61165. /**
  61166. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  61167. */
  61168. lensColorTexture: Nullable<Texture>;
  61169. /**
  61170. * The overall strengh for the lens flare effect
  61171. */
  61172. lensFlareStrength: number;
  61173. /**
  61174. * Dispersion coefficient for lens flare ghosts
  61175. */
  61176. lensFlareGhostDispersal: number;
  61177. /**
  61178. * Main lens flare halo width
  61179. */
  61180. lensFlareHaloWidth: number;
  61181. /**
  61182. * Based on the lens distortion effect, defines how much the lens flare result
  61183. * is distorted
  61184. */
  61185. lensFlareDistortionStrength: number;
  61186. /**
  61187. * Lens star texture must be used to simulate rays on the flares and is available
  61188. * in the documentation
  61189. */
  61190. lensStarTexture: Nullable<Texture>;
  61191. /**
  61192. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  61193. * flare effect by taking account of the dirt texture
  61194. */
  61195. lensFlareDirtTexture: Nullable<Texture>;
  61196. /**
  61197. * Represents the focal length for the depth of field effect
  61198. */
  61199. depthOfFieldDistance: number;
  61200. /**
  61201. * Represents the blur intensity for the blurred part of the depth of field effect
  61202. */
  61203. depthOfFieldBlurWidth: number;
  61204. /**
  61205. * Gets how much the image is blurred by the movement while using the motion blur post-process
  61206. */
  61207. /**
  61208. * Sets how much the image is blurred by the movement while using the motion blur post-process
  61209. */
  61210. motionStrength: number;
  61211. /**
  61212. * Gets wether or not the motion blur post-process is object based or screen based.
  61213. */
  61214. /**
  61215. * Sets wether or not the motion blur post-process should be object based or screen based
  61216. */
  61217. objectBasedMotionBlur: boolean;
  61218. /**
  61219. * List of animations for the pipeline (IAnimatable implementation)
  61220. */
  61221. animations: Animation[];
  61222. /**
  61223. * Private members
  61224. */
  61225. private _scene;
  61226. private _currentDepthOfFieldSource;
  61227. private _basePostProcess;
  61228. private _fixedExposure;
  61229. private _currentExposure;
  61230. private _hdrAutoExposure;
  61231. private _hdrCurrentLuminance;
  61232. private _motionStrength;
  61233. private _isObjectBasedMotionBlur;
  61234. private _floatTextureType;
  61235. private _ratio;
  61236. private _bloomEnabled;
  61237. private _depthOfFieldEnabled;
  61238. private _vlsEnabled;
  61239. private _lensFlareEnabled;
  61240. private _hdrEnabled;
  61241. private _motionBlurEnabled;
  61242. private _fxaaEnabled;
  61243. private _motionBlurSamples;
  61244. private _volumetricLightStepsCount;
  61245. private _samples;
  61246. /**
  61247. * @ignore
  61248. * Specifies if the bloom pipeline is enabled
  61249. */
  61250. BloomEnabled: boolean;
  61251. /**
  61252. * @ignore
  61253. * Specifies if the depth of field pipeline is enabed
  61254. */
  61255. DepthOfFieldEnabled: boolean;
  61256. /**
  61257. * @ignore
  61258. * Specifies if the lens flare pipeline is enabed
  61259. */
  61260. LensFlareEnabled: boolean;
  61261. /**
  61262. * @ignore
  61263. * Specifies if the HDR pipeline is enabled
  61264. */
  61265. HDREnabled: boolean;
  61266. /**
  61267. * @ignore
  61268. * Specifies if the volumetric lights scattering effect is enabled
  61269. */
  61270. VLSEnabled: boolean;
  61271. /**
  61272. * @ignore
  61273. * Specifies if the motion blur effect is enabled
  61274. */
  61275. MotionBlurEnabled: boolean;
  61276. /**
  61277. * Specifies if anti-aliasing is enabled
  61278. */
  61279. fxaaEnabled: boolean;
  61280. /**
  61281. * Specifies the number of steps used to calculate the volumetric lights
  61282. * Typically in interval [50, 200]
  61283. */
  61284. volumetricLightStepsCount: number;
  61285. /**
  61286. * Specifies the number of samples used for the motion blur effect
  61287. * Typically in interval [16, 64]
  61288. */
  61289. motionBlurSamples: number;
  61290. /**
  61291. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  61292. */
  61293. samples: number;
  61294. /**
  61295. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  61296. * @constructor
  61297. * @param name The rendering pipeline name
  61298. * @param scene The scene linked to this pipeline
  61299. * @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)
  61300. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  61301. * @param cameras The array of cameras that the rendering pipeline will be attached to
  61302. */
  61303. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  61304. private _buildPipeline;
  61305. private _createDownSampleX4PostProcess;
  61306. private _createBrightPassPostProcess;
  61307. private _createBlurPostProcesses;
  61308. private _createTextureAdderPostProcess;
  61309. private _createVolumetricLightPostProcess;
  61310. private _createLuminancePostProcesses;
  61311. private _createHdrPostProcess;
  61312. private _createLensFlarePostProcess;
  61313. private _createDepthOfFieldPostProcess;
  61314. private _createMotionBlurPostProcess;
  61315. private _getDepthTexture;
  61316. private _disposePostProcesses;
  61317. /**
  61318. * Dispose of the pipeline and stop all post processes
  61319. */
  61320. dispose(): void;
  61321. /**
  61322. * Serialize the rendering pipeline (Used when exporting)
  61323. * @returns the serialized object
  61324. */
  61325. serialize(): any;
  61326. /**
  61327. * Parse the serialized pipeline
  61328. * @param source Source pipeline.
  61329. * @param scene The scene to load the pipeline to.
  61330. * @param rootUrl The URL of the serialized pipeline.
  61331. * @returns An instantiated pipeline from the serialized object.
  61332. */
  61333. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  61334. /**
  61335. * Luminance steps
  61336. */
  61337. static LuminanceSteps: number;
  61338. }
  61339. }
  61340. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  61341. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  61342. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  61343. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  61344. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  61345. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  61346. }
  61347. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  61348. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  61349. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  61350. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  61351. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  61352. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  61353. }
  61354. declare module "babylonjs/Shaders/tonemap.fragment" {
  61355. /** @hidden */
  61356. export var tonemapPixelShader: {
  61357. name: string;
  61358. shader: string;
  61359. };
  61360. }
  61361. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  61362. import { Camera } from "babylonjs/Cameras/camera";
  61363. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61364. import "babylonjs/Shaders/tonemap.fragment";
  61365. import { Engine } from "babylonjs/Engines/engine";
  61366. /** Defines operator used for tonemapping */
  61367. export enum TonemappingOperator {
  61368. /** Hable */
  61369. Hable = 0,
  61370. /** Reinhard */
  61371. Reinhard = 1,
  61372. /** HejiDawson */
  61373. HejiDawson = 2,
  61374. /** Photographic */
  61375. Photographic = 3
  61376. }
  61377. /**
  61378. * Defines a post process to apply tone mapping
  61379. */
  61380. export class TonemapPostProcess extends PostProcess {
  61381. private _operator;
  61382. /** Defines the required exposure adjustement */
  61383. exposureAdjustment: number;
  61384. /**
  61385. * Creates a new TonemapPostProcess
  61386. * @param name defines the name of the postprocess
  61387. * @param _operator defines the operator to use
  61388. * @param exposureAdjustment defines the required exposure adjustement
  61389. * @param camera defines the camera to use (can be null)
  61390. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  61391. * @param engine defines the hosting engine (can be ignore if camera is set)
  61392. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61393. */
  61394. constructor(name: string, _operator: TonemappingOperator,
  61395. /** Defines the required exposure adjustement */
  61396. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  61397. }
  61398. }
  61399. declare module "babylonjs/Shaders/depth.vertex" {
  61400. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61407. /** @hidden */
  61408. export var depthVertexShader: {
  61409. name: string;
  61410. shader: string;
  61411. };
  61412. }
  61413. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  61414. /** @hidden */
  61415. export var volumetricLightScatteringPixelShader: {
  61416. name: string;
  61417. shader: string;
  61418. };
  61419. }
  61420. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  61421. /** @hidden */
  61422. export var volumetricLightScatteringPassPixelShader: {
  61423. name: string;
  61424. shader: string;
  61425. };
  61426. }
  61427. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  61428. import { Vector3 } from "babylonjs/Maths/math.vector";
  61429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61430. import { Mesh } from "babylonjs/Meshes/mesh";
  61431. import { Camera } from "babylonjs/Cameras/camera";
  61432. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61433. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61434. import { Scene } from "babylonjs/scene";
  61435. import "babylonjs/Meshes/Builders/planeBuilder";
  61436. import "babylonjs/Shaders/depth.vertex";
  61437. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  61438. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  61439. import { Engine } from "babylonjs/Engines/engine";
  61440. /**
  61441. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  61442. */
  61443. export class VolumetricLightScatteringPostProcess extends PostProcess {
  61444. private _volumetricLightScatteringPass;
  61445. private _volumetricLightScatteringRTT;
  61446. private _viewPort;
  61447. private _screenCoordinates;
  61448. private _cachedDefines;
  61449. /**
  61450. * If not undefined, the mesh position is computed from the attached node position
  61451. */
  61452. attachedNode: {
  61453. position: Vector3;
  61454. };
  61455. /**
  61456. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  61457. */
  61458. customMeshPosition: Vector3;
  61459. /**
  61460. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  61461. */
  61462. useCustomMeshPosition: boolean;
  61463. /**
  61464. * If the post-process should inverse the light scattering direction
  61465. */
  61466. invert: boolean;
  61467. /**
  61468. * The internal mesh used by the post-process
  61469. */
  61470. mesh: Mesh;
  61471. /**
  61472. * @hidden
  61473. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  61474. */
  61475. useDiffuseColor: boolean;
  61476. /**
  61477. * Array containing the excluded meshes not rendered in the internal pass
  61478. */
  61479. excludedMeshes: AbstractMesh[];
  61480. /**
  61481. * Controls the overall intensity of the post-process
  61482. */
  61483. exposure: number;
  61484. /**
  61485. * Dissipates each sample's contribution in range [0, 1]
  61486. */
  61487. decay: number;
  61488. /**
  61489. * Controls the overall intensity of each sample
  61490. */
  61491. weight: number;
  61492. /**
  61493. * Controls the density of each sample
  61494. */
  61495. density: number;
  61496. /**
  61497. * @constructor
  61498. * @param name The post-process name
  61499. * @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)
  61500. * @param camera The camera that the post-process will be attached to
  61501. * @param mesh The mesh used to create the light scattering
  61502. * @param samples The post-process quality, default 100
  61503. * @param samplingModeThe post-process filtering mode
  61504. * @param engine The babylon engine
  61505. * @param reusable If the post-process is reusable
  61506. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  61507. */
  61508. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  61509. /**
  61510. * Returns the string "VolumetricLightScatteringPostProcess"
  61511. * @returns "VolumetricLightScatteringPostProcess"
  61512. */
  61513. getClassName(): string;
  61514. private _isReady;
  61515. /**
  61516. * Sets the new light position for light scattering effect
  61517. * @param position The new custom light position
  61518. */
  61519. setCustomMeshPosition(position: Vector3): void;
  61520. /**
  61521. * Returns the light position for light scattering effect
  61522. * @return Vector3 The custom light position
  61523. */
  61524. getCustomMeshPosition(): Vector3;
  61525. /**
  61526. * Disposes the internal assets and detaches the post-process from the camera
  61527. */
  61528. dispose(camera: Camera): void;
  61529. /**
  61530. * Returns the render target texture used by the post-process
  61531. * @return the render target texture used by the post-process
  61532. */
  61533. getPass(): RenderTargetTexture;
  61534. private _meshExcluded;
  61535. private _createPass;
  61536. private _updateMeshScreenCoordinates;
  61537. /**
  61538. * Creates a default mesh for the Volumeric Light Scattering post-process
  61539. * @param name The mesh name
  61540. * @param scene The scene where to create the mesh
  61541. * @return the default mesh
  61542. */
  61543. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  61544. }
  61545. }
  61546. declare module "babylonjs/PostProcesses/index" {
  61547. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  61548. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  61549. export * from "babylonjs/PostProcesses/bloomEffect";
  61550. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  61551. export * from "babylonjs/PostProcesses/blurPostProcess";
  61552. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  61553. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  61554. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  61555. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  61556. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  61557. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  61558. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  61559. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  61560. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  61561. export * from "babylonjs/PostProcesses/filterPostProcess";
  61562. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  61563. export * from "babylonjs/PostProcesses/grainPostProcess";
  61564. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  61565. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  61566. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  61567. export * from "babylonjs/PostProcesses/passPostProcess";
  61568. export * from "babylonjs/PostProcesses/postProcess";
  61569. export * from "babylonjs/PostProcesses/postProcessManager";
  61570. export * from "babylonjs/PostProcesses/refractionPostProcess";
  61571. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  61572. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  61573. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  61574. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  61575. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  61576. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  61577. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  61578. }
  61579. declare module "babylonjs/Probes/index" {
  61580. export * from "babylonjs/Probes/reflectionProbe";
  61581. }
  61582. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  61583. import { Scene } from "babylonjs/scene";
  61584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61585. import { SmartArray } from "babylonjs/Misc/smartArray";
  61586. import { ISceneComponent } from "babylonjs/sceneComponent";
  61587. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  61588. import "babylonjs/Meshes/Builders/boxBuilder";
  61589. import "babylonjs/Shaders/color.fragment";
  61590. import "babylonjs/Shaders/color.vertex";
  61591. import { Color3 } from "babylonjs/Maths/math.color";
  61592. module "babylonjs/scene" {
  61593. interface Scene {
  61594. /** @hidden (Backing field) */
  61595. _boundingBoxRenderer: BoundingBoxRenderer;
  61596. /** @hidden (Backing field) */
  61597. _forceShowBoundingBoxes: boolean;
  61598. /**
  61599. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  61600. */
  61601. forceShowBoundingBoxes: boolean;
  61602. /**
  61603. * Gets the bounding box renderer associated with the scene
  61604. * @returns a BoundingBoxRenderer
  61605. */
  61606. getBoundingBoxRenderer(): BoundingBoxRenderer;
  61607. }
  61608. }
  61609. module "babylonjs/Meshes/abstractMesh" {
  61610. interface AbstractMesh {
  61611. /** @hidden (Backing field) */
  61612. _showBoundingBox: boolean;
  61613. /**
  61614. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  61615. */
  61616. showBoundingBox: boolean;
  61617. }
  61618. }
  61619. /**
  61620. * Component responsible of rendering the bounding box of the meshes in a scene.
  61621. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  61622. */
  61623. export class BoundingBoxRenderer implements ISceneComponent {
  61624. /**
  61625. * The component name helpfull to identify the component in the list of scene components.
  61626. */
  61627. readonly name: string;
  61628. /**
  61629. * The scene the component belongs to.
  61630. */
  61631. scene: Scene;
  61632. /**
  61633. * Color of the bounding box lines placed in front of an object
  61634. */
  61635. frontColor: Color3;
  61636. /**
  61637. * Color of the bounding box lines placed behind an object
  61638. */
  61639. backColor: Color3;
  61640. /**
  61641. * Defines if the renderer should show the back lines or not
  61642. */
  61643. showBackLines: boolean;
  61644. /**
  61645. * @hidden
  61646. */
  61647. renderList: SmartArray<BoundingBox>;
  61648. private _colorShader;
  61649. private _vertexBuffers;
  61650. private _indexBuffer;
  61651. private _fillIndexBuffer;
  61652. private _fillIndexData;
  61653. /**
  61654. * Instantiates a new bounding box renderer in a scene.
  61655. * @param scene the scene the renderer renders in
  61656. */
  61657. constructor(scene: Scene);
  61658. /**
  61659. * Registers the component in a given scene
  61660. */
  61661. register(): void;
  61662. private _evaluateSubMesh;
  61663. private _activeMesh;
  61664. private _prepareRessources;
  61665. private _createIndexBuffer;
  61666. /**
  61667. * Rebuilds the elements related to this component in case of
  61668. * context lost for instance.
  61669. */
  61670. rebuild(): void;
  61671. /**
  61672. * @hidden
  61673. */
  61674. reset(): void;
  61675. /**
  61676. * Render the bounding boxes of a specific rendering group
  61677. * @param renderingGroupId defines the rendering group to render
  61678. */
  61679. render(renderingGroupId: number): void;
  61680. /**
  61681. * In case of occlusion queries, we can render the occlusion bounding box through this method
  61682. * @param mesh Define the mesh to render the occlusion bounding box for
  61683. */
  61684. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  61685. /**
  61686. * Dispose and release the resources attached to this renderer.
  61687. */
  61688. dispose(): void;
  61689. }
  61690. }
  61691. declare module "babylonjs/Shaders/depth.fragment" {
  61692. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61693. /** @hidden */
  61694. export var depthPixelShader: {
  61695. name: string;
  61696. shader: string;
  61697. };
  61698. }
  61699. declare module "babylonjs/Rendering/depthRenderer" {
  61700. import { Nullable } from "babylonjs/types";
  61701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61702. import { Scene } from "babylonjs/scene";
  61703. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61704. import { Camera } from "babylonjs/Cameras/camera";
  61705. import "babylonjs/Shaders/depth.fragment";
  61706. import "babylonjs/Shaders/depth.vertex";
  61707. /**
  61708. * This represents a depth renderer in Babylon.
  61709. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61710. */
  61711. export class DepthRenderer {
  61712. private _scene;
  61713. private _depthMap;
  61714. private _effect;
  61715. private readonly _storeNonLinearDepth;
  61716. private readonly _clearColor;
  61717. /** Get if the depth renderer is using packed depth or not */
  61718. readonly isPacked: boolean;
  61719. private _cachedDefines;
  61720. private _camera;
  61721. /**
  61722. * Specifiess that the depth renderer will only be used within
  61723. * the camera it is created for.
  61724. * This can help forcing its rendering during the camera processing.
  61725. */
  61726. useOnlyInActiveCamera: boolean;
  61727. /** @hidden */
  61728. static _SceneComponentInitialization: (scene: Scene) => void;
  61729. /**
  61730. * Instantiates a depth renderer
  61731. * @param scene The scene the renderer belongs to
  61732. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61733. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61734. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61735. */
  61736. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61737. /**
  61738. * Creates the depth rendering effect and checks if the effect is ready.
  61739. * @param subMesh The submesh to be used to render the depth map of
  61740. * @param useInstances If multiple world instances should be used
  61741. * @returns if the depth renderer is ready to render the depth map
  61742. */
  61743. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61744. /**
  61745. * Gets the texture which the depth map will be written to.
  61746. * @returns The depth map texture
  61747. */
  61748. getDepthMap(): RenderTargetTexture;
  61749. /**
  61750. * Disposes of the depth renderer.
  61751. */
  61752. dispose(): void;
  61753. }
  61754. }
  61755. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  61756. import { Nullable } from "babylonjs/types";
  61757. import { Scene } from "babylonjs/scene";
  61758. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61759. import { Camera } from "babylonjs/Cameras/camera";
  61760. import { ISceneComponent } from "babylonjs/sceneComponent";
  61761. module "babylonjs/scene" {
  61762. interface Scene {
  61763. /** @hidden (Backing field) */
  61764. _depthRenderer: {
  61765. [id: string]: DepthRenderer;
  61766. };
  61767. /**
  61768. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  61769. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  61770. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61771. * @returns the created depth renderer
  61772. */
  61773. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  61774. /**
  61775. * Disables a depth renderer for a given camera
  61776. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  61777. */
  61778. disableDepthRenderer(camera?: Nullable<Camera>): void;
  61779. }
  61780. }
  61781. /**
  61782. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  61783. * in several rendering techniques.
  61784. */
  61785. export class DepthRendererSceneComponent implements ISceneComponent {
  61786. /**
  61787. * The component name helpfull to identify the component in the list of scene components.
  61788. */
  61789. readonly name: string;
  61790. /**
  61791. * The scene the component belongs to.
  61792. */
  61793. scene: Scene;
  61794. /**
  61795. * Creates a new instance of the component for the given scene
  61796. * @param scene Defines the scene to register the component in
  61797. */
  61798. constructor(scene: Scene);
  61799. /**
  61800. * Registers the component in a given scene
  61801. */
  61802. register(): void;
  61803. /**
  61804. * Rebuilds the elements related to this component in case of
  61805. * context lost for instance.
  61806. */
  61807. rebuild(): void;
  61808. /**
  61809. * Disposes the component and the associated ressources
  61810. */
  61811. dispose(): void;
  61812. private _gatherRenderTargets;
  61813. private _gatherActiveCameraRenderTargets;
  61814. }
  61815. }
  61816. declare module "babylonjs/Shaders/outline.fragment" {
  61817. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61818. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  61819. /** @hidden */
  61820. export var outlinePixelShader: {
  61821. name: string;
  61822. shader: string;
  61823. };
  61824. }
  61825. declare module "babylonjs/Shaders/outline.vertex" {
  61826. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61827. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61828. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61829. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61830. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  61831. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61832. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61833. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61834. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  61835. /** @hidden */
  61836. export var outlineVertexShader: {
  61837. name: string;
  61838. shader: string;
  61839. };
  61840. }
  61841. declare module "babylonjs/Rendering/outlineRenderer" {
  61842. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61843. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  61844. import { Scene } from "babylonjs/scene";
  61845. import { ISceneComponent } from "babylonjs/sceneComponent";
  61846. import "babylonjs/Shaders/outline.fragment";
  61847. import "babylonjs/Shaders/outline.vertex";
  61848. module "babylonjs/scene" {
  61849. interface Scene {
  61850. /** @hidden */
  61851. _outlineRenderer: OutlineRenderer;
  61852. /**
  61853. * Gets the outline renderer associated with the scene
  61854. * @returns a OutlineRenderer
  61855. */
  61856. getOutlineRenderer(): OutlineRenderer;
  61857. }
  61858. }
  61859. module "babylonjs/Meshes/abstractMesh" {
  61860. interface AbstractMesh {
  61861. /** @hidden (Backing field) */
  61862. _renderOutline: boolean;
  61863. /**
  61864. * Gets or sets a boolean indicating if the outline must be rendered as well
  61865. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  61866. */
  61867. renderOutline: boolean;
  61868. /** @hidden (Backing field) */
  61869. _renderOverlay: boolean;
  61870. /**
  61871. * Gets or sets a boolean indicating if the overlay must be rendered as well
  61872. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  61873. */
  61874. renderOverlay: boolean;
  61875. }
  61876. }
  61877. /**
  61878. * This class is responsible to draw bothe outline/overlay of meshes.
  61879. * It should not be used directly but through the available method on mesh.
  61880. */
  61881. export class OutlineRenderer implements ISceneComponent {
  61882. /**
  61883. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  61884. */
  61885. private static _StencilReference;
  61886. /**
  61887. * The name of the component. Each component must have a unique name.
  61888. */
  61889. name: string;
  61890. /**
  61891. * The scene the component belongs to.
  61892. */
  61893. scene: Scene;
  61894. /**
  61895. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  61896. */
  61897. zOffset: number;
  61898. private _engine;
  61899. private _effect;
  61900. private _cachedDefines;
  61901. private _savedDepthWrite;
  61902. /**
  61903. * Instantiates a new outline renderer. (There could be only one per scene).
  61904. * @param scene Defines the scene it belongs to
  61905. */
  61906. constructor(scene: Scene);
  61907. /**
  61908. * Register the component to one instance of a scene.
  61909. */
  61910. register(): void;
  61911. /**
  61912. * Rebuilds the elements related to this component in case of
  61913. * context lost for instance.
  61914. */
  61915. rebuild(): void;
  61916. /**
  61917. * Disposes the component and the associated ressources.
  61918. */
  61919. dispose(): void;
  61920. /**
  61921. * Renders the outline in the canvas.
  61922. * @param subMesh Defines the sumesh to render
  61923. * @param batch Defines the batch of meshes in case of instances
  61924. * @param useOverlay Defines if the rendering is for the overlay or the outline
  61925. */
  61926. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  61927. /**
  61928. * Returns whether or not the outline renderer is ready for a given submesh.
  61929. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  61930. * @param subMesh Defines the submesh to check readyness for
  61931. * @param useInstances Defines wheter wee are trying to render instances or not
  61932. * @returns true if ready otherwise false
  61933. */
  61934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61935. private _beforeRenderingMesh;
  61936. private _afterRenderingMesh;
  61937. }
  61938. }
  61939. declare module "babylonjs/Rendering/index" {
  61940. export * from "babylonjs/Rendering/boundingBoxRenderer";
  61941. export * from "babylonjs/Rendering/depthRenderer";
  61942. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  61943. export * from "babylonjs/Rendering/edgesRenderer";
  61944. export * from "babylonjs/Rendering/geometryBufferRenderer";
  61945. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  61946. export * from "babylonjs/Rendering/outlineRenderer";
  61947. export * from "babylonjs/Rendering/renderingGroup";
  61948. export * from "babylonjs/Rendering/renderingManager";
  61949. export * from "babylonjs/Rendering/utilityLayerRenderer";
  61950. }
  61951. declare module "babylonjs/Sprites/index" {
  61952. export * from "babylonjs/Sprites/sprite";
  61953. export * from "babylonjs/Sprites/spriteManager";
  61954. export * from "babylonjs/Sprites/spriteSceneComponent";
  61955. }
  61956. declare module "babylonjs/Misc/assetsManager" {
  61957. import { Scene } from "babylonjs/scene";
  61958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61959. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61960. import { Skeleton } from "babylonjs/Bones/skeleton";
  61961. import { Observable } from "babylonjs/Misc/observable";
  61962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61963. import { Texture } from "babylonjs/Materials/Textures/texture";
  61964. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  61965. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  61966. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  61967. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  61968. /**
  61969. * Defines the list of states available for a task inside a AssetsManager
  61970. */
  61971. export enum AssetTaskState {
  61972. /**
  61973. * Initialization
  61974. */
  61975. INIT = 0,
  61976. /**
  61977. * Running
  61978. */
  61979. RUNNING = 1,
  61980. /**
  61981. * Done
  61982. */
  61983. DONE = 2,
  61984. /**
  61985. * Error
  61986. */
  61987. ERROR = 3
  61988. }
  61989. /**
  61990. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  61991. */
  61992. export abstract class AbstractAssetTask {
  61993. /**
  61994. * Task name
  61995. */ name: string;
  61996. /**
  61997. * Callback called when the task is successful
  61998. */
  61999. onSuccess: (task: any) => void;
  62000. /**
  62001. * Callback called when the task is not successful
  62002. */
  62003. onError: (task: any, message?: string, exception?: any) => void;
  62004. /**
  62005. * Creates a new AssetsManager
  62006. * @param name defines the name of the task
  62007. */
  62008. constructor(
  62009. /**
  62010. * Task name
  62011. */ name: string);
  62012. private _isCompleted;
  62013. private _taskState;
  62014. private _errorObject;
  62015. /**
  62016. * Get if the task is completed
  62017. */
  62018. readonly isCompleted: boolean;
  62019. /**
  62020. * Gets the current state of the task
  62021. */
  62022. readonly taskState: AssetTaskState;
  62023. /**
  62024. * Gets the current error object (if task is in error)
  62025. */
  62026. readonly errorObject: {
  62027. message?: string;
  62028. exception?: any;
  62029. };
  62030. /**
  62031. * Internal only
  62032. * @hidden
  62033. */
  62034. _setErrorObject(message?: string, exception?: any): void;
  62035. /**
  62036. * Execute the current task
  62037. * @param scene defines the scene where you want your assets to be loaded
  62038. * @param onSuccess is a callback called when the task is successfully executed
  62039. * @param onError is a callback called if an error occurs
  62040. */
  62041. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62042. /**
  62043. * Execute the current task
  62044. * @param scene defines the scene where you want your assets to be loaded
  62045. * @param onSuccess is a callback called when the task is successfully executed
  62046. * @param onError is a callback called if an error occurs
  62047. */
  62048. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62049. /**
  62050. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  62051. * This can be used with failed tasks that have the reason for failure fixed.
  62052. */
  62053. reset(): void;
  62054. private onErrorCallback;
  62055. private onDoneCallback;
  62056. }
  62057. /**
  62058. * Define the interface used by progress events raised during assets loading
  62059. */
  62060. export interface IAssetsProgressEvent {
  62061. /**
  62062. * Defines the number of remaining tasks to process
  62063. */
  62064. remainingCount: number;
  62065. /**
  62066. * Defines the total number of tasks
  62067. */
  62068. totalCount: number;
  62069. /**
  62070. * Defines the task that was just processed
  62071. */
  62072. task: AbstractAssetTask;
  62073. }
  62074. /**
  62075. * Class used to share progress information about assets loading
  62076. */
  62077. export class AssetsProgressEvent implements IAssetsProgressEvent {
  62078. /**
  62079. * Defines the number of remaining tasks to process
  62080. */
  62081. remainingCount: number;
  62082. /**
  62083. * Defines the total number of tasks
  62084. */
  62085. totalCount: number;
  62086. /**
  62087. * Defines the task that was just processed
  62088. */
  62089. task: AbstractAssetTask;
  62090. /**
  62091. * Creates a AssetsProgressEvent
  62092. * @param remainingCount defines the number of remaining tasks to process
  62093. * @param totalCount defines the total number of tasks
  62094. * @param task defines the task that was just processed
  62095. */
  62096. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  62097. }
  62098. /**
  62099. * Define a task used by AssetsManager to load meshes
  62100. */
  62101. export class MeshAssetTask extends AbstractAssetTask {
  62102. /**
  62103. * Defines the name of the task
  62104. */
  62105. name: string;
  62106. /**
  62107. * Defines the list of mesh's names you want to load
  62108. */
  62109. meshesNames: any;
  62110. /**
  62111. * Defines the root url to use as a base to load your meshes and associated resources
  62112. */
  62113. rootUrl: string;
  62114. /**
  62115. * Defines the filename of the scene to load from
  62116. */
  62117. sceneFilename: string;
  62118. /**
  62119. * Gets the list of loaded meshes
  62120. */
  62121. loadedMeshes: Array<AbstractMesh>;
  62122. /**
  62123. * Gets the list of loaded particle systems
  62124. */
  62125. loadedParticleSystems: Array<IParticleSystem>;
  62126. /**
  62127. * Gets the list of loaded skeletons
  62128. */
  62129. loadedSkeletons: Array<Skeleton>;
  62130. /**
  62131. * Gets the list of loaded animation groups
  62132. */
  62133. loadedAnimationGroups: Array<AnimationGroup>;
  62134. /**
  62135. * Callback called when the task is successful
  62136. */
  62137. onSuccess: (task: MeshAssetTask) => void;
  62138. /**
  62139. * Callback called when the task is successful
  62140. */
  62141. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  62142. /**
  62143. * Creates a new MeshAssetTask
  62144. * @param name defines the name of the task
  62145. * @param meshesNames defines the list of mesh's names you want to load
  62146. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  62147. * @param sceneFilename defines the filename of the scene to load from
  62148. */
  62149. constructor(
  62150. /**
  62151. * Defines the name of the task
  62152. */
  62153. name: string,
  62154. /**
  62155. * Defines the list of mesh's names you want to load
  62156. */
  62157. meshesNames: any,
  62158. /**
  62159. * Defines the root url to use as a base to load your meshes and associated resources
  62160. */
  62161. rootUrl: string,
  62162. /**
  62163. * Defines the filename of the scene to load from
  62164. */
  62165. sceneFilename: string);
  62166. /**
  62167. * Execute the current task
  62168. * @param scene defines the scene where you want your assets to be loaded
  62169. * @param onSuccess is a callback called when the task is successfully executed
  62170. * @param onError is a callback called if an error occurs
  62171. */
  62172. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62173. }
  62174. /**
  62175. * Define a task used by AssetsManager to load text content
  62176. */
  62177. export class TextFileAssetTask extends AbstractAssetTask {
  62178. /**
  62179. * Defines the name of the task
  62180. */
  62181. name: string;
  62182. /**
  62183. * Defines the location of the file to load
  62184. */
  62185. url: string;
  62186. /**
  62187. * Gets the loaded text string
  62188. */
  62189. text: string;
  62190. /**
  62191. * Callback called when the task is successful
  62192. */
  62193. onSuccess: (task: TextFileAssetTask) => void;
  62194. /**
  62195. * Callback called when the task is successful
  62196. */
  62197. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  62198. /**
  62199. * Creates a new TextFileAssetTask object
  62200. * @param name defines the name of the task
  62201. * @param url defines the location of the file to load
  62202. */
  62203. constructor(
  62204. /**
  62205. * Defines the name of the task
  62206. */
  62207. name: string,
  62208. /**
  62209. * Defines the location of the file to load
  62210. */
  62211. url: string);
  62212. /**
  62213. * Execute the current task
  62214. * @param scene defines the scene where you want your assets to be loaded
  62215. * @param onSuccess is a callback called when the task is successfully executed
  62216. * @param onError is a callback called if an error occurs
  62217. */
  62218. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62219. }
  62220. /**
  62221. * Define a task used by AssetsManager to load binary data
  62222. */
  62223. export class BinaryFileAssetTask extends AbstractAssetTask {
  62224. /**
  62225. * Defines the name of the task
  62226. */
  62227. name: string;
  62228. /**
  62229. * Defines the location of the file to load
  62230. */
  62231. url: string;
  62232. /**
  62233. * Gets the lodaded data (as an array buffer)
  62234. */
  62235. data: ArrayBuffer;
  62236. /**
  62237. * Callback called when the task is successful
  62238. */
  62239. onSuccess: (task: BinaryFileAssetTask) => void;
  62240. /**
  62241. * Callback called when the task is successful
  62242. */
  62243. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  62244. /**
  62245. * Creates a new BinaryFileAssetTask object
  62246. * @param name defines the name of the new task
  62247. * @param url defines the location of the file to load
  62248. */
  62249. constructor(
  62250. /**
  62251. * Defines the name of the task
  62252. */
  62253. name: string,
  62254. /**
  62255. * Defines the location of the file to load
  62256. */
  62257. url: string);
  62258. /**
  62259. * Execute the current task
  62260. * @param scene defines the scene where you want your assets to be loaded
  62261. * @param onSuccess is a callback called when the task is successfully executed
  62262. * @param onError is a callback called if an error occurs
  62263. */
  62264. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62265. }
  62266. /**
  62267. * Define a task used by AssetsManager to load images
  62268. */
  62269. export class ImageAssetTask extends AbstractAssetTask {
  62270. /**
  62271. * Defines the name of the task
  62272. */
  62273. name: string;
  62274. /**
  62275. * Defines the location of the image to load
  62276. */
  62277. url: string;
  62278. /**
  62279. * Gets the loaded images
  62280. */
  62281. image: HTMLImageElement;
  62282. /**
  62283. * Callback called when the task is successful
  62284. */
  62285. onSuccess: (task: ImageAssetTask) => void;
  62286. /**
  62287. * Callback called when the task is successful
  62288. */
  62289. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  62290. /**
  62291. * Creates a new ImageAssetTask
  62292. * @param name defines the name of the task
  62293. * @param url defines the location of the image to load
  62294. */
  62295. constructor(
  62296. /**
  62297. * Defines the name of the task
  62298. */
  62299. name: string,
  62300. /**
  62301. * Defines the location of the image to load
  62302. */
  62303. url: string);
  62304. /**
  62305. * Execute the current task
  62306. * @param scene defines the scene where you want your assets to be loaded
  62307. * @param onSuccess is a callback called when the task is successfully executed
  62308. * @param onError is a callback called if an error occurs
  62309. */
  62310. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62311. }
  62312. /**
  62313. * Defines the interface used by texture loading tasks
  62314. */
  62315. export interface ITextureAssetTask<TEX extends BaseTexture> {
  62316. /**
  62317. * Gets the loaded texture
  62318. */
  62319. texture: TEX;
  62320. }
  62321. /**
  62322. * Define a task used by AssetsManager to load 2D textures
  62323. */
  62324. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  62325. /**
  62326. * Defines the name of the task
  62327. */
  62328. name: string;
  62329. /**
  62330. * Defines the location of the file to load
  62331. */
  62332. url: string;
  62333. /**
  62334. * Defines if mipmap should not be generated (default is false)
  62335. */
  62336. noMipmap?: boolean | undefined;
  62337. /**
  62338. * Defines if texture must be inverted on Y axis (default is false)
  62339. */
  62340. invertY?: boolean | undefined;
  62341. /**
  62342. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62343. */
  62344. samplingMode: number;
  62345. /**
  62346. * Gets the loaded texture
  62347. */
  62348. texture: Texture;
  62349. /**
  62350. * Callback called when the task is successful
  62351. */
  62352. onSuccess: (task: TextureAssetTask) => void;
  62353. /**
  62354. * Callback called when the task is successful
  62355. */
  62356. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  62357. /**
  62358. * Creates a new TextureAssetTask object
  62359. * @param name defines the name of the task
  62360. * @param url defines the location of the file to load
  62361. * @param noMipmap defines if mipmap should not be generated (default is false)
  62362. * @param invertY defines if texture must be inverted on Y axis (default is false)
  62363. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62364. */
  62365. constructor(
  62366. /**
  62367. * Defines the name of the task
  62368. */
  62369. name: string,
  62370. /**
  62371. * Defines the location of the file to load
  62372. */
  62373. url: string,
  62374. /**
  62375. * Defines if mipmap should not be generated (default is false)
  62376. */
  62377. noMipmap?: boolean | undefined,
  62378. /**
  62379. * Defines if texture must be inverted on Y axis (default is false)
  62380. */
  62381. invertY?: boolean | undefined,
  62382. /**
  62383. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  62384. */
  62385. samplingMode?: number);
  62386. /**
  62387. * Execute the current task
  62388. * @param scene defines the scene where you want your assets to be loaded
  62389. * @param onSuccess is a callback called when the task is successfully executed
  62390. * @param onError is a callback called if an error occurs
  62391. */
  62392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62393. }
  62394. /**
  62395. * Define a task used by AssetsManager to load cube textures
  62396. */
  62397. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  62398. /**
  62399. * Defines the name of the task
  62400. */
  62401. name: string;
  62402. /**
  62403. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62404. */
  62405. url: string;
  62406. /**
  62407. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62408. */
  62409. extensions?: string[] | undefined;
  62410. /**
  62411. * Defines if mipmaps should not be generated (default is false)
  62412. */
  62413. noMipmap?: boolean | undefined;
  62414. /**
  62415. * Defines the explicit list of files (undefined by default)
  62416. */
  62417. files?: string[] | undefined;
  62418. /**
  62419. * Gets the loaded texture
  62420. */
  62421. texture: CubeTexture;
  62422. /**
  62423. * Callback called when the task is successful
  62424. */
  62425. onSuccess: (task: CubeTextureAssetTask) => void;
  62426. /**
  62427. * Callback called when the task is successful
  62428. */
  62429. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  62430. /**
  62431. * Creates a new CubeTextureAssetTask
  62432. * @param name defines the name of the task
  62433. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62434. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62435. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62436. * @param files defines the explicit list of files (undefined by default)
  62437. */
  62438. constructor(
  62439. /**
  62440. * Defines the name of the task
  62441. */
  62442. name: string,
  62443. /**
  62444. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  62445. */
  62446. url: string,
  62447. /**
  62448. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  62449. */
  62450. extensions?: string[] | undefined,
  62451. /**
  62452. * Defines if mipmaps should not be generated (default is false)
  62453. */
  62454. noMipmap?: boolean | undefined,
  62455. /**
  62456. * Defines the explicit list of files (undefined by default)
  62457. */
  62458. files?: string[] | undefined);
  62459. /**
  62460. * Execute the current task
  62461. * @param scene defines the scene where you want your assets to be loaded
  62462. * @param onSuccess is a callback called when the task is successfully executed
  62463. * @param onError is a callback called if an error occurs
  62464. */
  62465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62466. }
  62467. /**
  62468. * Define a task used by AssetsManager to load HDR cube textures
  62469. */
  62470. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  62471. /**
  62472. * Defines the name of the task
  62473. */
  62474. name: string;
  62475. /**
  62476. * Defines the location of the file to load
  62477. */
  62478. url: string;
  62479. /**
  62480. * Defines the desired size (the more it increases the longer the generation will be)
  62481. */
  62482. size: number;
  62483. /**
  62484. * Defines if mipmaps should not be generated (default is false)
  62485. */
  62486. noMipmap: boolean;
  62487. /**
  62488. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62489. */
  62490. generateHarmonics: boolean;
  62491. /**
  62492. * 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)
  62493. */
  62494. gammaSpace: boolean;
  62495. /**
  62496. * Internal Use Only
  62497. */
  62498. reserved: boolean;
  62499. /**
  62500. * Gets the loaded texture
  62501. */
  62502. texture: HDRCubeTexture;
  62503. /**
  62504. * Callback called when the task is successful
  62505. */
  62506. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  62507. /**
  62508. * Callback called when the task is successful
  62509. */
  62510. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  62511. /**
  62512. * Creates a new HDRCubeTextureAssetTask object
  62513. * @param name defines the name of the task
  62514. * @param url defines the location of the file to load
  62515. * @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.
  62516. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62517. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62518. * @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)
  62519. * @param reserved Internal use only
  62520. */
  62521. constructor(
  62522. /**
  62523. * Defines the name of the task
  62524. */
  62525. name: string,
  62526. /**
  62527. * Defines the location of the file to load
  62528. */
  62529. url: string,
  62530. /**
  62531. * Defines the desired size (the more it increases the longer the generation will be)
  62532. */
  62533. size: number,
  62534. /**
  62535. * Defines if mipmaps should not be generated (default is false)
  62536. */
  62537. noMipmap?: boolean,
  62538. /**
  62539. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  62540. */
  62541. generateHarmonics?: boolean,
  62542. /**
  62543. * 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)
  62544. */
  62545. gammaSpace?: boolean,
  62546. /**
  62547. * Internal Use Only
  62548. */
  62549. reserved?: boolean);
  62550. /**
  62551. * Execute the current task
  62552. * @param scene defines the scene where you want your assets to be loaded
  62553. * @param onSuccess is a callback called when the task is successfully executed
  62554. * @param onError is a callback called if an error occurs
  62555. */
  62556. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62557. }
  62558. /**
  62559. * Define a task used by AssetsManager to load Equirectangular cube textures
  62560. */
  62561. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  62562. /**
  62563. * Defines the name of the task
  62564. */
  62565. name: string;
  62566. /**
  62567. * Defines the location of the file to load
  62568. */
  62569. url: string;
  62570. /**
  62571. * Defines the desired size (the more it increases the longer the generation will be)
  62572. */
  62573. size: number;
  62574. /**
  62575. * Defines if mipmaps should not be generated (default is false)
  62576. */
  62577. noMipmap: boolean;
  62578. /**
  62579. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62580. * but the standard material would require them in Gamma space) (default is true)
  62581. */
  62582. gammaSpace: boolean;
  62583. /**
  62584. * Gets the loaded texture
  62585. */
  62586. texture: EquiRectangularCubeTexture;
  62587. /**
  62588. * Callback called when the task is successful
  62589. */
  62590. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  62591. /**
  62592. * Callback called when the task is successful
  62593. */
  62594. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  62595. /**
  62596. * Creates a new EquiRectangularCubeTextureAssetTask object
  62597. * @param name defines the name of the task
  62598. * @param url defines the location of the file to load
  62599. * @param size defines the desired size (the more it increases the longer the generation will be)
  62600. * If the size is omitted this implies you are using a preprocessed cubemap.
  62601. * @param noMipmap defines if mipmaps should not be generated (default is false)
  62602. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  62603. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  62604. * (default is true)
  62605. */
  62606. constructor(
  62607. /**
  62608. * Defines the name of the task
  62609. */
  62610. name: string,
  62611. /**
  62612. * Defines the location of the file to load
  62613. */
  62614. url: string,
  62615. /**
  62616. * Defines the desired size (the more it increases the longer the generation will be)
  62617. */
  62618. size: number,
  62619. /**
  62620. * Defines if mipmaps should not be generated (default is false)
  62621. */
  62622. noMipmap?: boolean,
  62623. /**
  62624. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  62625. * but the standard material would require them in Gamma space) (default is true)
  62626. */
  62627. gammaSpace?: boolean);
  62628. /**
  62629. * Execute the current task
  62630. * @param scene defines the scene where you want your assets to be loaded
  62631. * @param onSuccess is a callback called when the task is successfully executed
  62632. * @param onError is a callback called if an error occurs
  62633. */
  62634. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  62635. }
  62636. /**
  62637. * This class can be used to easily import assets into a scene
  62638. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  62639. */
  62640. export class AssetsManager {
  62641. private _scene;
  62642. private _isLoading;
  62643. protected _tasks: AbstractAssetTask[];
  62644. protected _waitingTasksCount: number;
  62645. protected _totalTasksCount: number;
  62646. /**
  62647. * Callback called when all tasks are processed
  62648. */
  62649. onFinish: (tasks: AbstractAssetTask[]) => void;
  62650. /**
  62651. * Callback called when a task is successful
  62652. */
  62653. onTaskSuccess: (task: AbstractAssetTask) => void;
  62654. /**
  62655. * Callback called when a task had an error
  62656. */
  62657. onTaskError: (task: AbstractAssetTask) => void;
  62658. /**
  62659. * Callback called when a task is done (whatever the result is)
  62660. */
  62661. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  62662. /**
  62663. * Observable called when all tasks are processed
  62664. */
  62665. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  62666. /**
  62667. * Observable called when a task had an error
  62668. */
  62669. onTaskErrorObservable: Observable<AbstractAssetTask>;
  62670. /**
  62671. * Observable called when all tasks were executed
  62672. */
  62673. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  62674. /**
  62675. * Observable called when a task is done (whatever the result is)
  62676. */
  62677. onProgressObservable: Observable<IAssetsProgressEvent>;
  62678. /**
  62679. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  62680. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  62681. */
  62682. useDefaultLoadingScreen: boolean;
  62683. /**
  62684. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  62685. * when all assets have been downloaded.
  62686. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  62687. */
  62688. autoHideLoadingUI: boolean;
  62689. /**
  62690. * Creates a new AssetsManager
  62691. * @param scene defines the scene to work on
  62692. */
  62693. constructor(scene: Scene);
  62694. /**
  62695. * Add a MeshAssetTask to the list of active tasks
  62696. * @param taskName defines the name of the new task
  62697. * @param meshesNames defines the name of meshes to load
  62698. * @param rootUrl defines the root url to use to locate files
  62699. * @param sceneFilename defines the filename of the scene file
  62700. * @returns a new MeshAssetTask object
  62701. */
  62702. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  62703. /**
  62704. * Add a TextFileAssetTask to the list of active tasks
  62705. * @param taskName defines the name of the new task
  62706. * @param url defines the url of the file to load
  62707. * @returns a new TextFileAssetTask object
  62708. */
  62709. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  62710. /**
  62711. * Add a BinaryFileAssetTask to the list of active tasks
  62712. * @param taskName defines the name of the new task
  62713. * @param url defines the url of the file to load
  62714. * @returns a new BinaryFileAssetTask object
  62715. */
  62716. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  62717. /**
  62718. * Add a ImageAssetTask to the list of active tasks
  62719. * @param taskName defines the name of the new task
  62720. * @param url defines the url of the file to load
  62721. * @returns a new ImageAssetTask object
  62722. */
  62723. addImageTask(taskName: string, url: string): ImageAssetTask;
  62724. /**
  62725. * Add a TextureAssetTask to the list of active tasks
  62726. * @param taskName defines the name of the new task
  62727. * @param url defines the url of the file to load
  62728. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62729. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  62730. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62731. * @returns a new TextureAssetTask object
  62732. */
  62733. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  62734. /**
  62735. * Add a CubeTextureAssetTask to the list of active tasks
  62736. * @param taskName defines the name of the new task
  62737. * @param url defines the url of the file to load
  62738. * @param extensions defines the extension to use to load the cube map (can be null)
  62739. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62740. * @param files defines the list of files to load (can be null)
  62741. * @returns a new CubeTextureAssetTask object
  62742. */
  62743. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  62744. /**
  62745. *
  62746. * Add a HDRCubeTextureAssetTask to the list of active tasks
  62747. * @param taskName defines the name of the new task
  62748. * @param url defines the url of the file to load
  62749. * @param size defines the size you want for the cubemap (can be null)
  62750. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62751. * @param generateHarmonics defines if you want to automatically generate (true by default)
  62752. * @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)
  62753. * @param reserved Internal use only
  62754. * @returns a new HDRCubeTextureAssetTask object
  62755. */
  62756. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  62757. /**
  62758. *
  62759. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  62760. * @param taskName defines the name of the new task
  62761. * @param url defines the url of the file to load
  62762. * @param size defines the size you want for the cubemap (can be null)
  62763. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  62764. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62765. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62766. * @returns a new EquiRectangularCubeTextureAssetTask object
  62767. */
  62768. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  62769. /**
  62770. * Remove a task from the assets manager.
  62771. * @param task the task to remove
  62772. */
  62773. removeTask(task: AbstractAssetTask): void;
  62774. private _decreaseWaitingTasksCount;
  62775. private _runTask;
  62776. /**
  62777. * Reset the AssetsManager and remove all tasks
  62778. * @return the current instance of the AssetsManager
  62779. */
  62780. reset(): AssetsManager;
  62781. /**
  62782. * Start the loading process
  62783. * @return the current instance of the AssetsManager
  62784. */
  62785. load(): AssetsManager;
  62786. /**
  62787. * Start the loading process as an async operation
  62788. * @return a promise returning the list of failed tasks
  62789. */
  62790. loadAsync(): Promise<void>;
  62791. }
  62792. }
  62793. declare module "babylonjs/Misc/deferred" {
  62794. /**
  62795. * Wrapper class for promise with external resolve and reject.
  62796. */
  62797. export class Deferred<T> {
  62798. /**
  62799. * The promise associated with this deferred object.
  62800. */
  62801. readonly promise: Promise<T>;
  62802. private _resolve;
  62803. private _reject;
  62804. /**
  62805. * The resolve method of the promise associated with this deferred object.
  62806. */
  62807. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  62808. /**
  62809. * The reject method of the promise associated with this deferred object.
  62810. */
  62811. readonly reject: (reason?: any) => void;
  62812. /**
  62813. * Constructor for this deferred object.
  62814. */
  62815. constructor();
  62816. }
  62817. }
  62818. declare module "babylonjs/Misc/meshExploder" {
  62819. import { Mesh } from "babylonjs/Meshes/mesh";
  62820. /**
  62821. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  62822. */
  62823. export class MeshExploder {
  62824. private _centerMesh;
  62825. private _meshes;
  62826. private _meshesOrigins;
  62827. private _toCenterVectors;
  62828. private _scaledDirection;
  62829. private _newPosition;
  62830. private _centerPosition;
  62831. /**
  62832. * Explodes meshes from a center mesh.
  62833. * @param meshes The meshes to explode.
  62834. * @param centerMesh The mesh to be center of explosion.
  62835. */
  62836. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  62837. private _setCenterMesh;
  62838. /**
  62839. * Get class name
  62840. * @returns "MeshExploder"
  62841. */
  62842. getClassName(): string;
  62843. /**
  62844. * "Exploded meshes"
  62845. * @returns Array of meshes with the centerMesh at index 0.
  62846. */
  62847. getMeshes(): Array<Mesh>;
  62848. /**
  62849. * Explodes meshes giving a specific direction
  62850. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  62851. */
  62852. explode(direction?: number): void;
  62853. }
  62854. }
  62855. declare module "babylonjs/Misc/filesInput" {
  62856. import { Engine } from "babylonjs/Engines/engine";
  62857. import { Scene } from "babylonjs/scene";
  62858. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  62859. /**
  62860. * Class used to help managing file picking and drag'n'drop
  62861. */
  62862. export class FilesInput {
  62863. /**
  62864. * List of files ready to be loaded
  62865. */
  62866. static readonly FilesToLoad: {
  62867. [key: string]: File;
  62868. };
  62869. /**
  62870. * Callback called when a file is processed
  62871. */
  62872. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  62873. private _engine;
  62874. private _currentScene;
  62875. private _sceneLoadedCallback;
  62876. private _progressCallback;
  62877. private _additionalRenderLoopLogicCallback;
  62878. private _textureLoadingCallback;
  62879. private _startingProcessingFilesCallback;
  62880. private _onReloadCallback;
  62881. private _errorCallback;
  62882. private _elementToMonitor;
  62883. private _sceneFileToLoad;
  62884. private _filesToLoad;
  62885. /**
  62886. * Creates a new FilesInput
  62887. * @param engine defines the rendering engine
  62888. * @param scene defines the hosting scene
  62889. * @param sceneLoadedCallback callback called when scene is loaded
  62890. * @param progressCallback callback called to track progress
  62891. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  62892. * @param textureLoadingCallback callback called when a texture is loading
  62893. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  62894. * @param onReloadCallback callback called when a reload is requested
  62895. * @param errorCallback callback call if an error occurs
  62896. */
  62897. 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);
  62898. private _dragEnterHandler;
  62899. private _dragOverHandler;
  62900. private _dropHandler;
  62901. /**
  62902. * Calls this function to listen to drag'n'drop events on a specific DOM element
  62903. * @param elementToMonitor defines the DOM element to track
  62904. */
  62905. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  62906. /**
  62907. * Release all associated resources
  62908. */
  62909. dispose(): void;
  62910. private renderFunction;
  62911. private drag;
  62912. private drop;
  62913. private _traverseFolder;
  62914. private _processFiles;
  62915. /**
  62916. * Load files from a drop event
  62917. * @param event defines the drop event to use as source
  62918. */
  62919. loadFiles(event: any): void;
  62920. private _processReload;
  62921. /**
  62922. * Reload the current scene from the loaded files
  62923. */
  62924. reload(): void;
  62925. }
  62926. }
  62927. declare module "babylonjs/Misc/HighDynamicRange/index" {
  62928. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  62929. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  62930. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  62931. }
  62932. declare module "babylonjs/Misc/sceneOptimizer" {
  62933. import { Scene, IDisposable } from "babylonjs/scene";
  62934. import { Observable } from "babylonjs/Misc/observable";
  62935. /**
  62936. * Defines the root class used to create scene optimization to use with SceneOptimizer
  62937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62938. */
  62939. export class SceneOptimization {
  62940. /**
  62941. * Defines the priority of this optimization (0 by default which means first in the list)
  62942. */
  62943. priority: number;
  62944. /**
  62945. * Gets a string describing the action executed by the current optimization
  62946. * @returns description string
  62947. */
  62948. getDescription(): string;
  62949. /**
  62950. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62951. * @param scene defines the current scene where to apply this optimization
  62952. * @param optimizer defines the current optimizer
  62953. * @returns true if everything that can be done was applied
  62954. */
  62955. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62956. /**
  62957. * Creates the SceneOptimization object
  62958. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62959. * @param desc defines the description associated with the optimization
  62960. */
  62961. constructor(
  62962. /**
  62963. * Defines the priority of this optimization (0 by default which means first in the list)
  62964. */
  62965. priority?: number);
  62966. }
  62967. /**
  62968. * Defines an optimization used to reduce the size of render target textures
  62969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62970. */
  62971. export class TextureOptimization extends SceneOptimization {
  62972. /**
  62973. * Defines the priority of this optimization (0 by default which means first in the list)
  62974. */
  62975. priority: number;
  62976. /**
  62977. * 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
  62978. */
  62979. maximumSize: number;
  62980. /**
  62981. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62982. */
  62983. step: number;
  62984. /**
  62985. * Gets a string describing the action executed by the current optimization
  62986. * @returns description string
  62987. */
  62988. getDescription(): string;
  62989. /**
  62990. * Creates the TextureOptimization object
  62991. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62992. * @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
  62993. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  62994. */
  62995. constructor(
  62996. /**
  62997. * Defines the priority of this optimization (0 by default which means first in the list)
  62998. */
  62999. priority?: number,
  63000. /**
  63001. * 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
  63002. */
  63003. maximumSize?: number,
  63004. /**
  63005. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  63006. */
  63007. step?: number);
  63008. /**
  63009. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63010. * @param scene defines the current scene where to apply this optimization
  63011. * @param optimizer defines the current optimizer
  63012. * @returns true if everything that can be done was applied
  63013. */
  63014. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63015. }
  63016. /**
  63017. * Defines an optimization used to increase or decrease the rendering resolution
  63018. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63019. */
  63020. export class HardwareScalingOptimization extends SceneOptimization {
  63021. /**
  63022. * Defines the priority of this optimization (0 by default which means first in the list)
  63023. */
  63024. priority: number;
  63025. /**
  63026. * Defines the maximum scale to use (2 by default)
  63027. */
  63028. maximumScale: number;
  63029. /**
  63030. * Defines the step to use between two passes (0.5 by default)
  63031. */
  63032. step: number;
  63033. private _currentScale;
  63034. private _directionOffset;
  63035. /**
  63036. * Gets a string describing the action executed by the current optimization
  63037. * @return description string
  63038. */
  63039. getDescription(): string;
  63040. /**
  63041. * Creates the HardwareScalingOptimization object
  63042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63043. * @param maximumScale defines the maximum scale to use (2 by default)
  63044. * @param step defines the step to use between two passes (0.5 by default)
  63045. */
  63046. constructor(
  63047. /**
  63048. * Defines the priority of this optimization (0 by default which means first in the list)
  63049. */
  63050. priority?: number,
  63051. /**
  63052. * Defines the maximum scale to use (2 by default)
  63053. */
  63054. maximumScale?: number,
  63055. /**
  63056. * Defines the step to use between two passes (0.5 by default)
  63057. */
  63058. step?: number);
  63059. /**
  63060. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63061. * @param scene defines the current scene where to apply this optimization
  63062. * @param optimizer defines the current optimizer
  63063. * @returns true if everything that can be done was applied
  63064. */
  63065. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63066. }
  63067. /**
  63068. * Defines an optimization used to remove shadows
  63069. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63070. */
  63071. export class ShadowsOptimization extends SceneOptimization {
  63072. /**
  63073. * Gets a string describing the action executed by the current optimization
  63074. * @return description string
  63075. */
  63076. getDescription(): string;
  63077. /**
  63078. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63079. * @param scene defines the current scene where to apply this optimization
  63080. * @param optimizer defines the current optimizer
  63081. * @returns true if everything that can be done was applied
  63082. */
  63083. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63084. }
  63085. /**
  63086. * Defines an optimization used to turn post-processes off
  63087. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63088. */
  63089. export class PostProcessesOptimization extends SceneOptimization {
  63090. /**
  63091. * Gets a string describing the action executed by the current optimization
  63092. * @return description string
  63093. */
  63094. getDescription(): string;
  63095. /**
  63096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63097. * @param scene defines the current scene where to apply this optimization
  63098. * @param optimizer defines the current optimizer
  63099. * @returns true if everything that can be done was applied
  63100. */
  63101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63102. }
  63103. /**
  63104. * Defines an optimization used to turn lens flares off
  63105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63106. */
  63107. export class LensFlaresOptimization extends SceneOptimization {
  63108. /**
  63109. * Gets a string describing the action executed by the current optimization
  63110. * @return description string
  63111. */
  63112. getDescription(): string;
  63113. /**
  63114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63115. * @param scene defines the current scene where to apply this optimization
  63116. * @param optimizer defines the current optimizer
  63117. * @returns true if everything that can be done was applied
  63118. */
  63119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63120. }
  63121. /**
  63122. * Defines an optimization based on user defined callback.
  63123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63124. */
  63125. export class CustomOptimization extends SceneOptimization {
  63126. /**
  63127. * Callback called to apply the custom optimization.
  63128. */
  63129. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  63130. /**
  63131. * Callback called to get custom description
  63132. */
  63133. onGetDescription: () => string;
  63134. /**
  63135. * Gets a string describing the action executed by the current optimization
  63136. * @returns description string
  63137. */
  63138. getDescription(): string;
  63139. /**
  63140. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63141. * @param scene defines the current scene where to apply this optimization
  63142. * @param optimizer defines the current optimizer
  63143. * @returns true if everything that can be done was applied
  63144. */
  63145. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63146. }
  63147. /**
  63148. * Defines an optimization used to turn particles off
  63149. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63150. */
  63151. export class ParticlesOptimization extends SceneOptimization {
  63152. /**
  63153. * Gets a string describing the action executed by the current optimization
  63154. * @return description string
  63155. */
  63156. getDescription(): string;
  63157. /**
  63158. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63159. * @param scene defines the current scene where to apply this optimization
  63160. * @param optimizer defines the current optimizer
  63161. * @returns true if everything that can be done was applied
  63162. */
  63163. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63164. }
  63165. /**
  63166. * Defines an optimization used to turn render targets off
  63167. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63168. */
  63169. export class RenderTargetsOptimization extends SceneOptimization {
  63170. /**
  63171. * Gets a string describing the action executed by the current optimization
  63172. * @return description string
  63173. */
  63174. getDescription(): string;
  63175. /**
  63176. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63177. * @param scene defines the current scene where to apply this optimization
  63178. * @param optimizer defines the current optimizer
  63179. * @returns true if everything that can be done was applied
  63180. */
  63181. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  63182. }
  63183. /**
  63184. * Defines an optimization used to merge meshes with compatible materials
  63185. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63186. */
  63187. export class MergeMeshesOptimization extends SceneOptimization {
  63188. private static _UpdateSelectionTree;
  63189. /**
  63190. * Gets or sets a boolean which defines if optimization octree has to be updated
  63191. */
  63192. /**
  63193. * Gets or sets a boolean which defines if optimization octree has to be updated
  63194. */
  63195. static UpdateSelectionTree: boolean;
  63196. /**
  63197. * Gets a string describing the action executed by the current optimization
  63198. * @return description string
  63199. */
  63200. getDescription(): string;
  63201. private _canBeMerged;
  63202. /**
  63203. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  63204. * @param scene defines the current scene where to apply this optimization
  63205. * @param optimizer defines the current optimizer
  63206. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  63207. * @returns true if everything that can be done was applied
  63208. */
  63209. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  63210. }
  63211. /**
  63212. * Defines a list of options used by SceneOptimizer
  63213. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63214. */
  63215. export class SceneOptimizerOptions {
  63216. /**
  63217. * Defines the target frame rate to reach (60 by default)
  63218. */
  63219. targetFrameRate: number;
  63220. /**
  63221. * Defines the interval between two checkes (2000ms by default)
  63222. */
  63223. trackerDuration: number;
  63224. /**
  63225. * Gets the list of optimizations to apply
  63226. */
  63227. optimizations: SceneOptimization[];
  63228. /**
  63229. * Creates a new list of options used by SceneOptimizer
  63230. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  63231. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  63232. */
  63233. constructor(
  63234. /**
  63235. * Defines the target frame rate to reach (60 by default)
  63236. */
  63237. targetFrameRate?: number,
  63238. /**
  63239. * Defines the interval between two checkes (2000ms by default)
  63240. */
  63241. trackerDuration?: number);
  63242. /**
  63243. * Add a new optimization
  63244. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  63245. * @returns the current SceneOptimizerOptions
  63246. */
  63247. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  63248. /**
  63249. * Add a new custom optimization
  63250. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  63251. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  63252. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  63253. * @returns the current SceneOptimizerOptions
  63254. */
  63255. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  63256. /**
  63257. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  63258. * @param targetFrameRate defines the target frame rate (60 by default)
  63259. * @returns a SceneOptimizerOptions object
  63260. */
  63261. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63262. /**
  63263. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  63264. * @param targetFrameRate defines the target frame rate (60 by default)
  63265. * @returns a SceneOptimizerOptions object
  63266. */
  63267. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63268. /**
  63269. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  63270. * @param targetFrameRate defines the target frame rate (60 by default)
  63271. * @returns a SceneOptimizerOptions object
  63272. */
  63273. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  63274. }
  63275. /**
  63276. * Class used to run optimizations in order to reach a target frame rate
  63277. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  63278. */
  63279. export class SceneOptimizer implements IDisposable {
  63280. private _isRunning;
  63281. private _options;
  63282. private _scene;
  63283. private _currentPriorityLevel;
  63284. private _targetFrameRate;
  63285. private _trackerDuration;
  63286. private _currentFrameRate;
  63287. private _sceneDisposeObserver;
  63288. private _improvementMode;
  63289. /**
  63290. * Defines an observable called when the optimizer reaches the target frame rate
  63291. */
  63292. onSuccessObservable: Observable<SceneOptimizer>;
  63293. /**
  63294. * Defines an observable called when the optimizer enables an optimization
  63295. */
  63296. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  63297. /**
  63298. * Defines an observable called when the optimizer is not able to reach the target frame rate
  63299. */
  63300. onFailureObservable: Observable<SceneOptimizer>;
  63301. /**
  63302. * Gets a boolean indicating if the optimizer is in improvement mode
  63303. */
  63304. readonly isInImprovementMode: boolean;
  63305. /**
  63306. * Gets the current priority level (0 at start)
  63307. */
  63308. readonly currentPriorityLevel: number;
  63309. /**
  63310. * Gets the current frame rate checked by the SceneOptimizer
  63311. */
  63312. readonly currentFrameRate: number;
  63313. /**
  63314. * Gets or sets the current target frame rate (60 by default)
  63315. */
  63316. /**
  63317. * Gets or sets the current target frame rate (60 by default)
  63318. */
  63319. targetFrameRate: number;
  63320. /**
  63321. * Gets or sets the current interval between two checks (every 2000ms by default)
  63322. */
  63323. /**
  63324. * Gets or sets the current interval between two checks (every 2000ms by default)
  63325. */
  63326. trackerDuration: number;
  63327. /**
  63328. * Gets the list of active optimizations
  63329. */
  63330. readonly optimizations: SceneOptimization[];
  63331. /**
  63332. * Creates a new SceneOptimizer
  63333. * @param scene defines the scene to work on
  63334. * @param options defines the options to use with the SceneOptimizer
  63335. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  63336. * @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)
  63337. */
  63338. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  63339. /**
  63340. * Stops the current optimizer
  63341. */
  63342. stop(): void;
  63343. /**
  63344. * Reset the optimizer to initial step (current priority level = 0)
  63345. */
  63346. reset(): void;
  63347. /**
  63348. * Start the optimizer. By default it will try to reach a specific framerate
  63349. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  63350. */
  63351. start(): void;
  63352. private _checkCurrentState;
  63353. /**
  63354. * Release all resources
  63355. */
  63356. dispose(): void;
  63357. /**
  63358. * Helper function to create a SceneOptimizer with one single line of code
  63359. * @param scene defines the scene to work on
  63360. * @param options defines the options to use with the SceneOptimizer
  63361. * @param onSuccess defines a callback to call on success
  63362. * @param onFailure defines a callback to call on failure
  63363. * @returns the new SceneOptimizer object
  63364. */
  63365. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  63366. }
  63367. }
  63368. declare module "babylonjs/Misc/sceneSerializer" {
  63369. import { Scene } from "babylonjs/scene";
  63370. /**
  63371. * Class used to serialize a scene into a string
  63372. */
  63373. export class SceneSerializer {
  63374. /**
  63375. * Clear cache used by a previous serialization
  63376. */
  63377. static ClearCache(): void;
  63378. /**
  63379. * Serialize a scene into a JSON compatible object
  63380. * @param scene defines the scene to serialize
  63381. * @returns a JSON compatible object
  63382. */
  63383. static Serialize(scene: Scene): any;
  63384. /**
  63385. * Serialize a mesh into a JSON compatible object
  63386. * @param toSerialize defines the mesh to serialize
  63387. * @param withParents defines if parents must be serialized as well
  63388. * @param withChildren defines if children must be serialized as well
  63389. * @returns a JSON compatible object
  63390. */
  63391. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  63392. }
  63393. }
  63394. declare module "babylonjs/Misc/textureTools" {
  63395. import { Texture } from "babylonjs/Materials/Textures/texture";
  63396. /**
  63397. * Class used to host texture specific utilities
  63398. */
  63399. export class TextureTools {
  63400. /**
  63401. * Uses the GPU to create a copy texture rescaled at a given size
  63402. * @param texture Texture to copy from
  63403. * @param width defines the desired width
  63404. * @param height defines the desired height
  63405. * @param useBilinearMode defines if bilinear mode has to be used
  63406. * @return the generated texture
  63407. */
  63408. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  63409. }
  63410. }
  63411. declare module "babylonjs/Misc/videoRecorder" {
  63412. import { Nullable } from "babylonjs/types";
  63413. import { Engine } from "babylonjs/Engines/engine";
  63414. /**
  63415. * This represents the different options available for the video capture.
  63416. */
  63417. export interface VideoRecorderOptions {
  63418. /** Defines the mime type of the video. */
  63419. mimeType: string;
  63420. /** Defines the FPS the video should be recorded at. */
  63421. fps: number;
  63422. /** Defines the chunk size for the recording data. */
  63423. recordChunckSize: number;
  63424. /** The audio tracks to attach to the recording. */
  63425. audioTracks?: MediaStreamTrack[];
  63426. }
  63427. /**
  63428. * This can help with recording videos from BabylonJS.
  63429. * This is based on the available WebRTC functionalities of the browser.
  63430. *
  63431. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  63432. */
  63433. export class VideoRecorder {
  63434. private static readonly _defaultOptions;
  63435. /**
  63436. * Returns whether or not the VideoRecorder is available in your browser.
  63437. * @param engine Defines the Babylon Engine.
  63438. * @returns true if supported otherwise false.
  63439. */
  63440. static IsSupported(engine: Engine): boolean;
  63441. private readonly _options;
  63442. private _canvas;
  63443. private _mediaRecorder;
  63444. private _recordedChunks;
  63445. private _fileName;
  63446. private _resolve;
  63447. private _reject;
  63448. /**
  63449. * True when a recording is already in progress.
  63450. */
  63451. readonly isRecording: boolean;
  63452. /**
  63453. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  63454. * @param engine Defines the BabylonJS Engine you wish to record.
  63455. * @param options Defines options that can be used to customize the capture.
  63456. */
  63457. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  63458. /**
  63459. * Stops the current recording before the default capture timeout passed in the startRecording function.
  63460. */
  63461. stopRecording(): void;
  63462. /**
  63463. * Starts recording the canvas for a max duration specified in parameters.
  63464. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  63465. * If null no automatic download will start and you can rely on the promise to get the data back.
  63466. * @param maxDuration Defines the maximum recording time in seconds.
  63467. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  63468. * @return A promise callback at the end of the recording with the video data in Blob.
  63469. */
  63470. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  63471. /**
  63472. * Releases internal resources used during the recording.
  63473. */
  63474. dispose(): void;
  63475. private _handleDataAvailable;
  63476. private _handleError;
  63477. private _handleStop;
  63478. }
  63479. }
  63480. declare module "babylonjs/Misc/screenshotTools" {
  63481. import { Camera } from "babylonjs/Cameras/camera";
  63482. import { Engine } from "babylonjs/Engines/engine";
  63483. /**
  63484. * Class containing a set of static utilities functions for screenshots
  63485. */
  63486. export class ScreenshotTools {
  63487. /**
  63488. * Captures a screenshot of the current rendering
  63489. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63490. * @param engine defines the rendering engine
  63491. * @param camera defines the source camera
  63492. * @param size This parameter can be set to a single number or to an object with the
  63493. * following (optional) properties: precision, width, height. If a single number is passed,
  63494. * it will be used for both width and height. If an object is passed, the screenshot size
  63495. * will be derived from the parameters. The precision property is a multiplier allowing
  63496. * rendering at a higher or lower resolution
  63497. * @param successCallback defines the callback receives a single parameter which contains the
  63498. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63499. * src parameter of an <img> to display it
  63500. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63501. * Check your browser for supported MIME types
  63502. */
  63503. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  63504. /**
  63505. * Captures a screenshot of the current rendering
  63506. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63507. * @param engine defines the rendering engine
  63508. * @param camera defines the source camera
  63509. * @param size This parameter can be set to a single number or to an object with the
  63510. * following (optional) properties: precision, width, height. If a single number is passed,
  63511. * it will be used for both width and height. If an object is passed, the screenshot size
  63512. * will be derived from the parameters. The precision property is a multiplier allowing
  63513. * rendering at a higher or lower resolution
  63514. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  63515. * Check your browser for supported MIME types
  63516. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63517. * to the src parameter of an <img> to display it
  63518. */
  63519. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  63520. /**
  63521. * Generates an image screenshot from the specified camera.
  63522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63523. * @param engine The engine to use for rendering
  63524. * @param camera The camera to use for rendering
  63525. * @param size This parameter can be set to a single number or to an object with the
  63526. * following (optional) properties: precision, width, height. If a single number is passed,
  63527. * it will be used for both width and height. If an object is passed, the screenshot size
  63528. * will be derived from the parameters. The precision property is a multiplier allowing
  63529. * rendering at a higher or lower resolution
  63530. * @param successCallback The callback receives a single parameter which contains the
  63531. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  63532. * src parameter of an <img> to display it
  63533. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63534. * Check your browser for supported MIME types
  63535. * @param samples Texture samples (default: 1)
  63536. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63537. * @param fileName A name for for the downloaded file.
  63538. */
  63539. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  63540. /**
  63541. * Generates an image screenshot from the specified camera.
  63542. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  63543. * @param engine The engine to use for rendering
  63544. * @param camera The camera to use for rendering
  63545. * @param size This parameter can be set to a single number or to an object with the
  63546. * following (optional) properties: precision, width, height. If a single number is passed,
  63547. * it will be used for both width and height. If an object is passed, the screenshot size
  63548. * will be derived from the parameters. The precision property is a multiplier allowing
  63549. * rendering at a higher or lower resolution
  63550. * @param mimeType The MIME type of the screenshot image (default: image/png).
  63551. * Check your browser for supported MIME types
  63552. * @param samples Texture samples (default: 1)
  63553. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  63554. * @param fileName A name for for the downloaded file.
  63555. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  63556. * to the src parameter of an <img> to display it
  63557. */
  63558. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  63559. }
  63560. }
  63561. declare module "babylonjs/Misc/index" {
  63562. export * from "babylonjs/Misc/andOrNotEvaluator";
  63563. export * from "babylonjs/Misc/assetsManager";
  63564. export * from "babylonjs/Misc/dds";
  63565. export * from "babylonjs/Misc/decorators";
  63566. export * from "babylonjs/Misc/deferred";
  63567. export * from "babylonjs/Misc/environmentTextureTools";
  63568. export * from "babylonjs/Misc/meshExploder";
  63569. export * from "babylonjs/Misc/filesInput";
  63570. export * from "babylonjs/Misc/HighDynamicRange/index";
  63571. export * from "babylonjs/Misc/khronosTextureContainer";
  63572. export * from "babylonjs/Misc/observable";
  63573. export * from "babylonjs/Misc/performanceMonitor";
  63574. export * from "babylonjs/Misc/promise";
  63575. export * from "babylonjs/Misc/sceneOptimizer";
  63576. export * from "babylonjs/Misc/sceneSerializer";
  63577. export * from "babylonjs/Misc/smartArray";
  63578. export * from "babylonjs/Misc/stringDictionary";
  63579. export * from "babylonjs/Misc/tags";
  63580. export * from "babylonjs/Misc/textureTools";
  63581. export * from "babylonjs/Misc/tga";
  63582. export * from "babylonjs/Misc/tools";
  63583. export * from "babylonjs/Misc/videoRecorder";
  63584. export * from "babylonjs/Misc/virtualJoystick";
  63585. export * from "babylonjs/Misc/workerPool";
  63586. export * from "babylonjs/Misc/logger";
  63587. export * from "babylonjs/Misc/typeStore";
  63588. export * from "babylonjs/Misc/filesInputStore";
  63589. export * from "babylonjs/Misc/deepCopier";
  63590. export * from "babylonjs/Misc/pivotTools";
  63591. export * from "babylonjs/Misc/precisionDate";
  63592. export * from "babylonjs/Misc/screenshotTools";
  63593. export * from "babylonjs/Misc/typeStore";
  63594. export * from "babylonjs/Misc/webRequest";
  63595. export * from "babylonjs/Misc/iInspectable";
  63596. export * from "babylonjs/Misc/brdfTextureTools";
  63597. export * from "babylonjs/Misc/gradients";
  63598. export * from "babylonjs/Misc/perfCounter";
  63599. export * from "babylonjs/Misc/fileRequest";
  63600. export * from "babylonjs/Misc/customAnimationFrameRequester";
  63601. export * from "babylonjs/Misc/retryStrategy";
  63602. export * from "babylonjs/Misc/loadFileError";
  63603. }
  63604. declare module "babylonjs/index" {
  63605. export * from "babylonjs/abstractScene";
  63606. export * from "babylonjs/Actions/index";
  63607. export * from "babylonjs/Animations/index";
  63608. export * from "babylonjs/assetContainer";
  63609. export * from "babylonjs/Audio/index";
  63610. export * from "babylonjs/Behaviors/index";
  63611. export * from "babylonjs/Bones/index";
  63612. export * from "babylonjs/Cameras/index";
  63613. export * from "babylonjs/Collisions/index";
  63614. export * from "babylonjs/Culling/index";
  63615. export * from "babylonjs/Debug/index";
  63616. export * from "babylonjs/Engines/index";
  63617. export * from "babylonjs/Events/index";
  63618. export * from "babylonjs/Gamepads/index";
  63619. export * from "babylonjs/Gizmos/index";
  63620. export * from "babylonjs/Helpers/index";
  63621. export * from "babylonjs/Instrumentation/index";
  63622. export * from "babylonjs/Layers/index";
  63623. export * from "babylonjs/LensFlares/index";
  63624. export * from "babylonjs/Lights/index";
  63625. export * from "babylonjs/Loading/index";
  63626. export * from "babylonjs/Materials/index";
  63627. export * from "babylonjs/Maths/index";
  63628. export * from "babylonjs/Meshes/index";
  63629. export * from "babylonjs/Morph/index";
  63630. export * from "babylonjs/Navigation/index";
  63631. export * from "babylonjs/node";
  63632. export * from "babylonjs/Offline/index";
  63633. export * from "babylonjs/Particles/index";
  63634. export * from "babylonjs/Physics/index";
  63635. export * from "babylonjs/PostProcesses/index";
  63636. export * from "babylonjs/Probes/index";
  63637. export * from "babylonjs/Rendering/index";
  63638. export * from "babylonjs/scene";
  63639. export * from "babylonjs/sceneComponent";
  63640. export * from "babylonjs/Sprites/index";
  63641. export * from "babylonjs/States/index";
  63642. export * from "babylonjs/Misc/index";
  63643. export * from "babylonjs/types";
  63644. }
  63645. declare module "babylonjs/Animations/pathCursor" {
  63646. import { Vector3 } from "babylonjs/Maths/math.vector";
  63647. import { Path2 } from "babylonjs/Maths/math.path";
  63648. /**
  63649. * A cursor which tracks a point on a path
  63650. */
  63651. export class PathCursor {
  63652. private path;
  63653. /**
  63654. * Stores path cursor callbacks for when an onchange event is triggered
  63655. */
  63656. private _onchange;
  63657. /**
  63658. * The value of the path cursor
  63659. */
  63660. value: number;
  63661. /**
  63662. * The animation array of the path cursor
  63663. */
  63664. animations: Animation[];
  63665. /**
  63666. * Initializes the path cursor
  63667. * @param path The path to track
  63668. */
  63669. constructor(path: Path2);
  63670. /**
  63671. * Gets the cursor point on the path
  63672. * @returns A point on the path cursor at the cursor location
  63673. */
  63674. getPoint(): Vector3;
  63675. /**
  63676. * Moves the cursor ahead by the step amount
  63677. * @param step The amount to move the cursor forward
  63678. * @returns This path cursor
  63679. */
  63680. moveAhead(step?: number): PathCursor;
  63681. /**
  63682. * Moves the cursor behind by the step amount
  63683. * @param step The amount to move the cursor back
  63684. * @returns This path cursor
  63685. */
  63686. moveBack(step?: number): PathCursor;
  63687. /**
  63688. * Moves the cursor by the step amount
  63689. * If the step amount is greater than one, an exception is thrown
  63690. * @param step The amount to move the cursor
  63691. * @returns This path cursor
  63692. */
  63693. move(step: number): PathCursor;
  63694. /**
  63695. * Ensures that the value is limited between zero and one
  63696. * @returns This path cursor
  63697. */
  63698. private ensureLimits;
  63699. /**
  63700. * Runs onchange callbacks on change (used by the animation engine)
  63701. * @returns This path cursor
  63702. */
  63703. private raiseOnChange;
  63704. /**
  63705. * Executes a function on change
  63706. * @param f A path cursor onchange callback
  63707. * @returns This path cursor
  63708. */
  63709. onchange(f: (cursor: PathCursor) => void): PathCursor;
  63710. }
  63711. }
  63712. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  63713. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  63714. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  63715. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  63716. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  63717. }
  63718. declare module "babylonjs/Engines/Processors/Expressions/index" {
  63719. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  63720. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  63721. }
  63722. declare module "babylonjs/Engines/Processors/index" {
  63723. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  63724. export * from "babylonjs/Engines/Processors/Expressions/index";
  63725. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  63726. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  63727. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  63728. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  63729. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  63730. export * from "babylonjs/Engines/Processors/shaderProcessor";
  63731. }
  63732. declare module "babylonjs/Legacy/legacy" {
  63733. import * as Babylon from "babylonjs/index";
  63734. export * from "babylonjs/index";
  63735. }
  63736. declare module "babylonjs/Shaders/blur.fragment" {
  63737. /** @hidden */
  63738. export var blurPixelShader: {
  63739. name: string;
  63740. shader: string;
  63741. };
  63742. }
  63743. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  63744. /** @hidden */
  63745. export var pointCloudVertexDeclaration: {
  63746. name: string;
  63747. shader: string;
  63748. };
  63749. }
  63750. declare module "babylonjs" {
  63751. export * from "babylonjs/Legacy/legacy";
  63752. }
  63753. declare module BABYLON {
  63754. /** Alias type for value that can be null */
  63755. export type Nullable<T> = T | null;
  63756. /**
  63757. * Alias type for number that are floats
  63758. * @ignorenaming
  63759. */
  63760. export type float = number;
  63761. /**
  63762. * Alias type for number that are doubles.
  63763. * @ignorenaming
  63764. */
  63765. export type double = number;
  63766. /**
  63767. * Alias type for number that are integer
  63768. * @ignorenaming
  63769. */
  63770. export type int = number;
  63771. /** Alias type for number array or Float32Array */
  63772. export type FloatArray = number[] | Float32Array;
  63773. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  63774. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  63775. /**
  63776. * Alias for types that can be used by a Buffer or VertexBuffer.
  63777. */
  63778. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  63779. /**
  63780. * Alias type for primitive types
  63781. * @ignorenaming
  63782. */
  63783. type Primitive = undefined | null | boolean | string | number | Function;
  63784. /**
  63785. * Type modifier to make all the properties of an object Readonly
  63786. */
  63787. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  63788. /**
  63789. * Type modifier to make all the properties of an object Readonly recursively
  63790. */
  63791. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  63792. /** @hidden */
  63793. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  63794. }
  63795. /** @hidden */
  63796. /** @hidden */
  63797. type DeepImmutableObject<T> = {
  63798. readonly [K in keyof T]: DeepImmutable<T[K]>;
  63799. };
  63800. }
  63801. declare module BABYLON {
  63802. /**
  63803. * A class serves as a medium between the observable and its observers
  63804. */
  63805. export class EventState {
  63806. /**
  63807. * Create a new EventState
  63808. * @param mask defines the mask associated with this state
  63809. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63810. * @param target defines the original target of the state
  63811. * @param currentTarget defines the current target of the state
  63812. */
  63813. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63814. /**
  63815. * Initialize the current event state
  63816. * @param mask defines the mask associated with this state
  63817. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63818. * @param target defines the original target of the state
  63819. * @param currentTarget defines the current target of the state
  63820. * @returns the current event state
  63821. */
  63822. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63823. /**
  63824. * An Observer can set this property to true to prevent subsequent observers of being notified
  63825. */
  63826. skipNextObservers: boolean;
  63827. /**
  63828. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63829. */
  63830. mask: number;
  63831. /**
  63832. * The object that originally notified the event
  63833. */
  63834. target?: any;
  63835. /**
  63836. * The current object in the bubbling phase
  63837. */
  63838. currentTarget?: any;
  63839. /**
  63840. * This will be populated with the return value of the last function that was executed.
  63841. * If it is the first function in the callback chain it will be the event data.
  63842. */
  63843. lastReturnValue?: any;
  63844. }
  63845. /**
  63846. * Represent an Observer registered to a given Observable object.
  63847. */
  63848. export class Observer<T> {
  63849. /**
  63850. * Defines the callback to call when the observer is notified
  63851. */
  63852. callback: (eventData: T, eventState: EventState) => void;
  63853. /**
  63854. * Defines the mask of the observer (used to filter notifications)
  63855. */
  63856. mask: number;
  63857. /**
  63858. * Defines the current scope used to restore the JS context
  63859. */
  63860. scope: any;
  63861. /** @hidden */
  63862. _willBeUnregistered: boolean;
  63863. /**
  63864. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63865. */
  63866. unregisterOnNextCall: boolean;
  63867. /**
  63868. * Creates a new observer
  63869. * @param callback defines the callback to call when the observer is notified
  63870. * @param mask defines the mask of the observer (used to filter notifications)
  63871. * @param scope defines the current scope used to restore the JS context
  63872. */
  63873. constructor(
  63874. /**
  63875. * Defines the callback to call when the observer is notified
  63876. */
  63877. callback: (eventData: T, eventState: EventState) => void,
  63878. /**
  63879. * Defines the mask of the observer (used to filter notifications)
  63880. */
  63881. mask: number,
  63882. /**
  63883. * Defines the current scope used to restore the JS context
  63884. */
  63885. scope?: any);
  63886. }
  63887. /**
  63888. * Represent a list of observers registered to multiple Observables object.
  63889. */
  63890. export class MultiObserver<T> {
  63891. private _observers;
  63892. private _observables;
  63893. /**
  63894. * Release associated resources
  63895. */
  63896. dispose(): void;
  63897. /**
  63898. * Raise a callback when one of the observable will notify
  63899. * @param observables defines a list of observables to watch
  63900. * @param callback defines the callback to call on notification
  63901. * @param mask defines the mask used to filter notifications
  63902. * @param scope defines the current scope used to restore the JS context
  63903. * @returns the new MultiObserver
  63904. */
  63905. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63906. }
  63907. /**
  63908. * The Observable class is a simple implementation of the Observable pattern.
  63909. *
  63910. * 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.
  63911. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63912. * 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).
  63913. * 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.
  63914. */
  63915. export class Observable<T> {
  63916. private _observers;
  63917. private _eventState;
  63918. private _onObserverAdded;
  63919. /**
  63920. * Gets the list of observers
  63921. */
  63922. readonly observers: Array<Observer<T>>;
  63923. /**
  63924. * Creates a new observable
  63925. * @param onObserverAdded defines a callback to call when a new observer is added
  63926. */
  63927. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63928. /**
  63929. * Create a new Observer with the specified callback
  63930. * @param callback the callback that will be executed for that Observer
  63931. * @param mask the mask used to filter observers
  63932. * @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.
  63933. * @param scope optional scope for the callback to be called from
  63934. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63935. * @returns the new observer created for the callback
  63936. */
  63937. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63938. /**
  63939. * Create a new Observer with the specified callback and unregisters after the next notification
  63940. * @param callback the callback that will be executed for that Observer
  63941. * @returns the new observer created for the callback
  63942. */
  63943. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63944. /**
  63945. * Remove an Observer from the Observable object
  63946. * @param observer the instance of the Observer to remove
  63947. * @returns false if it doesn't belong to this Observable
  63948. */
  63949. remove(observer: Nullable<Observer<T>>): boolean;
  63950. /**
  63951. * Remove a callback from the Observable object
  63952. * @param callback the callback to remove
  63953. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63954. * @returns false if it doesn't belong to this Observable
  63955. */
  63956. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63957. private _deferUnregister;
  63958. private _remove;
  63959. /**
  63960. * Moves the observable to the top of the observer list making it get called first when notified
  63961. * @param observer the observer to move
  63962. */
  63963. makeObserverTopPriority(observer: Observer<T>): void;
  63964. /**
  63965. * Moves the observable to the bottom of the observer list making it get called last when notified
  63966. * @param observer the observer to move
  63967. */
  63968. makeObserverBottomPriority(observer: Observer<T>): void;
  63969. /**
  63970. * Notify all Observers by calling their respective callback with the given data
  63971. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63972. * @param eventData defines the data to send to all observers
  63973. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63974. * @param target defines the original target of the state
  63975. * @param currentTarget defines the current target of the state
  63976. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63977. */
  63978. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63979. /**
  63980. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63981. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63982. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63983. * and it is crucial that all callbacks will be executed.
  63984. * The order of the callbacks is kept, callbacks are not executed parallel.
  63985. *
  63986. * @param eventData The data to be sent to each callback
  63987. * @param mask is used to filter observers defaults to -1
  63988. * @param target defines the callback target (see EventState)
  63989. * @param currentTarget defines he current object in the bubbling phase
  63990. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63991. */
  63992. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63993. /**
  63994. * Notify a specific observer
  63995. * @param observer defines the observer to notify
  63996. * @param eventData defines the data to be sent to each callback
  63997. * @param mask is used to filter observers defaults to -1
  63998. */
  63999. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  64000. /**
  64001. * Gets a boolean indicating if the observable has at least one observer
  64002. * @returns true is the Observable has at least one Observer registered
  64003. */
  64004. hasObservers(): boolean;
  64005. /**
  64006. * Clear the list of observers
  64007. */
  64008. clear(): void;
  64009. /**
  64010. * Clone the current observable
  64011. * @returns a new observable
  64012. */
  64013. clone(): Observable<T>;
  64014. /**
  64015. * Does this observable handles observer registered with a given mask
  64016. * @param mask defines the mask to be tested
  64017. * @return whether or not one observer registered with the given mask is handeled
  64018. **/
  64019. hasSpecificMask(mask?: number): boolean;
  64020. }
  64021. }
  64022. declare module BABYLON {
  64023. /**
  64024. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64025. * Babylon.js
  64026. */
  64027. export class DomManagement {
  64028. /**
  64029. * Checks if the window object exists
  64030. * @returns true if the window object exists
  64031. */
  64032. static IsWindowObjectExist(): boolean;
  64033. /**
  64034. * Extracts text content from a DOM element hierarchy
  64035. * @param element defines the root element
  64036. * @returns a string
  64037. */
  64038. static GetDOMTextContent(element: HTMLElement): string;
  64039. }
  64040. }
  64041. declare module BABYLON {
  64042. /**
  64043. * Logger used througouht the application to allow configuration of
  64044. * the log level required for the messages.
  64045. */
  64046. export class Logger {
  64047. /**
  64048. * No log
  64049. */
  64050. static readonly NoneLogLevel: number;
  64051. /**
  64052. * Only message logs
  64053. */
  64054. static readonly MessageLogLevel: number;
  64055. /**
  64056. * Only warning logs
  64057. */
  64058. static readonly WarningLogLevel: number;
  64059. /**
  64060. * Only error logs
  64061. */
  64062. static readonly ErrorLogLevel: number;
  64063. /**
  64064. * All logs
  64065. */
  64066. static readonly AllLogLevel: number;
  64067. private static _LogCache;
  64068. /**
  64069. * Gets a value indicating the number of loading errors
  64070. * @ignorenaming
  64071. */
  64072. static errorsCount: number;
  64073. /**
  64074. * Callback called when a new log is added
  64075. */
  64076. static OnNewCacheEntry: (entry: string) => void;
  64077. private static _AddLogEntry;
  64078. private static _FormatMessage;
  64079. private static _LogDisabled;
  64080. private static _LogEnabled;
  64081. private static _WarnDisabled;
  64082. private static _WarnEnabled;
  64083. private static _ErrorDisabled;
  64084. private static _ErrorEnabled;
  64085. /**
  64086. * Log a message to the console
  64087. */
  64088. static Log: (message: string) => void;
  64089. /**
  64090. * Write a warning message to the console
  64091. */
  64092. static Warn: (message: string) => void;
  64093. /**
  64094. * Write an error message to the console
  64095. */
  64096. static Error: (message: string) => void;
  64097. /**
  64098. * Gets current log cache (list of logs)
  64099. */
  64100. static readonly LogCache: string;
  64101. /**
  64102. * Clears the log cache
  64103. */
  64104. static ClearLogCache(): void;
  64105. /**
  64106. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64107. */
  64108. static LogLevels: number;
  64109. }
  64110. }
  64111. declare module BABYLON {
  64112. /** @hidden */
  64113. export class _TypeStore {
  64114. /** @hidden */
  64115. static RegisteredTypes: {
  64116. [key: string]: Object;
  64117. };
  64118. /** @hidden */
  64119. static GetClass(fqdn: string): any;
  64120. }
  64121. }
  64122. declare module BABYLON {
  64123. /**
  64124. * Class containing a set of static utilities functions for deep copy.
  64125. */
  64126. export class DeepCopier {
  64127. /**
  64128. * Tries to copy an object by duplicating every property
  64129. * @param source defines the source object
  64130. * @param destination defines the target object
  64131. * @param doNotCopyList defines a list of properties to avoid
  64132. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64133. */
  64134. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64135. }
  64136. }
  64137. declare module BABYLON {
  64138. /**
  64139. * Class containing a set of static utilities functions for precision date
  64140. */
  64141. export class PrecisionDate {
  64142. /**
  64143. * Gets either window.performance.now() if supported or Date.now() else
  64144. */
  64145. static readonly Now: number;
  64146. }
  64147. }
  64148. declare module BABYLON {
  64149. /** @hidden */
  64150. export class _DevTools {
  64151. static WarnImport(name: string): string;
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /**
  64156. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64157. */
  64158. export class WebRequest {
  64159. private _xhr;
  64160. /**
  64161. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64162. * i.e. when loading files, where the server/service expects an Authorization header
  64163. */
  64164. static CustomRequestHeaders: {
  64165. [key: string]: string;
  64166. };
  64167. /**
  64168. * Add callback functions in this array to update all the requests before they get sent to the network
  64169. */
  64170. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  64171. private _injectCustomRequestHeaders;
  64172. /**
  64173. * Gets or sets a function to be called when loading progress changes
  64174. */
  64175. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64176. /**
  64177. * Returns client's state
  64178. */
  64179. readonly readyState: number;
  64180. /**
  64181. * Returns client's status
  64182. */
  64183. readonly status: number;
  64184. /**
  64185. * Returns client's status as a text
  64186. */
  64187. readonly statusText: string;
  64188. /**
  64189. * Returns client's response
  64190. */
  64191. readonly response: any;
  64192. /**
  64193. * Returns client's response url
  64194. */
  64195. readonly responseURL: string;
  64196. /**
  64197. * Returns client's response as text
  64198. */
  64199. readonly responseText: string;
  64200. /**
  64201. * Gets or sets the expected response type
  64202. */
  64203. responseType: XMLHttpRequestResponseType;
  64204. /** @hidden */
  64205. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64206. /** @hidden */
  64207. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64208. /**
  64209. * Cancels any network activity
  64210. */
  64211. abort(): void;
  64212. /**
  64213. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64214. * @param body defines an optional request body
  64215. */
  64216. send(body?: Document | BodyInit | null): void;
  64217. /**
  64218. * Sets the request method, request URL
  64219. * @param method defines the method to use (GET, POST, etc..)
  64220. * @param url defines the url to connect with
  64221. */
  64222. open(method: string, url: string): void;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * File request interface
  64228. */
  64229. export interface IFileRequest {
  64230. /**
  64231. * Raised when the request is complete (success or error).
  64232. */
  64233. onCompleteObservable: Observable<IFileRequest>;
  64234. /**
  64235. * Aborts the request for a file.
  64236. */
  64237. abort: () => void;
  64238. }
  64239. }
  64240. declare module BABYLON {
  64241. /**
  64242. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64243. */
  64244. export class PerformanceMonitor {
  64245. private _enabled;
  64246. private _rollingFrameTime;
  64247. private _lastFrameTimeMs;
  64248. /**
  64249. * constructor
  64250. * @param frameSampleSize The number of samples required to saturate the sliding window
  64251. */
  64252. constructor(frameSampleSize?: number);
  64253. /**
  64254. * Samples current frame
  64255. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64256. */
  64257. sampleFrame(timeMs?: number): void;
  64258. /**
  64259. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64260. */
  64261. readonly averageFrameTime: number;
  64262. /**
  64263. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64264. */
  64265. readonly averageFrameTimeVariance: number;
  64266. /**
  64267. * Returns the frame time of the most recent frame
  64268. */
  64269. readonly instantaneousFrameTime: number;
  64270. /**
  64271. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64272. */
  64273. readonly averageFPS: number;
  64274. /**
  64275. * Returns the average framerate in frames per second using the most recent frame time
  64276. */
  64277. readonly instantaneousFPS: number;
  64278. /**
  64279. * Returns true if enough samples have been taken to completely fill the sliding window
  64280. */
  64281. readonly isSaturated: boolean;
  64282. /**
  64283. * Enables contributions to the sliding window sample set
  64284. */
  64285. enable(): void;
  64286. /**
  64287. * Disables contributions to the sliding window sample set
  64288. * Samples will not be interpolated over the disabled period
  64289. */
  64290. disable(): void;
  64291. /**
  64292. * Returns true if sampling is enabled
  64293. */
  64294. readonly isEnabled: boolean;
  64295. /**
  64296. * Resets performance monitor
  64297. */
  64298. reset(): void;
  64299. }
  64300. /**
  64301. * RollingAverage
  64302. *
  64303. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64304. */
  64305. export class RollingAverage {
  64306. /**
  64307. * Current average
  64308. */
  64309. average: number;
  64310. /**
  64311. * Current variance
  64312. */
  64313. variance: number;
  64314. protected _samples: Array<number>;
  64315. protected _sampleCount: number;
  64316. protected _pos: number;
  64317. protected _m2: number;
  64318. /**
  64319. * constructor
  64320. * @param length The number of samples required to saturate the sliding window
  64321. */
  64322. constructor(length: number);
  64323. /**
  64324. * Adds a sample to the sample set
  64325. * @param v The sample value
  64326. */
  64327. add(v: number): void;
  64328. /**
  64329. * Returns previously added values or null if outside of history or outside the sliding window domain
  64330. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64331. * @return Value previously recorded with add() or null if outside of range
  64332. */
  64333. history(i: number): number;
  64334. /**
  64335. * Returns true if enough samples have been taken to completely fill the sliding window
  64336. * @return true if sample-set saturated
  64337. */
  64338. isSaturated(): boolean;
  64339. /**
  64340. * Resets the rolling average (equivalent to 0 samples taken so far)
  64341. */
  64342. reset(): void;
  64343. /**
  64344. * Wraps a value around the sample range boundaries
  64345. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64346. * @return Wrapped position in sample range
  64347. */
  64348. protected _wrapPosition(i: number): number;
  64349. }
  64350. }
  64351. declare module BABYLON {
  64352. /**
  64353. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64354. * The underlying implementation relies on an associative array to ensure the best performances.
  64355. * The value can be anything including 'null' but except 'undefined'
  64356. */
  64357. export class StringDictionary<T> {
  64358. /**
  64359. * This will clear this dictionary and copy the content from the 'source' one.
  64360. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64361. * @param source the dictionary to take the content from and copy to this dictionary
  64362. */
  64363. copyFrom(source: StringDictionary<T>): void;
  64364. /**
  64365. * Get a value based from its key
  64366. * @param key the given key to get the matching value from
  64367. * @return the value if found, otherwise undefined is returned
  64368. */
  64369. get(key: string): T | undefined;
  64370. /**
  64371. * Get a value from its key or add it if it doesn't exist.
  64372. * This method will ensure you that a given key/data will be present in the dictionary.
  64373. * @param key the given key to get the matching value from
  64374. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64375. * The factory will only be invoked if there's no data for the given key.
  64376. * @return the value corresponding to the key.
  64377. */
  64378. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64379. /**
  64380. * Get a value from its key if present in the dictionary otherwise add it
  64381. * @param key the key to get the value from
  64382. * @param val if there's no such key/value pair in the dictionary add it with this value
  64383. * @return the value corresponding to the key
  64384. */
  64385. getOrAdd(key: string, val: T): T;
  64386. /**
  64387. * Check if there's a given key in the dictionary
  64388. * @param key the key to check for
  64389. * @return true if the key is present, false otherwise
  64390. */
  64391. contains(key: string): boolean;
  64392. /**
  64393. * Add a new key and its corresponding value
  64394. * @param key the key to add
  64395. * @param value the value corresponding to the key
  64396. * @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
  64397. */
  64398. add(key: string, value: T): boolean;
  64399. /**
  64400. * Update a specific value associated to a key
  64401. * @param key defines the key to use
  64402. * @param value defines the value to store
  64403. * @returns true if the value was updated (or false if the key was not found)
  64404. */
  64405. set(key: string, value: T): boolean;
  64406. /**
  64407. * Get the element of the given key and remove it from the dictionary
  64408. * @param key defines the key to search
  64409. * @returns the value associated with the key or null if not found
  64410. */
  64411. getAndRemove(key: string): Nullable<T>;
  64412. /**
  64413. * Remove a key/value from the dictionary.
  64414. * @param key the key to remove
  64415. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64416. */
  64417. remove(key: string): boolean;
  64418. /**
  64419. * Clear the whole content of the dictionary
  64420. */
  64421. clear(): void;
  64422. /**
  64423. * Gets the current count
  64424. */
  64425. readonly count: number;
  64426. /**
  64427. * Execute a callback on each key/val of the dictionary.
  64428. * Note that you can remove any element in this dictionary in the callback implementation
  64429. * @param callback the callback to execute on a given key/value pair
  64430. */
  64431. forEach(callback: (key: string, val: T) => void): void;
  64432. /**
  64433. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64434. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64435. * Note that you can remove any element in this dictionary in the callback implementation
  64436. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64437. * @returns the first item
  64438. */
  64439. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64440. private _count;
  64441. private _data;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /**
  64446. * Class used to store gfx data (like WebGLBuffer)
  64447. */
  64448. export class DataBuffer {
  64449. /**
  64450. * Gets or sets the number of objects referencing this buffer
  64451. */
  64452. references: number;
  64453. /** Gets or sets the size of the underlying buffer */
  64454. capacity: number;
  64455. /**
  64456. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  64457. */
  64458. is32Bits: boolean;
  64459. /**
  64460. * Gets the underlying buffer
  64461. */
  64462. readonly underlyingResource: any;
  64463. }
  64464. }
  64465. declare module BABYLON {
  64466. /**
  64467. * Class used to store data that will be store in GPU memory
  64468. */
  64469. export class Buffer {
  64470. private _engine;
  64471. private _buffer;
  64472. /** @hidden */
  64473. _data: Nullable<DataArray>;
  64474. private _updatable;
  64475. private _instanced;
  64476. /**
  64477. * Gets the byte stride.
  64478. */
  64479. readonly byteStride: number;
  64480. /**
  64481. * Constructor
  64482. * @param engine the engine
  64483. * @param data the data to use for this buffer
  64484. * @param updatable whether the data is updatable
  64485. * @param stride the stride (optional)
  64486. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64487. * @param instanced whether the buffer is instanced (optional)
  64488. * @param useBytes set to true if the stride in in bytes (optional)
  64489. */
  64490. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64491. /**
  64492. * Create a new VertexBuffer based on the current buffer
  64493. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64494. * @param offset defines offset in the buffer (0 by default)
  64495. * @param size defines the size in floats of attributes (position is 3 for instance)
  64496. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64497. * @param instanced defines if the vertex buffer contains indexed data
  64498. * @param useBytes defines if the offset and stride are in bytes
  64499. * @returns the new vertex buffer
  64500. */
  64501. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64502. /**
  64503. * Gets a boolean indicating if the Buffer is updatable?
  64504. * @returns true if the buffer is updatable
  64505. */
  64506. isUpdatable(): boolean;
  64507. /**
  64508. * Gets current buffer's data
  64509. * @returns a DataArray or null
  64510. */
  64511. getData(): Nullable<DataArray>;
  64512. /**
  64513. * Gets underlying native buffer
  64514. * @returns underlying native buffer
  64515. */
  64516. getBuffer(): Nullable<DataBuffer>;
  64517. /**
  64518. * Gets the stride in float32 units (i.e. byte stride / 4).
  64519. * May not be an integer if the byte stride is not divisible by 4.
  64520. * DEPRECATED. Use byteStride instead.
  64521. * @returns the stride in float32 units
  64522. */
  64523. getStrideSize(): number;
  64524. /**
  64525. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64526. * @param data defines the data to store
  64527. */
  64528. create(data?: Nullable<DataArray>): void;
  64529. /** @hidden */
  64530. _rebuild(): void;
  64531. /**
  64532. * Update current buffer data
  64533. * @param data defines the data to store
  64534. */
  64535. update(data: DataArray): void;
  64536. /**
  64537. * Updates the data directly.
  64538. * @param data the new data
  64539. * @param offset the new offset
  64540. * @param vertexCount the vertex count (optional)
  64541. * @param useBytes set to true if the offset is in bytes
  64542. */
  64543. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64544. /**
  64545. * Release all resources
  64546. */
  64547. dispose(): void;
  64548. }
  64549. /**
  64550. * Specialized buffer used to store vertex data
  64551. */
  64552. export class VertexBuffer {
  64553. /** @hidden */
  64554. _buffer: Buffer;
  64555. private _kind;
  64556. private _size;
  64557. private _ownsBuffer;
  64558. private _instanced;
  64559. private _instanceDivisor;
  64560. /**
  64561. * The byte type.
  64562. */
  64563. static readonly BYTE: number;
  64564. /**
  64565. * The unsigned byte type.
  64566. */
  64567. static readonly UNSIGNED_BYTE: number;
  64568. /**
  64569. * The short type.
  64570. */
  64571. static readonly SHORT: number;
  64572. /**
  64573. * The unsigned short type.
  64574. */
  64575. static readonly UNSIGNED_SHORT: number;
  64576. /**
  64577. * The integer type.
  64578. */
  64579. static readonly INT: number;
  64580. /**
  64581. * The unsigned integer type.
  64582. */
  64583. static readonly UNSIGNED_INT: number;
  64584. /**
  64585. * The float type.
  64586. */
  64587. static readonly FLOAT: number;
  64588. /**
  64589. * Gets or sets the instance divisor when in instanced mode
  64590. */
  64591. instanceDivisor: number;
  64592. /**
  64593. * Gets the byte stride.
  64594. */
  64595. readonly byteStride: number;
  64596. /**
  64597. * Gets the byte offset.
  64598. */
  64599. readonly byteOffset: number;
  64600. /**
  64601. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  64602. */
  64603. readonly normalized: boolean;
  64604. /**
  64605. * Gets the data type of each component in the array.
  64606. */
  64607. readonly type: number;
  64608. /**
  64609. * Constructor
  64610. * @param engine the engine
  64611. * @param data the data to use for this vertex buffer
  64612. * @param kind the vertex buffer kind
  64613. * @param updatable whether the data is updatable
  64614. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64615. * @param stride the stride (optional)
  64616. * @param instanced whether the buffer is instanced (optional)
  64617. * @param offset the offset of the data (optional)
  64618. * @param size the number of components (optional)
  64619. * @param type the type of the component (optional)
  64620. * @param normalized whether the data contains normalized data (optional)
  64621. * @param useBytes set to true if stride and offset are in bytes (optional)
  64622. */
  64623. 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);
  64624. /** @hidden */
  64625. _rebuild(): void;
  64626. /**
  64627. * Returns the kind of the VertexBuffer (string)
  64628. * @returns a string
  64629. */
  64630. getKind(): string;
  64631. /**
  64632. * Gets a boolean indicating if the VertexBuffer is updatable?
  64633. * @returns true if the buffer is updatable
  64634. */
  64635. isUpdatable(): boolean;
  64636. /**
  64637. * Gets current buffer's data
  64638. * @returns a DataArray or null
  64639. */
  64640. getData(): Nullable<DataArray>;
  64641. /**
  64642. * Gets underlying native buffer
  64643. * @returns underlying native buffer
  64644. */
  64645. getBuffer(): Nullable<DataBuffer>;
  64646. /**
  64647. * Gets the stride in float32 units (i.e. byte stride / 4).
  64648. * May not be an integer if the byte stride is not divisible by 4.
  64649. * DEPRECATED. Use byteStride instead.
  64650. * @returns the stride in float32 units
  64651. */
  64652. getStrideSize(): number;
  64653. /**
  64654. * Returns the offset as a multiple of the type byte length.
  64655. * DEPRECATED. Use byteOffset instead.
  64656. * @returns the offset in bytes
  64657. */
  64658. getOffset(): number;
  64659. /**
  64660. * Returns the number of components per vertex attribute (integer)
  64661. * @returns the size in float
  64662. */
  64663. getSize(): number;
  64664. /**
  64665. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  64666. * @returns true if this buffer is instanced
  64667. */
  64668. getIsInstanced(): boolean;
  64669. /**
  64670. * Returns the instancing divisor, zero for non-instanced (integer).
  64671. * @returns a number
  64672. */
  64673. getInstanceDivisor(): number;
  64674. /**
  64675. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64676. * @param data defines the data to store
  64677. */
  64678. create(data?: DataArray): void;
  64679. /**
  64680. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  64681. * This function will create a new buffer if the current one is not updatable
  64682. * @param data defines the data to store
  64683. */
  64684. update(data: DataArray): void;
  64685. /**
  64686. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  64687. * Returns the directly updated WebGLBuffer.
  64688. * @param data the new data
  64689. * @param offset the new offset
  64690. * @param useBytes set to true if the offset is in bytes
  64691. */
  64692. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  64693. /**
  64694. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  64695. */
  64696. dispose(): void;
  64697. /**
  64698. * Enumerates each value of this vertex buffer as numbers.
  64699. * @param count the number of values to enumerate
  64700. * @param callback the callback function called for each value
  64701. */
  64702. forEach(count: number, callback: (value: number, index: number) => void): void;
  64703. /**
  64704. * Positions
  64705. */
  64706. static readonly PositionKind: string;
  64707. /**
  64708. * Normals
  64709. */
  64710. static readonly NormalKind: string;
  64711. /**
  64712. * Tangents
  64713. */
  64714. static readonly TangentKind: string;
  64715. /**
  64716. * Texture coordinates
  64717. */
  64718. static readonly UVKind: string;
  64719. /**
  64720. * Texture coordinates 2
  64721. */
  64722. static readonly UV2Kind: string;
  64723. /**
  64724. * Texture coordinates 3
  64725. */
  64726. static readonly UV3Kind: string;
  64727. /**
  64728. * Texture coordinates 4
  64729. */
  64730. static readonly UV4Kind: string;
  64731. /**
  64732. * Texture coordinates 5
  64733. */
  64734. static readonly UV5Kind: string;
  64735. /**
  64736. * Texture coordinates 6
  64737. */
  64738. static readonly UV6Kind: string;
  64739. /**
  64740. * Colors
  64741. */
  64742. static readonly ColorKind: string;
  64743. /**
  64744. * Matrix indices (for bones)
  64745. */
  64746. static readonly MatricesIndicesKind: string;
  64747. /**
  64748. * Matrix weights (for bones)
  64749. */
  64750. static readonly MatricesWeightsKind: string;
  64751. /**
  64752. * Additional matrix indices (for bones)
  64753. */
  64754. static readonly MatricesIndicesExtraKind: string;
  64755. /**
  64756. * Additional matrix weights (for bones)
  64757. */
  64758. static readonly MatricesWeightsExtraKind: string;
  64759. /**
  64760. * Deduces the stride given a kind.
  64761. * @param kind The kind string to deduce
  64762. * @returns The deduced stride
  64763. */
  64764. static DeduceStride(kind: string): number;
  64765. /**
  64766. * Gets the byte length of the given type.
  64767. * @param type the type
  64768. * @returns the number of bytes
  64769. */
  64770. static GetTypeByteLength(type: number): number;
  64771. /**
  64772. * Enumerates each value of the given parameters as numbers.
  64773. * @param data the data to enumerate
  64774. * @param byteOffset the byte offset of the data
  64775. * @param byteStride the byte stride of the data
  64776. * @param componentCount the number of components per element
  64777. * @param componentType the type of the component
  64778. * @param count the number of values to enumerate
  64779. * @param normalized whether the data is normalized
  64780. * @param callback the callback function called for each value
  64781. */
  64782. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  64783. private static _GetFloatValue;
  64784. }
  64785. }
  64786. declare module BABYLON {
  64787. /**
  64788. * Scalar computation library
  64789. */
  64790. export class Scalar {
  64791. /**
  64792. * Two pi constants convenient for computation.
  64793. */
  64794. static TwoPi: number;
  64795. /**
  64796. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64797. * @param a number
  64798. * @param b number
  64799. * @param epsilon (default = 1.401298E-45)
  64800. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  64801. */
  64802. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  64803. /**
  64804. * Returns a string : the upper case translation of the number i to hexadecimal.
  64805. * @param i number
  64806. * @returns the upper case translation of the number i to hexadecimal.
  64807. */
  64808. static ToHex(i: number): string;
  64809. /**
  64810. * Returns -1 if value is negative and +1 is value is positive.
  64811. * @param value the value
  64812. * @returns the value itself if it's equal to zero.
  64813. */
  64814. static Sign(value: number): number;
  64815. /**
  64816. * Returns the value itself if it's between min and max.
  64817. * Returns min if the value is lower than min.
  64818. * Returns max if the value is greater than max.
  64819. * @param value the value to clmap
  64820. * @param min the min value to clamp to (default: 0)
  64821. * @param max the max value to clamp to (default: 1)
  64822. * @returns the clamped value
  64823. */
  64824. static Clamp(value: number, min?: number, max?: number): number;
  64825. /**
  64826. * the log2 of value.
  64827. * @param value the value to compute log2 of
  64828. * @returns the log2 of value.
  64829. */
  64830. static Log2(value: number): number;
  64831. /**
  64832. * Loops the value, so that it is never larger than length and never smaller than 0.
  64833. *
  64834. * This is similar to the modulo operator but it works with floating point numbers.
  64835. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  64836. * With t = 5 and length = 2.5, the result would be 0.0.
  64837. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  64838. * @param value the value
  64839. * @param length the length
  64840. * @returns the looped value
  64841. */
  64842. static Repeat(value: number, length: number): number;
  64843. /**
  64844. * Normalize the value between 0.0 and 1.0 using min and max values
  64845. * @param value value to normalize
  64846. * @param min max to normalize between
  64847. * @param max min to normalize between
  64848. * @returns the normalized value
  64849. */
  64850. static Normalize(value: number, min: number, max: number): number;
  64851. /**
  64852. * Denormalize the value from 0.0 and 1.0 using min and max values
  64853. * @param normalized value to denormalize
  64854. * @param min max to denormalize between
  64855. * @param max min to denormalize between
  64856. * @returns the denormalized value
  64857. */
  64858. static Denormalize(normalized: number, min: number, max: number): number;
  64859. /**
  64860. * Calculates the shortest difference between two given angles given in degrees.
  64861. * @param current current angle in degrees
  64862. * @param target target angle in degrees
  64863. * @returns the delta
  64864. */
  64865. static DeltaAngle(current: number, target: number): number;
  64866. /**
  64867. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  64868. * @param tx value
  64869. * @param length length
  64870. * @returns The returned value will move back and forth between 0 and length
  64871. */
  64872. static PingPong(tx: number, length: number): number;
  64873. /**
  64874. * Interpolates between min and max with smoothing at the limits.
  64875. *
  64876. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  64877. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  64878. * @param from from
  64879. * @param to to
  64880. * @param tx value
  64881. * @returns the smooth stepped value
  64882. */
  64883. static SmoothStep(from: number, to: number, tx: number): number;
  64884. /**
  64885. * Moves a value current towards target.
  64886. *
  64887. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  64888. * Negative values of maxDelta pushes the value away from target.
  64889. * @param current current value
  64890. * @param target target value
  64891. * @param maxDelta max distance to move
  64892. * @returns resulting value
  64893. */
  64894. static MoveTowards(current: number, target: number, maxDelta: number): number;
  64895. /**
  64896. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64897. *
  64898. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  64899. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  64900. * @param current current value
  64901. * @param target target value
  64902. * @param maxDelta max distance to move
  64903. * @returns resulting angle
  64904. */
  64905. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  64906. /**
  64907. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  64908. * @param start start value
  64909. * @param end target value
  64910. * @param amount amount to lerp between
  64911. * @returns the lerped value
  64912. */
  64913. static Lerp(start: number, end: number, amount: number): number;
  64914. /**
  64915. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  64916. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  64917. * @param start start value
  64918. * @param end target value
  64919. * @param amount amount to lerp between
  64920. * @returns the lerped value
  64921. */
  64922. static LerpAngle(start: number, end: number, amount: number): number;
  64923. /**
  64924. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  64925. * @param a start value
  64926. * @param b target value
  64927. * @param value value between a and b
  64928. * @returns the inverseLerp value
  64929. */
  64930. static InverseLerp(a: number, b: number, value: number): number;
  64931. /**
  64932. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  64933. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  64934. * @param value1 spline value
  64935. * @param tangent1 spline value
  64936. * @param value2 spline value
  64937. * @param tangent2 spline value
  64938. * @param amount input value
  64939. * @returns hermite result
  64940. */
  64941. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  64942. /**
  64943. * Returns a random float number between and min and max values
  64944. * @param min min value of random
  64945. * @param max max value of random
  64946. * @returns random value
  64947. */
  64948. static RandomRange(min: number, max: number): number;
  64949. /**
  64950. * This function returns percentage of a number in a given range.
  64951. *
  64952. * RangeToPercent(40,20,60) will return 0.5 (50%)
  64953. * RangeToPercent(34,0,100) will return 0.34 (34%)
  64954. * @param number to convert to percentage
  64955. * @param min min range
  64956. * @param max max range
  64957. * @returns the percentage
  64958. */
  64959. static RangeToPercent(number: number, min: number, max: number): number;
  64960. /**
  64961. * This function returns number that corresponds to the percentage in a given range.
  64962. *
  64963. * PercentToRange(0.34,0,100) will return 34.
  64964. * @param percent to convert to number
  64965. * @param min min range
  64966. * @param max max range
  64967. * @returns the number
  64968. */
  64969. static PercentToRange(percent: number, min: number, max: number): number;
  64970. /**
  64971. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  64972. * @param angle The angle to normalize in radian.
  64973. * @return The converted angle.
  64974. */
  64975. static NormalizeRadians(angle: number): number;
  64976. }
  64977. }
  64978. declare module BABYLON {
  64979. /**
  64980. * Constant used to convert a value to gamma space
  64981. * @ignorenaming
  64982. */
  64983. export const ToGammaSpace: number;
  64984. /**
  64985. * Constant used to convert a value to linear space
  64986. * @ignorenaming
  64987. */
  64988. export const ToLinearSpace = 2.2;
  64989. /**
  64990. * Constant used to define the minimal number value in Babylon.js
  64991. * @ignorenaming
  64992. */
  64993. let Epsilon: number;
  64994. }
  64995. declare module BABYLON {
  64996. /**
  64997. * Class used to represent a viewport on screen
  64998. */
  64999. export class Viewport {
  65000. /** viewport left coordinate */
  65001. x: number;
  65002. /** viewport top coordinate */
  65003. y: number;
  65004. /**viewport width */
  65005. width: number;
  65006. /** viewport height */
  65007. height: number;
  65008. /**
  65009. * Creates a Viewport object located at (x, y) and sized (width, height)
  65010. * @param x defines viewport left coordinate
  65011. * @param y defines viewport top coordinate
  65012. * @param width defines the viewport width
  65013. * @param height defines the viewport height
  65014. */
  65015. constructor(
  65016. /** viewport left coordinate */
  65017. x: number,
  65018. /** viewport top coordinate */
  65019. y: number,
  65020. /**viewport width */
  65021. width: number,
  65022. /** viewport height */
  65023. height: number);
  65024. /**
  65025. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65026. * @param renderWidth defines the rendering width
  65027. * @param renderHeight defines the rendering height
  65028. * @returns a new Viewport
  65029. */
  65030. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65031. /**
  65032. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65033. * @param renderWidth defines the rendering width
  65034. * @param renderHeight defines the rendering height
  65035. * @param ref defines the target viewport
  65036. * @returns the current viewport
  65037. */
  65038. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65039. /**
  65040. * Returns a new Viewport copied from the current one
  65041. * @returns a new Viewport
  65042. */
  65043. clone(): Viewport;
  65044. }
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * Class containing a set of static utilities functions for arrays.
  65049. */
  65050. export class ArrayTools {
  65051. /**
  65052. * Returns an array of the given size filled with element built from the given constructor and the paramters
  65053. * @param size the number of element to construct and put in the array
  65054. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  65055. * @returns a new array filled with new objects
  65056. */
  65057. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  65058. }
  65059. }
  65060. declare module BABYLON {
  65061. /**
  65062. * @hidden
  65063. */
  65064. export interface IColor4Like {
  65065. r: float;
  65066. g: float;
  65067. b: float;
  65068. a: float;
  65069. }
  65070. /**
  65071. * @hidden
  65072. */
  65073. export interface IColor3Like {
  65074. r: float;
  65075. g: float;
  65076. b: float;
  65077. }
  65078. /**
  65079. * @hidden
  65080. */
  65081. export interface IVector4Like {
  65082. x: float;
  65083. y: float;
  65084. z: float;
  65085. w: float;
  65086. }
  65087. /**
  65088. * @hidden
  65089. */
  65090. export interface IVector3Like {
  65091. x: float;
  65092. y: float;
  65093. z: float;
  65094. }
  65095. /**
  65096. * @hidden
  65097. */
  65098. export interface IVector2Like {
  65099. x: float;
  65100. y: float;
  65101. }
  65102. /**
  65103. * @hidden
  65104. */
  65105. export interface IMatrixLike {
  65106. toArray(): DeepImmutable<Float32Array>;
  65107. updateFlag: int;
  65108. }
  65109. /**
  65110. * @hidden
  65111. */
  65112. export interface IViewportLike {
  65113. x: float;
  65114. y: float;
  65115. width: float;
  65116. height: float;
  65117. }
  65118. /**
  65119. * @hidden
  65120. */
  65121. export interface IPlaneLike {
  65122. normal: IVector3Like;
  65123. d: float;
  65124. normalize(): void;
  65125. }
  65126. }
  65127. declare module BABYLON {
  65128. /**
  65129. * Class representing a vector containing 2 coordinates
  65130. */
  65131. export class Vector2 {
  65132. /** defines the first coordinate */
  65133. x: number;
  65134. /** defines the second coordinate */
  65135. y: number;
  65136. /**
  65137. * Creates a new Vector2 from the given x and y coordinates
  65138. * @param x defines the first coordinate
  65139. * @param y defines the second coordinate
  65140. */
  65141. constructor(
  65142. /** defines the first coordinate */
  65143. x?: number,
  65144. /** defines the second coordinate */
  65145. y?: number);
  65146. /**
  65147. * Gets a string with the Vector2 coordinates
  65148. * @returns a string with the Vector2 coordinates
  65149. */
  65150. toString(): string;
  65151. /**
  65152. * Gets class name
  65153. * @returns the string "Vector2"
  65154. */
  65155. getClassName(): string;
  65156. /**
  65157. * Gets current vector hash code
  65158. * @returns the Vector2 hash code as a number
  65159. */
  65160. getHashCode(): number;
  65161. /**
  65162. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  65163. * @param array defines the source array
  65164. * @param index defines the offset in source array
  65165. * @returns the current Vector2
  65166. */
  65167. toArray(array: FloatArray, index?: number): Vector2;
  65168. /**
  65169. * Copy the current vector to an array
  65170. * @returns a new array with 2 elements: the Vector2 coordinates.
  65171. */
  65172. asArray(): number[];
  65173. /**
  65174. * Sets the Vector2 coordinates with the given Vector2 coordinates
  65175. * @param source defines the source Vector2
  65176. * @returns the current updated Vector2
  65177. */
  65178. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  65179. /**
  65180. * Sets the Vector2 coordinates with the given floats
  65181. * @param x defines the first coordinate
  65182. * @param y defines the second coordinate
  65183. * @returns the current updated Vector2
  65184. */
  65185. copyFromFloats(x: number, y: number): Vector2;
  65186. /**
  65187. * Sets the Vector2 coordinates with the given floats
  65188. * @param x defines the first coordinate
  65189. * @param y defines the second coordinate
  65190. * @returns the current updated Vector2
  65191. */
  65192. set(x: number, y: number): Vector2;
  65193. /**
  65194. * Add another vector with the current one
  65195. * @param otherVector defines the other vector
  65196. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  65197. */
  65198. add(otherVector: DeepImmutable<Vector2>): Vector2;
  65199. /**
  65200. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  65201. * @param otherVector defines the other vector
  65202. * @param result defines the target vector
  65203. * @returns the unmodified current Vector2
  65204. */
  65205. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65206. /**
  65207. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  65208. * @param otherVector defines the other vector
  65209. * @returns the current updated Vector2
  65210. */
  65211. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65212. /**
  65213. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  65214. * @param otherVector defines the other vector
  65215. * @returns a new Vector2
  65216. */
  65217. addVector3(otherVector: Vector3): Vector2;
  65218. /**
  65219. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  65220. * @param otherVector defines the other vector
  65221. * @returns a new Vector2
  65222. */
  65223. subtract(otherVector: Vector2): Vector2;
  65224. /**
  65225. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  65226. * @param otherVector defines the other vector
  65227. * @param result defines the target vector
  65228. * @returns the unmodified current Vector2
  65229. */
  65230. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65231. /**
  65232. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  65233. * @param otherVector defines the other vector
  65234. * @returns the current updated Vector2
  65235. */
  65236. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65237. /**
  65238. * Multiplies in place the current Vector2 coordinates by the given ones
  65239. * @param otherVector defines the other vector
  65240. * @returns the current updated Vector2
  65241. */
  65242. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65243. /**
  65244. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  65245. * @param otherVector defines the other vector
  65246. * @returns a new Vector2
  65247. */
  65248. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  65249. /**
  65250. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  65251. * @param otherVector defines the other vector
  65252. * @param result defines the target vector
  65253. * @returns the unmodified current Vector2
  65254. */
  65255. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65256. /**
  65257. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  65258. * @param x defines the first coordinate
  65259. * @param y defines the second coordinate
  65260. * @returns a new Vector2
  65261. */
  65262. multiplyByFloats(x: number, y: number): Vector2;
  65263. /**
  65264. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  65265. * @param otherVector defines the other vector
  65266. * @returns a new Vector2
  65267. */
  65268. divide(otherVector: Vector2): Vector2;
  65269. /**
  65270. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  65271. * @param otherVector defines the other vector
  65272. * @param result defines the target vector
  65273. * @returns the unmodified current Vector2
  65274. */
  65275. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  65276. /**
  65277. * Divides the current Vector2 coordinates by the given ones
  65278. * @param otherVector defines the other vector
  65279. * @returns the current updated Vector2
  65280. */
  65281. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  65282. /**
  65283. * Gets a new Vector2 with current Vector2 negated coordinates
  65284. * @returns a new Vector2
  65285. */
  65286. negate(): Vector2;
  65287. /**
  65288. * Multiply the Vector2 coordinates by scale
  65289. * @param scale defines the scaling factor
  65290. * @returns the current updated Vector2
  65291. */
  65292. scaleInPlace(scale: number): Vector2;
  65293. /**
  65294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  65295. * @param scale defines the scaling factor
  65296. * @returns a new Vector2
  65297. */
  65298. scale(scale: number): Vector2;
  65299. /**
  65300. * Scale the current Vector2 values by a factor to a given Vector2
  65301. * @param scale defines the scale factor
  65302. * @param result defines the Vector2 object where to store the result
  65303. * @returns the unmodified current Vector2
  65304. */
  65305. scaleToRef(scale: number, result: Vector2): Vector2;
  65306. /**
  65307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  65308. * @param scale defines the scale factor
  65309. * @param result defines the Vector2 object where to store the result
  65310. * @returns the unmodified current Vector2
  65311. */
  65312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  65313. /**
  65314. * Gets a boolean if two vectors are equals
  65315. * @param otherVector defines the other vector
  65316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  65317. */
  65318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  65319. /**
  65320. * Gets a boolean if two vectors are equals (using an epsilon value)
  65321. * @param otherVector defines the other vector
  65322. * @param epsilon defines the minimal distance to consider equality
  65323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  65324. */
  65325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  65326. /**
  65327. * Gets a new Vector2 from current Vector2 floored values
  65328. * @returns a new Vector2
  65329. */
  65330. floor(): Vector2;
  65331. /**
  65332. * Gets a new Vector2 from current Vector2 floored values
  65333. * @returns a new Vector2
  65334. */
  65335. fract(): Vector2;
  65336. /**
  65337. * Gets the length of the vector
  65338. * @returns the vector length (float)
  65339. */
  65340. length(): number;
  65341. /**
  65342. * Gets the vector squared length
  65343. * @returns the vector squared length (float)
  65344. */
  65345. lengthSquared(): number;
  65346. /**
  65347. * Normalize the vector
  65348. * @returns the current updated Vector2
  65349. */
  65350. normalize(): Vector2;
  65351. /**
  65352. * Gets a new Vector2 copied from the Vector2
  65353. * @returns a new Vector2
  65354. */
  65355. clone(): Vector2;
  65356. /**
  65357. * Gets a new Vector2(0, 0)
  65358. * @returns a new Vector2
  65359. */
  65360. static Zero(): Vector2;
  65361. /**
  65362. * Gets a new Vector2(1, 1)
  65363. * @returns a new Vector2
  65364. */
  65365. static One(): Vector2;
  65366. /**
  65367. * Gets a new Vector2 set from the given index element of the given array
  65368. * @param array defines the data source
  65369. * @param offset defines the offset in the data source
  65370. * @returns a new Vector2
  65371. */
  65372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  65373. /**
  65374. * Sets "result" from the given index element of the given array
  65375. * @param array defines the data source
  65376. * @param offset defines the offset in the data source
  65377. * @param result defines the target vector
  65378. */
  65379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  65380. /**
  65381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  65382. * @param value1 defines 1st point of control
  65383. * @param value2 defines 2nd point of control
  65384. * @param value3 defines 3rd point of control
  65385. * @param value4 defines 4th point of control
  65386. * @param amount defines the interpolation factor
  65387. * @returns a new Vector2
  65388. */
  65389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  65390. /**
  65391. * 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".
  65392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  65393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  65394. * @param value defines the value to clamp
  65395. * @param min defines the lower limit
  65396. * @param max defines the upper limit
  65397. * @returns a new Vector2
  65398. */
  65399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  65400. /**
  65401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  65402. * @param value1 defines the 1st control point
  65403. * @param tangent1 defines the outgoing tangent
  65404. * @param value2 defines the 2nd control point
  65405. * @param tangent2 defines the incoming tangent
  65406. * @param amount defines the interpolation factor
  65407. * @returns a new Vector2
  65408. */
  65409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  65410. /**
  65411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  65412. * @param start defines the start vector
  65413. * @param end defines the end vector
  65414. * @param amount defines the interpolation factor
  65415. * @returns a new Vector2
  65416. */
  65417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  65418. /**
  65419. * Gets the dot product of the vector "left" and the vector "right"
  65420. * @param left defines first vector
  65421. * @param right defines second vector
  65422. * @returns the dot product (float)
  65423. */
  65424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  65425. /**
  65426. * Returns a new Vector2 equal to the normalized given vector
  65427. * @param vector defines the vector to normalize
  65428. * @returns a new Vector2
  65429. */
  65430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  65431. /**
  65432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  65433. * @param left defines 1st vector
  65434. * @param right defines 2nd vector
  65435. * @returns a new Vector2
  65436. */
  65437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65438. /**
  65439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  65440. * @param left defines 1st vector
  65441. * @param right defines 2nd vector
  65442. * @returns a new Vector2
  65443. */
  65444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  65445. /**
  65446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  65447. * @param vector defines the vector to transform
  65448. * @param transformation defines the matrix to apply
  65449. * @returns a new Vector2
  65450. */
  65451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  65452. /**
  65453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  65454. * @param vector defines the vector to transform
  65455. * @param transformation defines the matrix to apply
  65456. * @param result defines the target vector
  65457. */
  65458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  65459. /**
  65460. * Determines if a given vector is included in a triangle
  65461. * @param p defines the vector to test
  65462. * @param p0 defines 1st triangle point
  65463. * @param p1 defines 2nd triangle point
  65464. * @param p2 defines 3rd triangle point
  65465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  65466. */
  65467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  65468. /**
  65469. * Gets the distance between the vectors "value1" and "value2"
  65470. * @param value1 defines first vector
  65471. * @param value2 defines second vector
  65472. * @returns the distance between vectors
  65473. */
  65474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65475. /**
  65476. * Returns the squared distance between the vectors "value1" and "value2"
  65477. * @param value1 defines first vector
  65478. * @param value2 defines second vector
  65479. * @returns the squared distance between vectors
  65480. */
  65481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  65482. /**
  65483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  65484. * @param value1 defines first vector
  65485. * @param value2 defines second vector
  65486. * @returns a new Vector2
  65487. */
  65488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  65489. /**
  65490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  65491. * @param p defines the middle point
  65492. * @param segA defines one point of the segment
  65493. * @param segB defines the other point of the segment
  65494. * @returns the shortest distance
  65495. */
  65496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  65497. }
  65498. /**
  65499. * Classed used to store (x,y,z) vector representation
  65500. * A Vector3 is the main object used in 3D geometry
  65501. * It can represent etiher the coordinates of a point the space, either a direction
  65502. * Reminder: js uses a left handed forward facing system
  65503. */
  65504. export class Vector3 {
  65505. /**
  65506. * Defines the first coordinates (on X axis)
  65507. */
  65508. x: number;
  65509. /**
  65510. * Defines the second coordinates (on Y axis)
  65511. */
  65512. y: number;
  65513. /**
  65514. * Defines the third coordinates (on Z axis)
  65515. */
  65516. z: number;
  65517. private static _UpReadOnly;
  65518. private static _ZeroReadOnly;
  65519. /**
  65520. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  65521. * @param x defines the first coordinates (on X axis)
  65522. * @param y defines the second coordinates (on Y axis)
  65523. * @param z defines the third coordinates (on Z axis)
  65524. */
  65525. constructor(
  65526. /**
  65527. * Defines the first coordinates (on X axis)
  65528. */
  65529. x?: number,
  65530. /**
  65531. * Defines the second coordinates (on Y axis)
  65532. */
  65533. y?: number,
  65534. /**
  65535. * Defines the third coordinates (on Z axis)
  65536. */
  65537. z?: number);
  65538. /**
  65539. * Creates a string representation of the Vector3
  65540. * @returns a string with the Vector3 coordinates.
  65541. */
  65542. toString(): string;
  65543. /**
  65544. * Gets the class name
  65545. * @returns the string "Vector3"
  65546. */
  65547. getClassName(): string;
  65548. /**
  65549. * Creates the Vector3 hash code
  65550. * @returns a number which tends to be unique between Vector3 instances
  65551. */
  65552. getHashCode(): number;
  65553. /**
  65554. * Creates an array containing three elements : the coordinates of the Vector3
  65555. * @returns a new array of numbers
  65556. */
  65557. asArray(): number[];
  65558. /**
  65559. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  65560. * @param array defines the destination array
  65561. * @param index defines the offset in the destination array
  65562. * @returns the current Vector3
  65563. */
  65564. toArray(array: FloatArray, index?: number): Vector3;
  65565. /**
  65566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  65567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  65568. */
  65569. toQuaternion(): Quaternion;
  65570. /**
  65571. * Adds the given vector to the current Vector3
  65572. * @param otherVector defines the second operand
  65573. * @returns the current updated Vector3
  65574. */
  65575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65576. /**
  65577. * Adds the given coordinates to the current Vector3
  65578. * @param x defines the x coordinate of the operand
  65579. * @param y defines the y coordinate of the operand
  65580. * @param z defines the z coordinate of the operand
  65581. * @returns the current updated Vector3
  65582. */
  65583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65584. /**
  65585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  65586. * @param otherVector defines the second operand
  65587. * @returns the resulting Vector3
  65588. */
  65589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  65590. /**
  65591. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  65592. * @param otherVector defines the second operand
  65593. * @param result defines the Vector3 object where to store the result
  65594. * @returns the current Vector3
  65595. */
  65596. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65597. /**
  65598. * Subtract the given vector from the current Vector3
  65599. * @param otherVector defines the second operand
  65600. * @returns the current updated Vector3
  65601. */
  65602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65603. /**
  65604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  65605. * @param otherVector defines the second operand
  65606. * @returns the resulting Vector3
  65607. */
  65608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  65609. /**
  65610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  65611. * @param otherVector defines the second operand
  65612. * @param result defines the Vector3 object where to store the result
  65613. * @returns the current Vector3
  65614. */
  65615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65616. /**
  65617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  65618. * @param x defines the x coordinate of the operand
  65619. * @param y defines the y coordinate of the operand
  65620. * @param z defines the z coordinate of the operand
  65621. * @returns the resulting Vector3
  65622. */
  65623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  65624. /**
  65625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  65626. * @param x defines the x coordinate of the operand
  65627. * @param y defines the y coordinate of the operand
  65628. * @param z defines the z coordinate of the operand
  65629. * @param result defines the Vector3 object where to store the result
  65630. * @returns the current Vector3
  65631. */
  65632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  65633. /**
  65634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  65635. * @returns a new Vector3
  65636. */
  65637. negate(): Vector3;
  65638. /**
  65639. * Multiplies the Vector3 coordinates by the float "scale"
  65640. * @param scale defines the multiplier factor
  65641. * @returns the current updated Vector3
  65642. */
  65643. scaleInPlace(scale: number): Vector3;
  65644. /**
  65645. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  65646. * @param scale defines the multiplier factor
  65647. * @returns a new Vector3
  65648. */
  65649. scale(scale: number): Vector3;
  65650. /**
  65651. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  65652. * @param scale defines the multiplier factor
  65653. * @param result defines the Vector3 object where to store the result
  65654. * @returns the current Vector3
  65655. */
  65656. scaleToRef(scale: number, result: Vector3): Vector3;
  65657. /**
  65658. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  65659. * @param scale defines the scale factor
  65660. * @param result defines the Vector3 object where to store the result
  65661. * @returns the unmodified current Vector3
  65662. */
  65663. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  65664. /**
  65665. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  65666. * @param otherVector defines the second operand
  65667. * @returns true if both vectors are equals
  65668. */
  65669. equals(otherVector: DeepImmutable<Vector3>): boolean;
  65670. /**
  65671. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  65672. * @param otherVector defines the second operand
  65673. * @param epsilon defines the minimal distance to define values as equals
  65674. * @returns true if both vectors are distant less than epsilon
  65675. */
  65676. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  65677. /**
  65678. * Returns true if the current Vector3 coordinates equals the given floats
  65679. * @param x defines the x coordinate of the operand
  65680. * @param y defines the y coordinate of the operand
  65681. * @param z defines the z coordinate of the operand
  65682. * @returns true if both vectors are equals
  65683. */
  65684. equalsToFloats(x: number, y: number, z: number): boolean;
  65685. /**
  65686. * Multiplies the current Vector3 coordinates by the given ones
  65687. * @param otherVector defines the second operand
  65688. * @returns the current updated Vector3
  65689. */
  65690. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  65691. /**
  65692. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  65693. * @param otherVector defines the second operand
  65694. * @returns the new Vector3
  65695. */
  65696. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  65697. /**
  65698. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  65699. * @param otherVector defines the second operand
  65700. * @param result defines the Vector3 object where to store the result
  65701. * @returns the current Vector3
  65702. */
  65703. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65704. /**
  65705. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  65706. * @param x defines the x coordinate of the operand
  65707. * @param y defines the y coordinate of the operand
  65708. * @param z defines the z coordinate of the operand
  65709. * @returns the new Vector3
  65710. */
  65711. multiplyByFloats(x: number, y: number, z: number): Vector3;
  65712. /**
  65713. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  65714. * @param otherVector defines the second operand
  65715. * @returns the new Vector3
  65716. */
  65717. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  65718. /**
  65719. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  65720. * @param otherVector defines the second operand
  65721. * @param result defines the Vector3 object where to store the result
  65722. * @returns the current Vector3
  65723. */
  65724. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  65725. /**
  65726. * Divides the current Vector3 coordinates by the given ones.
  65727. * @param otherVector defines the second operand
  65728. * @returns the current updated Vector3
  65729. */
  65730. divideInPlace(otherVector: Vector3): Vector3;
  65731. /**
  65732. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  65733. * @param other defines the second operand
  65734. * @returns the current updated Vector3
  65735. */
  65736. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65737. /**
  65738. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  65739. * @param other defines the second operand
  65740. * @returns the current updated Vector3
  65741. */
  65742. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  65743. /**
  65744. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  65745. * @param x defines the x coordinate of the operand
  65746. * @param y defines the y coordinate of the operand
  65747. * @param z defines the z coordinate of the operand
  65748. * @returns the current updated Vector3
  65749. */
  65750. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65751. /**
  65752. * Updates the current Vector3 with the maximal coordinate values between its and the given 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. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  65759. /**
  65760. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  65761. * Check if is non uniform within a certain amount of decimal places to account for this
  65762. * @param epsilon the amount the values can differ
  65763. * @returns if the the vector is non uniform to a certain number of decimal places
  65764. */
  65765. isNonUniformWithinEpsilon(epsilon: number): boolean;
  65766. /**
  65767. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  65768. */
  65769. readonly isNonUniform: boolean;
  65770. /**
  65771. * Gets a new Vector3 from current Vector3 floored values
  65772. * @returns a new Vector3
  65773. */
  65774. floor(): Vector3;
  65775. /**
  65776. * Gets a new Vector3 from current Vector3 floored values
  65777. * @returns a new Vector3
  65778. */
  65779. fract(): Vector3;
  65780. /**
  65781. * Gets the length of the Vector3
  65782. * @returns the length of the Vector3
  65783. */
  65784. length(): number;
  65785. /**
  65786. * Gets the squared length of the Vector3
  65787. * @returns squared length of the Vector3
  65788. */
  65789. lengthSquared(): number;
  65790. /**
  65791. * Normalize the current Vector3.
  65792. * Please note that this is an in place operation.
  65793. * @returns the current updated Vector3
  65794. */
  65795. normalize(): Vector3;
  65796. /**
  65797. * Reorders the x y z properties of the vector in place
  65798. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  65799. * @returns the current updated vector
  65800. */
  65801. reorderInPlace(order: string): this;
  65802. /**
  65803. * Rotates the vector around 0,0,0 by a quaternion
  65804. * @param quaternion the rotation quaternion
  65805. * @param result vector to store the result
  65806. * @returns the resulting vector
  65807. */
  65808. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  65809. /**
  65810. * Rotates a vector around a given point
  65811. * @param quaternion the rotation quaternion
  65812. * @param point the point to rotate around
  65813. * @param result vector to store the result
  65814. * @returns the resulting vector
  65815. */
  65816. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  65817. /**
  65818. * Normalize the current Vector3 with the given input length.
  65819. * Please note that this is an in place operation.
  65820. * @param len the length of the vector
  65821. * @returns the current updated Vector3
  65822. */
  65823. normalizeFromLength(len: number): Vector3;
  65824. /**
  65825. * Normalize the current Vector3 to a new vector
  65826. * @returns the new Vector3
  65827. */
  65828. normalizeToNew(): Vector3;
  65829. /**
  65830. * Normalize the current Vector3 to the reference
  65831. * @param reference define the Vector3 to update
  65832. * @returns the updated Vector3
  65833. */
  65834. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  65835. /**
  65836. * Creates a new Vector3 copied from the current Vector3
  65837. * @returns the new Vector3
  65838. */
  65839. clone(): Vector3;
  65840. /**
  65841. * Copies the given vector coordinates to the current Vector3 ones
  65842. * @param source defines the source Vector3
  65843. * @returns the current updated Vector3
  65844. */
  65845. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  65846. /**
  65847. * Copies the given floats to the current Vector3 coordinates
  65848. * @param x defines the x coordinate of the operand
  65849. * @param y defines the y coordinate of the operand
  65850. * @param z defines the z coordinate of the operand
  65851. * @returns the current updated Vector3
  65852. */
  65853. copyFromFloats(x: number, y: number, z: number): Vector3;
  65854. /**
  65855. * Copies the given floats to the current Vector3 coordinates
  65856. * @param x defines the x coordinate of the operand
  65857. * @param y defines the y coordinate of the operand
  65858. * @param z defines the z coordinate of the operand
  65859. * @returns the current updated Vector3
  65860. */
  65861. set(x: number, y: number, z: number): Vector3;
  65862. /**
  65863. * Copies the given float to the current Vector3 coordinates
  65864. * @param v defines the x, y and z coordinates of the operand
  65865. * @returns the current updated Vector3
  65866. */
  65867. setAll(v: number): Vector3;
  65868. /**
  65869. * Get the clip factor between two vectors
  65870. * @param vector0 defines the first operand
  65871. * @param vector1 defines the second operand
  65872. * @param axis defines the axis to use
  65873. * @param size defines the size along the axis
  65874. * @returns the clip factor
  65875. */
  65876. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  65877. /**
  65878. * Get angle between two vectors
  65879. * @param vector0 angle between vector0 and vector1
  65880. * @param vector1 angle between vector0 and vector1
  65881. * @param normal direction of the normal
  65882. * @return the angle between vector0 and vector1
  65883. */
  65884. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  65885. /**
  65886. * Returns a new Vector3 set from the index "offset" of the given array
  65887. * @param array defines the source array
  65888. * @param offset defines the offset in the source array
  65889. * @returns the new Vector3
  65890. */
  65891. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  65892. /**
  65893. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  65894. * This function is deprecated. Use FromArray instead
  65895. * @param array defines the source array
  65896. * @param offset defines the offset in the source array
  65897. * @returns the new Vector3
  65898. */
  65899. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  65900. /**
  65901. * Sets the given vector "result" with the element values from the index "offset" of the given array
  65902. * @param array defines the source array
  65903. * @param offset defines the offset in the source array
  65904. * @param result defines the Vector3 where to store the result
  65905. */
  65906. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  65907. /**
  65908. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  65909. * This function is deprecated. Use FromArrayToRef instead.
  65910. * @param array defines the source array
  65911. * @param offset defines the offset in the source array
  65912. * @param result defines the Vector3 where to store the result
  65913. */
  65914. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  65915. /**
  65916. * Sets the given vector "result" with the given floats.
  65917. * @param x defines the x coordinate of the source
  65918. * @param y defines the y coordinate of the source
  65919. * @param z defines the z coordinate of the source
  65920. * @param result defines the Vector3 where to store the result
  65921. */
  65922. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  65923. /**
  65924. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  65925. * @returns a new empty Vector3
  65926. */
  65927. static Zero(): Vector3;
  65928. /**
  65929. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  65930. * @returns a new unit Vector3
  65931. */
  65932. static One(): Vector3;
  65933. /**
  65934. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  65935. * @returns a new up Vector3
  65936. */
  65937. static Up(): Vector3;
  65938. /**
  65939. * Gets a up Vector3 that must not be updated
  65940. */
  65941. static readonly UpReadOnly: DeepImmutable<Vector3>;
  65942. /**
  65943. * Gets a zero Vector3 that must not be updated
  65944. */
  65945. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  65946. /**
  65947. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  65948. * @returns a new down Vector3
  65949. */
  65950. static Down(): Vector3;
  65951. /**
  65952. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  65953. * @returns a new forward Vector3
  65954. */
  65955. static Forward(): Vector3;
  65956. /**
  65957. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  65958. * @returns a new forward Vector3
  65959. */
  65960. static Backward(): Vector3;
  65961. /**
  65962. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  65963. * @returns a new right Vector3
  65964. */
  65965. static Right(): Vector3;
  65966. /**
  65967. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  65968. * @returns a new left Vector3
  65969. */
  65970. static Left(): Vector3;
  65971. /**
  65972. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  65973. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65974. * @param vector defines the Vector3 to transform
  65975. * @param transformation defines the transformation matrix
  65976. * @returns the transformed Vector3
  65977. */
  65978. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  65979. /**
  65980. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  65981. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  65982. * @param vector defines the Vector3 to transform
  65983. * @param transformation defines the transformation matrix
  65984. * @param result defines the Vector3 where to store the result
  65985. */
  65986. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65987. /**
  65988. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  65989. * This method computes tranformed coordinates only, not transformed direction vectors
  65990. * @param x define the x coordinate of the source vector
  65991. * @param y define the y coordinate of the source vector
  65992. * @param z define the z coordinate of the source vector
  65993. * @param transformation defines the transformation matrix
  65994. * @param result defines the Vector3 where to store the result
  65995. */
  65996. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  65997. /**
  65998. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  65999. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66000. * @param vector defines the Vector3 to transform
  66001. * @param transformation defines the transformation matrix
  66002. * @returns the new Vector3
  66003. */
  66004. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  66005. /**
  66006. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  66007. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66008. * @param vector defines the Vector3 to transform
  66009. * @param transformation defines the transformation matrix
  66010. * @param result defines the Vector3 where to store the result
  66011. */
  66012. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66013. /**
  66014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  66015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  66016. * @param x define the x coordinate of the source vector
  66017. * @param y define the y coordinate of the source vector
  66018. * @param z define the z coordinate of the source vector
  66019. * @param transformation defines the transformation matrix
  66020. * @param result defines the Vector3 where to store the result
  66021. */
  66022. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  66023. /**
  66024. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  66025. * @param value1 defines the first control point
  66026. * @param value2 defines the second control point
  66027. * @param value3 defines the third control point
  66028. * @param value4 defines the fourth control point
  66029. * @param amount defines the amount on the spline to use
  66030. * @returns the new Vector3
  66031. */
  66032. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  66033. /**
  66034. * 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"
  66035. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66036. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66037. * @param value defines the current value
  66038. * @param min defines the lower range value
  66039. * @param max defines the upper range value
  66040. * @returns the new Vector3
  66041. */
  66042. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  66043. /**
  66044. * 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"
  66045. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  66046. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  66047. * @param value defines the current value
  66048. * @param min defines the lower range value
  66049. * @param max defines the upper range value
  66050. * @param result defines the Vector3 where to store the result
  66051. */
  66052. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  66053. /**
  66054. * Checks if a given vector is inside a specific range
  66055. * @param v defines the vector to test
  66056. * @param min defines the minimum range
  66057. * @param max defines the maximum range
  66058. */
  66059. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  66060. /**
  66061. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  66062. * @param value1 defines the first control point
  66063. * @param tangent1 defines the first tangent vector
  66064. * @param value2 defines the second control point
  66065. * @param tangent2 defines the second tangent vector
  66066. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  66067. * @returns the new Vector3
  66068. */
  66069. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  66070. /**
  66071. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  66072. * @param start defines the start value
  66073. * @param end defines the end value
  66074. * @param amount max defines amount between both (between 0 and 1)
  66075. * @returns the new Vector3
  66076. */
  66077. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  66078. /**
  66079. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  66080. * @param start defines the start value
  66081. * @param end defines the end value
  66082. * @param amount max defines amount between both (between 0 and 1)
  66083. * @param result defines the Vector3 where to store the result
  66084. */
  66085. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  66086. /**
  66087. * Returns the dot product (float) between the vectors "left" and "right"
  66088. * @param left defines the left operand
  66089. * @param right defines the right operand
  66090. * @returns the dot product
  66091. */
  66092. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  66093. /**
  66094. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  66095. * The cross product is then orthogonal to both "left" and "right"
  66096. * @param left defines the left operand
  66097. * @param right defines the right operand
  66098. * @returns the cross product
  66099. */
  66100. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66101. /**
  66102. * Sets the given vector "result" with the cross product of "left" and "right"
  66103. * The cross product is then orthogonal to both "left" and "right"
  66104. * @param left defines the left operand
  66105. * @param right defines the right operand
  66106. * @param result defines the Vector3 where to store the result
  66107. */
  66108. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  66109. /**
  66110. * Returns a new Vector3 as the normalization of the given vector
  66111. * @param vector defines the Vector3 to normalize
  66112. * @returns the new Vector3
  66113. */
  66114. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  66115. /**
  66116. * Sets the given vector "result" with the normalization of the given first vector
  66117. * @param vector defines the Vector3 to normalize
  66118. * @param result defines the Vector3 where to store the result
  66119. */
  66120. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  66121. /**
  66122. * Project a Vector3 onto screen space
  66123. * @param vector defines the Vector3 to project
  66124. * @param world defines the world matrix to use
  66125. * @param transform defines the transform (view x projection) matrix to use
  66126. * @param viewport defines the screen viewport to use
  66127. * @returns the new Vector3
  66128. */
  66129. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  66130. /** @hidden */
  66131. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  66132. /**
  66133. * Unproject from screen space to object space
  66134. * @param source defines the screen space Vector3 to use
  66135. * @param viewportWidth defines the current width of the viewport
  66136. * @param viewportHeight defines the current height of the viewport
  66137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66138. * @param transform defines the transform (view x projection) matrix to use
  66139. * @returns the new Vector3
  66140. */
  66141. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  66142. /**
  66143. * Unproject from screen space to object space
  66144. * @param source defines the screen space Vector3 to use
  66145. * @param viewportWidth defines the current width of the viewport
  66146. * @param viewportHeight defines the current height of the viewport
  66147. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66148. * @param view defines the view matrix to use
  66149. * @param projection defines the projection matrix to use
  66150. * @returns the new Vector3
  66151. */
  66152. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  66153. /**
  66154. * Unproject from screen space to object space
  66155. * @param source defines the screen space Vector3 to use
  66156. * @param viewportWidth defines the current width of the viewport
  66157. * @param viewportHeight defines the current height of the viewport
  66158. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66159. * @param view defines the view matrix to use
  66160. * @param projection defines the projection matrix to use
  66161. * @param result defines the Vector3 where to store the result
  66162. */
  66163. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66164. /**
  66165. * Unproject from screen space to object space
  66166. * @param sourceX defines the screen space x coordinate to use
  66167. * @param sourceY defines the screen space y coordinate to use
  66168. * @param sourceZ defines the screen space z coordinate to use
  66169. * @param viewportWidth defines the current width of the viewport
  66170. * @param viewportHeight defines the current height of the viewport
  66171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  66172. * @param view defines the view matrix to use
  66173. * @param projection defines the projection matrix to use
  66174. * @param result defines the Vector3 where to store the result
  66175. */
  66176. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  66177. /**
  66178. * Gets the minimal coordinate values between two Vector3
  66179. * @param left defines the first operand
  66180. * @param right defines the second operand
  66181. * @returns the new Vector3
  66182. */
  66183. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66184. /**
  66185. * Gets the maximal coordinate values between two Vector3
  66186. * @param left defines the first operand
  66187. * @param right defines the second operand
  66188. * @returns the new Vector3
  66189. */
  66190. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  66191. /**
  66192. * Returns the distance between the vectors "value1" and "value2"
  66193. * @param value1 defines the first operand
  66194. * @param value2 defines the second operand
  66195. * @returns the distance
  66196. */
  66197. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66198. /**
  66199. * Returns the squared distance between the vectors "value1" and "value2"
  66200. * @param value1 defines the first operand
  66201. * @param value2 defines the second operand
  66202. * @returns the squared distance
  66203. */
  66204. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  66205. /**
  66206. * Returns a new Vector3 located at the center between "value1" and "value2"
  66207. * @param value1 defines the first operand
  66208. * @param value2 defines the second operand
  66209. * @returns the new Vector3
  66210. */
  66211. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  66212. /**
  66213. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  66214. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  66215. * to something in order to rotate it from its local system to the given target system
  66216. * Note: axis1, axis2 and axis3 are normalized during this operation
  66217. * @param axis1 defines the first axis
  66218. * @param axis2 defines the second axis
  66219. * @param axis3 defines the third axis
  66220. * @returns a new Vector3
  66221. */
  66222. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  66223. /**
  66224. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  66225. * @param axis1 defines the first axis
  66226. * @param axis2 defines the second axis
  66227. * @param axis3 defines the third axis
  66228. * @param ref defines the Vector3 where to store the result
  66229. */
  66230. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  66231. }
  66232. /**
  66233. * Vector4 class created for EulerAngle class conversion to Quaternion
  66234. */
  66235. export class Vector4 {
  66236. /** x value of the vector */
  66237. x: number;
  66238. /** y value of the vector */
  66239. y: number;
  66240. /** z value of the vector */
  66241. z: number;
  66242. /** w value of the vector */
  66243. w: number;
  66244. /**
  66245. * Creates a Vector4 object from the given floats.
  66246. * @param x x value of the vector
  66247. * @param y y value of the vector
  66248. * @param z z value of the vector
  66249. * @param w w value of the vector
  66250. */
  66251. constructor(
  66252. /** x value of the vector */
  66253. x: number,
  66254. /** y value of the vector */
  66255. y: number,
  66256. /** z value of the vector */
  66257. z: number,
  66258. /** w value of the vector */
  66259. w: number);
  66260. /**
  66261. * Returns the string with the Vector4 coordinates.
  66262. * @returns a string containing all the vector values
  66263. */
  66264. toString(): string;
  66265. /**
  66266. * Returns the string "Vector4".
  66267. * @returns "Vector4"
  66268. */
  66269. getClassName(): string;
  66270. /**
  66271. * Returns the Vector4 hash code.
  66272. * @returns a unique hash code
  66273. */
  66274. getHashCode(): number;
  66275. /**
  66276. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  66277. * @returns the resulting array
  66278. */
  66279. asArray(): number[];
  66280. /**
  66281. * Populates the given array from the given index with the Vector4 coordinates.
  66282. * @param array array to populate
  66283. * @param index index of the array to start at (default: 0)
  66284. * @returns the Vector4.
  66285. */
  66286. toArray(array: FloatArray, index?: number): Vector4;
  66287. /**
  66288. * Adds the given vector to the current Vector4.
  66289. * @param otherVector the vector to add
  66290. * @returns the updated Vector4.
  66291. */
  66292. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66293. /**
  66294. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  66295. * @param otherVector the vector to add
  66296. * @returns the resulting vector
  66297. */
  66298. add(otherVector: DeepImmutable<Vector4>): Vector4;
  66299. /**
  66300. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  66301. * @param otherVector the vector to add
  66302. * @param result the vector to store the result
  66303. * @returns the current Vector4.
  66304. */
  66305. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66306. /**
  66307. * Subtract in place the given vector from the current Vector4.
  66308. * @param otherVector the vector to subtract
  66309. * @returns the updated Vector4.
  66310. */
  66311. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66312. /**
  66313. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  66314. * @param otherVector the vector to add
  66315. * @returns the new vector with the result
  66316. */
  66317. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  66318. /**
  66319. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  66320. * @param otherVector the vector to subtract
  66321. * @param result the vector to store the result
  66322. * @returns the current Vector4.
  66323. */
  66324. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66325. /**
  66326. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66327. */
  66328. /**
  66329. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66330. * @param x value to subtract
  66331. * @param y value to subtract
  66332. * @param z value to subtract
  66333. * @param w value to subtract
  66334. * @returns new vector containing the result
  66335. */
  66336. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66337. /**
  66338. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  66339. * @param x value to subtract
  66340. * @param y value to subtract
  66341. * @param z value to subtract
  66342. * @param w value to subtract
  66343. * @param result the vector to store the result in
  66344. * @returns the current Vector4.
  66345. */
  66346. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  66347. /**
  66348. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  66349. * @returns a new vector with the negated values
  66350. */
  66351. negate(): Vector4;
  66352. /**
  66353. * Multiplies the current Vector4 coordinates by scale (float).
  66354. * @param scale the number to scale with
  66355. * @returns the updated Vector4.
  66356. */
  66357. scaleInPlace(scale: number): Vector4;
  66358. /**
  66359. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  66360. * @param scale the number to scale with
  66361. * @returns a new vector with the result
  66362. */
  66363. scale(scale: number): Vector4;
  66364. /**
  66365. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  66366. * @param scale the number to scale with
  66367. * @param result a vector to store the result in
  66368. * @returns the current Vector4.
  66369. */
  66370. scaleToRef(scale: number, result: Vector4): Vector4;
  66371. /**
  66372. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  66373. * @param scale defines the scale factor
  66374. * @param result defines the Vector4 object where to store the result
  66375. * @returns the unmodified current Vector4
  66376. */
  66377. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  66378. /**
  66379. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  66380. * @param otherVector the vector to compare against
  66381. * @returns true if they are equal
  66382. */
  66383. equals(otherVector: DeepImmutable<Vector4>): boolean;
  66384. /**
  66385. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  66386. * @param otherVector vector to compare against
  66387. * @param epsilon (Default: very small number)
  66388. * @returns true if they are equal
  66389. */
  66390. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  66391. /**
  66392. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  66393. * @param x x value to compare against
  66394. * @param y y value to compare against
  66395. * @param z z value to compare against
  66396. * @param w w value to compare against
  66397. * @returns true if equal
  66398. */
  66399. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  66400. /**
  66401. * Multiplies in place the current Vector4 by the given one.
  66402. * @param otherVector vector to multiple with
  66403. * @returns the updated Vector4.
  66404. */
  66405. multiplyInPlace(otherVector: Vector4): Vector4;
  66406. /**
  66407. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  66408. * @param otherVector vector to multiple with
  66409. * @returns resulting new vector
  66410. */
  66411. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  66412. /**
  66413. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  66414. * @param otherVector vector to multiple with
  66415. * @param result vector to store the result
  66416. * @returns the current Vector4.
  66417. */
  66418. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66419. /**
  66420. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  66421. * @param x x value multiply with
  66422. * @param y y value multiply with
  66423. * @param z z value multiply with
  66424. * @param w w value multiply with
  66425. * @returns resulting new vector
  66426. */
  66427. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  66428. /**
  66429. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  66430. * @param otherVector vector to devide with
  66431. * @returns resulting new vector
  66432. */
  66433. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  66434. /**
  66435. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  66436. * @param otherVector vector to devide with
  66437. * @param result vector to store the result
  66438. * @returns the current Vector4.
  66439. */
  66440. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  66441. /**
  66442. * Divides the current Vector3 coordinates by the given ones.
  66443. * @param otherVector vector to devide with
  66444. * @returns the updated Vector3.
  66445. */
  66446. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  66447. /**
  66448. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  66449. * @param other defines the second operand
  66450. * @returns the current updated Vector4
  66451. */
  66452. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66453. /**
  66454. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  66455. * @param other defines the second operand
  66456. * @returns the current updated Vector4
  66457. */
  66458. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  66459. /**
  66460. * Gets a new Vector4 from current Vector4 floored values
  66461. * @returns a new Vector4
  66462. */
  66463. floor(): Vector4;
  66464. /**
  66465. * Gets a new Vector4 from current Vector3 floored values
  66466. * @returns a new Vector4
  66467. */
  66468. fract(): Vector4;
  66469. /**
  66470. * Returns the Vector4 length (float).
  66471. * @returns the length
  66472. */
  66473. length(): number;
  66474. /**
  66475. * Returns the Vector4 squared length (float).
  66476. * @returns the length squared
  66477. */
  66478. lengthSquared(): number;
  66479. /**
  66480. * Normalizes in place the Vector4.
  66481. * @returns the updated Vector4.
  66482. */
  66483. normalize(): Vector4;
  66484. /**
  66485. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  66486. * @returns this converted to a new vector3
  66487. */
  66488. toVector3(): Vector3;
  66489. /**
  66490. * Returns a new Vector4 copied from the current one.
  66491. * @returns the new cloned vector
  66492. */
  66493. clone(): Vector4;
  66494. /**
  66495. * Updates the current Vector4 with the given one coordinates.
  66496. * @param source the source vector to copy from
  66497. * @returns the updated Vector4.
  66498. */
  66499. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  66500. /**
  66501. * Updates the current Vector4 coordinates with the given floats.
  66502. * @param x float to copy from
  66503. * @param y float to copy from
  66504. * @param z float to copy from
  66505. * @param w float to copy from
  66506. * @returns the updated Vector4.
  66507. */
  66508. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  66509. /**
  66510. * Updates the current Vector4 coordinates with the given floats.
  66511. * @param x float to set from
  66512. * @param y float to set from
  66513. * @param z float to set from
  66514. * @param w float to set from
  66515. * @returns the updated Vector4.
  66516. */
  66517. set(x: number, y: number, z: number, w: number): Vector4;
  66518. /**
  66519. * Copies the given float to the current Vector3 coordinates
  66520. * @param v defines the x, y, z and w coordinates of the operand
  66521. * @returns the current updated Vector3
  66522. */
  66523. setAll(v: number): Vector4;
  66524. /**
  66525. * Returns a new Vector4 set from the starting index of the given array.
  66526. * @param array the array to pull values from
  66527. * @param offset the offset into the array to start at
  66528. * @returns the new vector
  66529. */
  66530. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  66531. /**
  66532. * Updates the given vector "result" from the starting index of the given array.
  66533. * @param array the array to pull values from
  66534. * @param offset the offset into the array to start at
  66535. * @param result the vector to store the result in
  66536. */
  66537. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  66538. /**
  66539. * Updates the given vector "result" from the starting index of the given Float32Array.
  66540. * @param array the array to pull values from
  66541. * @param offset the offset into the array to start at
  66542. * @param result the vector to store the result in
  66543. */
  66544. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  66545. /**
  66546. * Updates the given vector "result" coordinates from the given floats.
  66547. * @param x float to set from
  66548. * @param y float to set from
  66549. * @param z float to set from
  66550. * @param w float to set from
  66551. * @param result the vector to the floats in
  66552. */
  66553. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  66554. /**
  66555. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  66556. * @returns the new vector
  66557. */
  66558. static Zero(): Vector4;
  66559. /**
  66560. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  66561. * @returns the new vector
  66562. */
  66563. static One(): Vector4;
  66564. /**
  66565. * Returns a new normalized Vector4 from the given one.
  66566. * @param vector the vector to normalize
  66567. * @returns the vector
  66568. */
  66569. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  66570. /**
  66571. * Updates the given vector "result" from the normalization of the given one.
  66572. * @param vector the vector to normalize
  66573. * @param result the vector to store the result in
  66574. */
  66575. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  66576. /**
  66577. * Returns a vector with the minimum values from the left and right vectors
  66578. * @param left left vector to minimize
  66579. * @param right right vector to minimize
  66580. * @returns a new vector with the minimum of the left and right vector values
  66581. */
  66582. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66583. /**
  66584. * Returns a vector with the maximum values from the left and right vectors
  66585. * @param left left vector to maximize
  66586. * @param right right vector to maximize
  66587. * @returns a new vector with the maximum of the left and right vector values
  66588. */
  66589. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  66590. /**
  66591. * Returns the distance (float) between the vectors "value1" and "value2".
  66592. * @param value1 value to calulate the distance between
  66593. * @param value2 value to calulate the distance between
  66594. * @return the distance between the two vectors
  66595. */
  66596. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66597. /**
  66598. * Returns the squared distance (float) between the vectors "value1" and "value2".
  66599. * @param value1 value to calulate the distance between
  66600. * @param value2 value to calulate the distance between
  66601. * @return the distance between the two vectors squared
  66602. */
  66603. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  66604. /**
  66605. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  66606. * @param value1 value to calulate the center between
  66607. * @param value2 value to calulate the center between
  66608. * @return the center between the two vectors
  66609. */
  66610. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  66611. /**
  66612. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  66613. * This methods computes transformed normalized direction vectors only.
  66614. * @param vector the vector to transform
  66615. * @param transformation the transformation matrix to apply
  66616. * @returns the new vector
  66617. */
  66618. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  66619. /**
  66620. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  66621. * This methods computes transformed normalized direction vectors only.
  66622. * @param vector the vector to transform
  66623. * @param transformation the transformation matrix to apply
  66624. * @param result the vector to store the result in
  66625. */
  66626. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66627. /**
  66628. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  66629. * This methods computes transformed normalized direction vectors only.
  66630. * @param x value to transform
  66631. * @param y value to transform
  66632. * @param z value to transform
  66633. * @param w value to transform
  66634. * @param transformation the transformation matrix to apply
  66635. * @param result the vector to store the results in
  66636. */
  66637. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  66638. /**
  66639. * Creates a new Vector4 from a Vector3
  66640. * @param source defines the source data
  66641. * @param w defines the 4th component (default is 0)
  66642. * @returns a new Vector4
  66643. */
  66644. static FromVector3(source: Vector3, w?: number): Vector4;
  66645. }
  66646. /**
  66647. * Class used to store quaternion data
  66648. * @see https://en.wikipedia.org/wiki/Quaternion
  66649. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  66650. */
  66651. export class Quaternion {
  66652. /** defines the first component (0 by default) */
  66653. x: number;
  66654. /** defines the second component (0 by default) */
  66655. y: number;
  66656. /** defines the third component (0 by default) */
  66657. z: number;
  66658. /** defines the fourth component (1.0 by default) */
  66659. w: number;
  66660. /**
  66661. * Creates a new Quaternion from the given floats
  66662. * @param x defines the first component (0 by default)
  66663. * @param y defines the second component (0 by default)
  66664. * @param z defines the third component (0 by default)
  66665. * @param w defines the fourth component (1.0 by default)
  66666. */
  66667. constructor(
  66668. /** defines the first component (0 by default) */
  66669. x?: number,
  66670. /** defines the second component (0 by default) */
  66671. y?: number,
  66672. /** defines the third component (0 by default) */
  66673. z?: number,
  66674. /** defines the fourth component (1.0 by default) */
  66675. w?: number);
  66676. /**
  66677. * Gets a string representation for the current quaternion
  66678. * @returns a string with the Quaternion coordinates
  66679. */
  66680. toString(): string;
  66681. /**
  66682. * Gets the class name of the quaternion
  66683. * @returns the string "Quaternion"
  66684. */
  66685. getClassName(): string;
  66686. /**
  66687. * Gets a hash code for this quaternion
  66688. * @returns the quaternion hash code
  66689. */
  66690. getHashCode(): number;
  66691. /**
  66692. * Copy the quaternion to an array
  66693. * @returns a new array populated with 4 elements from the quaternion coordinates
  66694. */
  66695. asArray(): number[];
  66696. /**
  66697. * Check if two quaternions are equals
  66698. * @param otherQuaternion defines the second operand
  66699. * @return true if the current quaternion and the given one coordinates are strictly equals
  66700. */
  66701. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  66702. /**
  66703. * Clone the current quaternion
  66704. * @returns a new quaternion copied from the current one
  66705. */
  66706. clone(): Quaternion;
  66707. /**
  66708. * Copy a quaternion to the current one
  66709. * @param other defines the other quaternion
  66710. * @returns the updated current quaternion
  66711. */
  66712. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  66713. /**
  66714. * Updates the current quaternion with the given float coordinates
  66715. * @param x defines the x coordinate
  66716. * @param y defines the y coordinate
  66717. * @param z defines the z coordinate
  66718. * @param w defines the w coordinate
  66719. * @returns the updated current quaternion
  66720. */
  66721. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  66722. /**
  66723. * Updates the current quaternion from the given float coordinates
  66724. * @param x defines the x coordinate
  66725. * @param y defines the y coordinate
  66726. * @param z defines the z coordinate
  66727. * @param w defines the w coordinate
  66728. * @returns the updated current quaternion
  66729. */
  66730. set(x: number, y: number, z: number, w: number): Quaternion;
  66731. /**
  66732. * Adds two quaternions
  66733. * @param other defines the second operand
  66734. * @returns a new quaternion as the addition result of the given one and the current quaternion
  66735. */
  66736. add(other: DeepImmutable<Quaternion>): Quaternion;
  66737. /**
  66738. * Add a quaternion to the current one
  66739. * @param other defines the quaternion to add
  66740. * @returns the current quaternion
  66741. */
  66742. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  66743. /**
  66744. * Subtract two quaternions
  66745. * @param other defines the second operand
  66746. * @returns a new quaternion as the subtraction result of the given one from the current one
  66747. */
  66748. subtract(other: Quaternion): Quaternion;
  66749. /**
  66750. * Multiplies the current quaternion by a scale factor
  66751. * @param value defines the scale factor
  66752. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  66753. */
  66754. scale(value: number): Quaternion;
  66755. /**
  66756. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  66757. * @param scale defines the scale factor
  66758. * @param result defines the Quaternion object where to store the result
  66759. * @returns the unmodified current quaternion
  66760. */
  66761. scaleToRef(scale: number, result: Quaternion): Quaternion;
  66762. /**
  66763. * Multiplies in place the current quaternion by a scale factor
  66764. * @param value defines the scale factor
  66765. * @returns the current modified quaternion
  66766. */
  66767. scaleInPlace(value: number): Quaternion;
  66768. /**
  66769. * Scale the current quaternion values by a factor and add the result to a given quaternion
  66770. * @param scale defines the scale factor
  66771. * @param result defines the Quaternion object where to store the result
  66772. * @returns the unmodified current quaternion
  66773. */
  66774. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  66775. /**
  66776. * Multiplies two quaternions
  66777. * @param q1 defines the second operand
  66778. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  66779. */
  66780. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  66781. /**
  66782. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  66783. * @param q1 defines the second operand
  66784. * @param result defines the target quaternion
  66785. * @returns the current quaternion
  66786. */
  66787. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  66788. /**
  66789. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  66790. * @param q1 defines the second operand
  66791. * @returns the currentupdated quaternion
  66792. */
  66793. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  66794. /**
  66795. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  66796. * @param ref defines the target quaternion
  66797. * @returns the current quaternion
  66798. */
  66799. conjugateToRef(ref: Quaternion): Quaternion;
  66800. /**
  66801. * Conjugates in place (1-q) the current quaternion
  66802. * @returns the current updated quaternion
  66803. */
  66804. conjugateInPlace(): Quaternion;
  66805. /**
  66806. * Conjugates in place (1-q) the current quaternion
  66807. * @returns a new quaternion
  66808. */
  66809. conjugate(): Quaternion;
  66810. /**
  66811. * Gets length of current quaternion
  66812. * @returns the quaternion length (float)
  66813. */
  66814. length(): number;
  66815. /**
  66816. * Normalize in place the current quaternion
  66817. * @returns the current updated quaternion
  66818. */
  66819. normalize(): Quaternion;
  66820. /**
  66821. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  66822. * @param order is a reserved parameter and is ignore for now
  66823. * @returns a new Vector3 containing the Euler angles
  66824. */
  66825. toEulerAngles(order?: string): Vector3;
  66826. /**
  66827. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  66828. * @param result defines the vector which will be filled with the Euler angles
  66829. * @param order is a reserved parameter and is ignore for now
  66830. * @returns the current unchanged quaternion
  66831. */
  66832. toEulerAnglesToRef(result: Vector3): Quaternion;
  66833. /**
  66834. * Updates the given rotation matrix with the current quaternion values
  66835. * @param result defines the target matrix
  66836. * @returns the current unchanged quaternion
  66837. */
  66838. toRotationMatrix(result: Matrix): Quaternion;
  66839. /**
  66840. * Updates the current quaternion from the given rotation matrix values
  66841. * @param matrix defines the source matrix
  66842. * @returns the current updated quaternion
  66843. */
  66844. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66845. /**
  66846. * Creates a new quaternion from a rotation matrix
  66847. * @param matrix defines the source matrix
  66848. * @returns a new quaternion created from the given rotation matrix values
  66849. */
  66850. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  66851. /**
  66852. * Updates the given quaternion with the given rotation matrix values
  66853. * @param matrix defines the source matrix
  66854. * @param result defines the target quaternion
  66855. */
  66856. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  66857. /**
  66858. * Returns the dot product (float) between the quaternions "left" and "right"
  66859. * @param left defines the left operand
  66860. * @param right defines the right operand
  66861. * @returns the dot product
  66862. */
  66863. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  66864. /**
  66865. * Checks if the two quaternions are close to each other
  66866. * @param quat0 defines the first quaternion to check
  66867. * @param quat1 defines the second quaternion to check
  66868. * @returns true if the two quaternions are close to each other
  66869. */
  66870. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  66871. /**
  66872. * Creates an empty quaternion
  66873. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  66874. */
  66875. static Zero(): Quaternion;
  66876. /**
  66877. * Inverse a given quaternion
  66878. * @param q defines the source quaternion
  66879. * @returns a new quaternion as the inverted current quaternion
  66880. */
  66881. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  66882. /**
  66883. * Inverse a given quaternion
  66884. * @param q defines the source quaternion
  66885. * @param result the quaternion the result will be stored in
  66886. * @returns the result quaternion
  66887. */
  66888. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  66889. /**
  66890. * Creates an identity quaternion
  66891. * @returns the identity quaternion
  66892. */
  66893. static Identity(): Quaternion;
  66894. /**
  66895. * Gets a boolean indicating if the given quaternion is identity
  66896. * @param quaternion defines the quaternion to check
  66897. * @returns true if the quaternion is identity
  66898. */
  66899. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  66900. /**
  66901. * Creates a quaternion from a rotation around an axis
  66902. * @param axis defines the axis to use
  66903. * @param angle defines the angle to use
  66904. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  66905. */
  66906. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  66907. /**
  66908. * Creates a rotation around an axis and stores it into the given quaternion
  66909. * @param axis defines the axis to use
  66910. * @param angle defines the angle to use
  66911. * @param result defines the target quaternion
  66912. * @returns the target quaternion
  66913. */
  66914. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  66915. /**
  66916. * Creates a new quaternion from data stored into an array
  66917. * @param array defines the data source
  66918. * @param offset defines the offset in the source array where the data starts
  66919. * @returns a new quaternion
  66920. */
  66921. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  66922. /**
  66923. * Create a quaternion from Euler rotation angles
  66924. * @param x Pitch
  66925. * @param y Yaw
  66926. * @param z Roll
  66927. * @returns the new Quaternion
  66928. */
  66929. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  66930. /**
  66931. * Updates a quaternion from Euler rotation angles
  66932. * @param x Pitch
  66933. * @param y Yaw
  66934. * @param z Roll
  66935. * @param result the quaternion to store the result
  66936. * @returns the updated quaternion
  66937. */
  66938. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  66939. /**
  66940. * Create a quaternion from Euler rotation vector
  66941. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66942. * @returns the new Quaternion
  66943. */
  66944. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  66945. /**
  66946. * Updates a quaternion from Euler rotation vector
  66947. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  66948. * @param result the quaternion to store the result
  66949. * @returns the updated quaternion
  66950. */
  66951. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  66952. /**
  66953. * Creates a new quaternion from the given Euler float angles (y, x, z)
  66954. * @param yaw defines the rotation around Y axis
  66955. * @param pitch defines the rotation around X axis
  66956. * @param roll defines the rotation around Z axis
  66957. * @returns the new quaternion
  66958. */
  66959. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  66960. /**
  66961. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  66962. * @param yaw defines the rotation around Y axis
  66963. * @param pitch defines the rotation around X axis
  66964. * @param roll defines the rotation around Z axis
  66965. * @param result defines the target quaternion
  66966. */
  66967. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  66968. /**
  66969. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  66970. * @param alpha defines the rotation around first axis
  66971. * @param beta defines the rotation around second axis
  66972. * @param gamma defines the rotation around third axis
  66973. * @returns the new quaternion
  66974. */
  66975. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  66976. /**
  66977. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  66978. * @param alpha defines the rotation around first axis
  66979. * @param beta defines the rotation around second axis
  66980. * @param gamma defines the rotation around third axis
  66981. * @param result defines the target quaternion
  66982. */
  66983. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  66984. /**
  66985. * 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)
  66986. * @param axis1 defines the first axis
  66987. * @param axis2 defines the second axis
  66988. * @param axis3 defines the third axis
  66989. * @returns the new quaternion
  66990. */
  66991. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  66992. /**
  66993. * 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
  66994. * @param axis1 defines the first axis
  66995. * @param axis2 defines the second axis
  66996. * @param axis3 defines the third axis
  66997. * @param ref defines the target quaternion
  66998. */
  66999. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  67000. /**
  67001. * Interpolates between two quaternions
  67002. * @param left defines first quaternion
  67003. * @param right defines second quaternion
  67004. * @param amount defines the gradient to use
  67005. * @returns the new interpolated quaternion
  67006. */
  67007. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67008. /**
  67009. * Interpolates between two quaternions and stores it into a target quaternion
  67010. * @param left defines first quaternion
  67011. * @param right defines second quaternion
  67012. * @param amount defines the gradient to use
  67013. * @param result defines the target quaternion
  67014. */
  67015. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  67016. /**
  67017. * Interpolate between two quaternions using Hermite interpolation
  67018. * @param value1 defines first quaternion
  67019. * @param tangent1 defines the incoming tangent
  67020. * @param value2 defines second quaternion
  67021. * @param tangent2 defines the outgoing tangent
  67022. * @param amount defines the target quaternion
  67023. * @returns the new interpolated quaternion
  67024. */
  67025. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  67026. }
  67027. /**
  67028. * Class used to store matrix data (4x4)
  67029. */
  67030. export class Matrix {
  67031. private static _updateFlagSeed;
  67032. private static _identityReadOnly;
  67033. private _isIdentity;
  67034. private _isIdentityDirty;
  67035. private _isIdentity3x2;
  67036. private _isIdentity3x2Dirty;
  67037. /**
  67038. * Gets the update flag of the matrix which is an unique number for the matrix.
  67039. * It will be incremented every time the matrix data change.
  67040. * You can use it to speed the comparison between two versions of the same matrix.
  67041. */
  67042. updateFlag: number;
  67043. private readonly _m;
  67044. /**
  67045. * Gets the internal data of the matrix
  67046. */
  67047. readonly m: DeepImmutable<Float32Array>;
  67048. /** @hidden */
  67049. _markAsUpdated(): void;
  67050. /** @hidden */
  67051. private _updateIdentityStatus;
  67052. /**
  67053. * Creates an empty matrix (filled with zeros)
  67054. */
  67055. constructor();
  67056. /**
  67057. * Check if the current matrix is identity
  67058. * @returns true is the matrix is the identity matrix
  67059. */
  67060. isIdentity(): boolean;
  67061. /**
  67062. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  67063. * @returns true is the matrix is the identity matrix
  67064. */
  67065. isIdentityAs3x2(): boolean;
  67066. /**
  67067. * Gets the determinant of the matrix
  67068. * @returns the matrix determinant
  67069. */
  67070. determinant(): number;
  67071. /**
  67072. * Returns the matrix as a Float32Array
  67073. * @returns the matrix underlying array
  67074. */
  67075. toArray(): DeepImmutable<Float32Array>;
  67076. /**
  67077. * Returns the matrix as a Float32Array
  67078. * @returns the matrix underlying array.
  67079. */
  67080. asArray(): DeepImmutable<Float32Array>;
  67081. /**
  67082. * Inverts the current matrix in place
  67083. * @returns the current inverted matrix
  67084. */
  67085. invert(): Matrix;
  67086. /**
  67087. * Sets all the matrix elements to zero
  67088. * @returns the current matrix
  67089. */
  67090. reset(): Matrix;
  67091. /**
  67092. * Adds the current matrix with a second one
  67093. * @param other defines the matrix to add
  67094. * @returns a new matrix as the addition of the current matrix and the given one
  67095. */
  67096. add(other: DeepImmutable<Matrix>): Matrix;
  67097. /**
  67098. * Sets the given matrix "result" to the addition of the current matrix and the given one
  67099. * @param other defines the matrix to add
  67100. * @param result defines the target matrix
  67101. * @returns the current matrix
  67102. */
  67103. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67104. /**
  67105. * Adds in place the given matrix to the current matrix
  67106. * @param other defines the second operand
  67107. * @returns the current updated matrix
  67108. */
  67109. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  67110. /**
  67111. * Sets the given matrix to the current inverted Matrix
  67112. * @param other defines the target matrix
  67113. * @returns the unmodified current matrix
  67114. */
  67115. invertToRef(other: Matrix): Matrix;
  67116. /**
  67117. * add a value at the specified position in the current Matrix
  67118. * @param index the index of the value within the matrix. between 0 and 15.
  67119. * @param value the value to be added
  67120. * @returns the current updated matrix
  67121. */
  67122. addAtIndex(index: number, value: number): Matrix;
  67123. /**
  67124. * mutiply the specified position in the current Matrix by a value
  67125. * @param index the index of the value within the matrix. between 0 and 15.
  67126. * @param value the value to be added
  67127. * @returns the current updated matrix
  67128. */
  67129. multiplyAtIndex(index: number, value: number): Matrix;
  67130. /**
  67131. * Inserts the translation vector (using 3 floats) in the current matrix
  67132. * @param x defines the 1st component of the translation
  67133. * @param y defines the 2nd component of the translation
  67134. * @param z defines the 3rd component of the translation
  67135. * @returns the current updated matrix
  67136. */
  67137. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67138. /**
  67139. * Adds the translation vector (using 3 floats) in the current matrix
  67140. * @param x defines the 1st component of the translation
  67141. * @param y defines the 2nd component of the translation
  67142. * @param z defines the 3rd component of the translation
  67143. * @returns the current updated matrix
  67144. */
  67145. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  67146. /**
  67147. * Inserts the translation vector in the current matrix
  67148. * @param vector3 defines the translation to insert
  67149. * @returns the current updated matrix
  67150. */
  67151. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  67152. /**
  67153. * Gets the translation value of the current matrix
  67154. * @returns a new Vector3 as the extracted translation from the matrix
  67155. */
  67156. getTranslation(): Vector3;
  67157. /**
  67158. * Fill a Vector3 with the extracted translation from the matrix
  67159. * @param result defines the Vector3 where to store the translation
  67160. * @returns the current matrix
  67161. */
  67162. getTranslationToRef(result: Vector3): Matrix;
  67163. /**
  67164. * Remove rotation and scaling part from the matrix
  67165. * @returns the updated matrix
  67166. */
  67167. removeRotationAndScaling(): Matrix;
  67168. /**
  67169. * Multiply two matrices
  67170. * @param other defines the second operand
  67171. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  67172. */
  67173. multiply(other: DeepImmutable<Matrix>): Matrix;
  67174. /**
  67175. * Copy the current matrix from the given one
  67176. * @param other defines the source matrix
  67177. * @returns the current updated matrix
  67178. */
  67179. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  67180. /**
  67181. * Populates the given array from the starting index with the current matrix values
  67182. * @param array defines the target array
  67183. * @param offset defines the offset in the target array where to start storing values
  67184. * @returns the current matrix
  67185. */
  67186. copyToArray(array: Float32Array, offset?: number): Matrix;
  67187. /**
  67188. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  67189. * @param other defines the second operand
  67190. * @param result defines the matrix where to store the multiplication
  67191. * @returns the current matrix
  67192. */
  67193. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  67194. /**
  67195. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  67196. * @param other defines the second operand
  67197. * @param result defines the array where to store the multiplication
  67198. * @param offset defines the offset in the target array where to start storing values
  67199. * @returns the current matrix
  67200. */
  67201. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  67202. /**
  67203. * Check equality between this matrix and a second one
  67204. * @param value defines the second matrix to compare
  67205. * @returns true is the current matrix and the given one values are strictly equal
  67206. */
  67207. equals(value: DeepImmutable<Matrix>): boolean;
  67208. /**
  67209. * Clone the current matrix
  67210. * @returns a new matrix from the current matrix
  67211. */
  67212. clone(): Matrix;
  67213. /**
  67214. * Returns the name of the current matrix class
  67215. * @returns the string "Matrix"
  67216. */
  67217. getClassName(): string;
  67218. /**
  67219. * Gets the hash code of the current matrix
  67220. * @returns the hash code
  67221. */
  67222. getHashCode(): number;
  67223. /**
  67224. * Decomposes the current Matrix into a translation, rotation and scaling components
  67225. * @param scale defines the scale vector3 given as a reference to update
  67226. * @param rotation defines the rotation quaternion given as a reference to update
  67227. * @param translation defines the translation vector3 given as a reference to update
  67228. * @returns true if operation was successful
  67229. */
  67230. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  67231. /**
  67232. * Gets specific row of the matrix
  67233. * @param index defines the number of the row to get
  67234. * @returns the index-th row of the current matrix as a new Vector4
  67235. */
  67236. getRow(index: number): Nullable<Vector4>;
  67237. /**
  67238. * Sets the index-th row of the current matrix to the vector4 values
  67239. * @param index defines the number of the row to set
  67240. * @param row defines the target vector4
  67241. * @returns the updated current matrix
  67242. */
  67243. setRow(index: number, row: Vector4): Matrix;
  67244. /**
  67245. * Compute the transpose of the matrix
  67246. * @returns the new transposed matrix
  67247. */
  67248. transpose(): Matrix;
  67249. /**
  67250. * Compute the transpose of the matrix and store it in a given matrix
  67251. * @param result defines the target matrix
  67252. * @returns the current matrix
  67253. */
  67254. transposeToRef(result: Matrix): Matrix;
  67255. /**
  67256. * Sets the index-th row of the current matrix with the given 4 x float values
  67257. * @param index defines the row index
  67258. * @param x defines the x component to set
  67259. * @param y defines the y component to set
  67260. * @param z defines the z component to set
  67261. * @param w defines the w component to set
  67262. * @returns the updated current matrix
  67263. */
  67264. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  67265. /**
  67266. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  67267. * @param scale defines the scale factor
  67268. * @returns a new matrix
  67269. */
  67270. scale(scale: number): Matrix;
  67271. /**
  67272. * Scale the current matrix values by a factor to a given result matrix
  67273. * @param scale defines the scale factor
  67274. * @param result defines the matrix to store the result
  67275. * @returns the current matrix
  67276. */
  67277. scaleToRef(scale: number, result: Matrix): Matrix;
  67278. /**
  67279. * Scale the current matrix values by a factor and add the result to a given matrix
  67280. * @param scale defines the scale factor
  67281. * @param result defines the Matrix to store the result
  67282. * @returns the current matrix
  67283. */
  67284. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  67285. /**
  67286. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  67287. * @param ref matrix to store the result
  67288. */
  67289. toNormalMatrix(ref: Matrix): void;
  67290. /**
  67291. * Gets only rotation part of the current matrix
  67292. * @returns a new matrix sets to the extracted rotation matrix from the current one
  67293. */
  67294. getRotationMatrix(): Matrix;
  67295. /**
  67296. * Extracts the rotation matrix from the current one and sets it as the given "result"
  67297. * @param result defines the target matrix to store data to
  67298. * @returns the current matrix
  67299. */
  67300. getRotationMatrixToRef(result: Matrix): Matrix;
  67301. /**
  67302. * Toggles model matrix from being right handed to left handed in place and vice versa
  67303. */
  67304. toggleModelMatrixHandInPlace(): void;
  67305. /**
  67306. * Toggles projection matrix from being right handed to left handed in place and vice versa
  67307. */
  67308. toggleProjectionMatrixHandInPlace(): void;
  67309. /**
  67310. * Creates a matrix from an array
  67311. * @param array defines the source array
  67312. * @param offset defines an offset in the source array
  67313. * @returns a new Matrix set from the starting index of the given array
  67314. */
  67315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  67316. /**
  67317. * Copy the content of an array into a given matrix
  67318. * @param array defines the source array
  67319. * @param offset defines an offset in the source array
  67320. * @param result defines the target matrix
  67321. */
  67322. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  67323. /**
  67324. * Stores an array into a matrix after having multiplied each component by a given factor
  67325. * @param array defines the source array
  67326. * @param offset defines the offset in the source array
  67327. * @param scale defines the scaling factor
  67328. * @param result defines the target matrix
  67329. */
  67330. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  67331. /**
  67332. * Gets an identity matrix that must not be updated
  67333. */
  67334. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  67335. /**
  67336. * Stores a list of values (16) inside a given matrix
  67337. * @param initialM11 defines 1st value of 1st row
  67338. * @param initialM12 defines 2nd value of 1st row
  67339. * @param initialM13 defines 3rd value of 1st row
  67340. * @param initialM14 defines 4th value of 1st row
  67341. * @param initialM21 defines 1st value of 2nd row
  67342. * @param initialM22 defines 2nd value of 2nd row
  67343. * @param initialM23 defines 3rd value of 2nd row
  67344. * @param initialM24 defines 4th value of 2nd row
  67345. * @param initialM31 defines 1st value of 3rd row
  67346. * @param initialM32 defines 2nd value of 3rd row
  67347. * @param initialM33 defines 3rd value of 3rd row
  67348. * @param initialM34 defines 4th value of 3rd row
  67349. * @param initialM41 defines 1st value of 4th row
  67350. * @param initialM42 defines 2nd value of 4th row
  67351. * @param initialM43 defines 3rd value of 4th row
  67352. * @param initialM44 defines 4th value of 4th row
  67353. * @param result defines the target matrix
  67354. */
  67355. 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;
  67356. /**
  67357. * Creates new matrix from a list of values (16)
  67358. * @param initialM11 defines 1st value of 1st row
  67359. * @param initialM12 defines 2nd value of 1st row
  67360. * @param initialM13 defines 3rd value of 1st row
  67361. * @param initialM14 defines 4th value of 1st row
  67362. * @param initialM21 defines 1st value of 2nd row
  67363. * @param initialM22 defines 2nd value of 2nd row
  67364. * @param initialM23 defines 3rd value of 2nd row
  67365. * @param initialM24 defines 4th value of 2nd row
  67366. * @param initialM31 defines 1st value of 3rd row
  67367. * @param initialM32 defines 2nd value of 3rd row
  67368. * @param initialM33 defines 3rd value of 3rd row
  67369. * @param initialM34 defines 4th value of 3rd row
  67370. * @param initialM41 defines 1st value of 4th row
  67371. * @param initialM42 defines 2nd value of 4th row
  67372. * @param initialM43 defines 3rd value of 4th row
  67373. * @param initialM44 defines 4th value of 4th row
  67374. * @returns the new matrix
  67375. */
  67376. 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;
  67377. /**
  67378. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67379. * @param scale defines the scale vector3
  67380. * @param rotation defines the rotation quaternion
  67381. * @param translation defines the translation vector3
  67382. * @returns a new matrix
  67383. */
  67384. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  67385. /**
  67386. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  67387. * @param scale defines the scale vector3
  67388. * @param rotation defines the rotation quaternion
  67389. * @param translation defines the translation vector3
  67390. * @param result defines the target matrix
  67391. */
  67392. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  67393. /**
  67394. * Creates a new identity matrix
  67395. * @returns a new identity matrix
  67396. */
  67397. static Identity(): Matrix;
  67398. /**
  67399. * Creates a new identity matrix and stores the result in a given matrix
  67400. * @param result defines the target matrix
  67401. */
  67402. static IdentityToRef(result: Matrix): void;
  67403. /**
  67404. * Creates a new zero matrix
  67405. * @returns a new zero matrix
  67406. */
  67407. static Zero(): Matrix;
  67408. /**
  67409. * Creates a new rotation matrix for "angle" radians around the X axis
  67410. * @param angle defines the angle (in radians) to use
  67411. * @return the new matrix
  67412. */
  67413. static RotationX(angle: number): Matrix;
  67414. /**
  67415. * Creates a new matrix as the invert of a given matrix
  67416. * @param source defines the source matrix
  67417. * @returns the new matrix
  67418. */
  67419. static Invert(source: DeepImmutable<Matrix>): Matrix;
  67420. /**
  67421. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  67422. * @param angle defines the angle (in radians) to use
  67423. * @param result defines the target matrix
  67424. */
  67425. static RotationXToRef(angle: number, result: Matrix): void;
  67426. /**
  67427. * Creates a new rotation matrix for "angle" radians around the Y axis
  67428. * @param angle defines the angle (in radians) to use
  67429. * @return the new matrix
  67430. */
  67431. static RotationY(angle: number): Matrix;
  67432. /**
  67433. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  67434. * @param angle defines the angle (in radians) to use
  67435. * @param result defines the target matrix
  67436. */
  67437. static RotationYToRef(angle: number, result: Matrix): void;
  67438. /**
  67439. * Creates a new rotation matrix for "angle" radians around the Z axis
  67440. * @param angle defines the angle (in radians) to use
  67441. * @return the new matrix
  67442. */
  67443. static RotationZ(angle: number): Matrix;
  67444. /**
  67445. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  67446. * @param angle defines the angle (in radians) to use
  67447. * @param result defines the target matrix
  67448. */
  67449. static RotationZToRef(angle: number, result: Matrix): void;
  67450. /**
  67451. * Creates a new rotation matrix for "angle" radians around the given axis
  67452. * @param axis defines the axis to use
  67453. * @param angle defines the angle (in radians) to use
  67454. * @return the new matrix
  67455. */
  67456. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  67457. /**
  67458. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  67459. * @param axis defines the axis to use
  67460. * @param angle defines the angle (in radians) to use
  67461. * @param result defines the target matrix
  67462. */
  67463. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  67464. /**
  67465. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  67466. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  67467. * @param from defines the vector to align
  67468. * @param to defines the vector to align to
  67469. * @param result defines the target matrix
  67470. */
  67471. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  67472. /**
  67473. * Creates a rotation matrix
  67474. * @param yaw defines the yaw angle in radians (Y axis)
  67475. * @param pitch defines the pitch angle in radians (X axis)
  67476. * @param roll defines the roll angle in radians (X axis)
  67477. * @returns the new rotation matrix
  67478. */
  67479. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  67480. /**
  67481. * Creates a rotation matrix and stores it in a given matrix
  67482. * @param yaw defines the yaw angle in radians (Y axis)
  67483. * @param pitch defines the pitch angle in radians (X axis)
  67484. * @param roll defines the roll angle in radians (X axis)
  67485. * @param result defines the target matrix
  67486. */
  67487. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  67488. /**
  67489. * Creates a scaling matrix
  67490. * @param x defines the scale factor on X axis
  67491. * @param y defines the scale factor on Y axis
  67492. * @param z defines the scale factor on Z axis
  67493. * @returns the new matrix
  67494. */
  67495. static Scaling(x: number, y: number, z: number): Matrix;
  67496. /**
  67497. * Creates a scaling matrix and stores it in a given matrix
  67498. * @param x defines the scale factor on X axis
  67499. * @param y defines the scale factor on Y axis
  67500. * @param z defines the scale factor on Z axis
  67501. * @param result defines the target matrix
  67502. */
  67503. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  67504. /**
  67505. * Creates a translation matrix
  67506. * @param x defines the translation on X axis
  67507. * @param y defines the translation on Y axis
  67508. * @param z defines the translationon Z axis
  67509. * @returns the new matrix
  67510. */
  67511. static Translation(x: number, y: number, z: number): Matrix;
  67512. /**
  67513. * Creates a translation matrix and stores it in a given matrix
  67514. * @param x defines the translation on X axis
  67515. * @param y defines the translation on Y axis
  67516. * @param z defines the translationon Z axis
  67517. * @param result defines the target matrix
  67518. */
  67519. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  67520. /**
  67521. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67522. * @param startValue defines the start value
  67523. * @param endValue defines the end value
  67524. * @param gradient defines the gradient factor
  67525. * @returns the new matrix
  67526. */
  67527. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67528. /**
  67529. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  67530. * @param startValue defines the start value
  67531. * @param endValue defines the end value
  67532. * @param gradient defines the gradient factor
  67533. * @param result defines the Matrix object where to store data
  67534. */
  67535. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67536. /**
  67537. * Builds a new matrix whose values are computed by:
  67538. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67539. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67540. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67541. * @param startValue defines the first matrix
  67542. * @param endValue defines the second matrix
  67543. * @param gradient defines the gradient between the two matrices
  67544. * @returns the new matrix
  67545. */
  67546. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  67547. /**
  67548. * Update a matrix to values which are computed by:
  67549. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  67550. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  67551. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  67552. * @param startValue defines the first matrix
  67553. * @param endValue defines the second matrix
  67554. * @param gradient defines the gradient between the two matrices
  67555. * @param result defines the target matrix
  67556. */
  67557. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  67558. /**
  67559. * 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"
  67560. * This function works in left handed mode
  67561. * @param eye defines the final position of the entity
  67562. * @param target defines where the entity should look at
  67563. * @param up defines the up vector for the entity
  67564. * @returns the new matrix
  67565. */
  67566. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67567. /**
  67568. * 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".
  67569. * This function works in left handed mode
  67570. * @param eye defines the final position of the entity
  67571. * @param target defines where the entity should look at
  67572. * @param up defines the up vector for the entity
  67573. * @param result defines the target matrix
  67574. */
  67575. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67576. /**
  67577. * 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"
  67578. * This function works in right handed mode
  67579. * @param eye defines the final position of the entity
  67580. * @param target defines where the entity should look at
  67581. * @param up defines the up vector for the entity
  67582. * @returns the new matrix
  67583. */
  67584. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  67585. /**
  67586. * 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".
  67587. * This function works in right handed mode
  67588. * @param eye defines the final position of the entity
  67589. * @param target defines where the entity should look at
  67590. * @param up defines the up vector for the entity
  67591. * @param result defines the target matrix
  67592. */
  67593. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  67594. /**
  67595. * Create a left-handed orthographic projection matrix
  67596. * @param width defines the viewport width
  67597. * @param height defines the viewport height
  67598. * @param znear defines the near clip plane
  67599. * @param zfar defines the far clip plane
  67600. * @returns a new matrix as a left-handed orthographic projection matrix
  67601. */
  67602. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67603. /**
  67604. * Store a left-handed orthographic projection to a given matrix
  67605. * @param width defines the viewport width
  67606. * @param height defines the viewport height
  67607. * @param znear defines the near clip plane
  67608. * @param zfar defines the far clip plane
  67609. * @param result defines the target matrix
  67610. */
  67611. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  67612. /**
  67613. * Create a left-handed orthographic projection matrix
  67614. * @param left defines the viewport left coordinate
  67615. * @param right defines the viewport right coordinate
  67616. * @param bottom defines the viewport bottom coordinate
  67617. * @param top defines the viewport top coordinate
  67618. * @param znear defines the near clip plane
  67619. * @param zfar defines the far clip plane
  67620. * @returns a new matrix as a left-handed orthographic projection matrix
  67621. */
  67622. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67623. /**
  67624. * Stores a left-handed orthographic projection into a given matrix
  67625. * @param left defines the viewport left coordinate
  67626. * @param right defines the viewport right coordinate
  67627. * @param bottom defines the viewport bottom coordinate
  67628. * @param top defines the viewport top coordinate
  67629. * @param znear defines the near clip plane
  67630. * @param zfar defines the far clip plane
  67631. * @param result defines the target matrix
  67632. */
  67633. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67634. /**
  67635. * Creates a right-handed orthographic projection matrix
  67636. * @param left defines the viewport left coordinate
  67637. * @param right defines the viewport right coordinate
  67638. * @param bottom defines the viewport bottom coordinate
  67639. * @param top defines the viewport top coordinate
  67640. * @param znear defines the near clip plane
  67641. * @param zfar defines the far clip plane
  67642. * @returns a new matrix as a right-handed orthographic projection matrix
  67643. */
  67644. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  67645. /**
  67646. * Stores a right-handed orthographic projection into a given matrix
  67647. * @param left defines the viewport left coordinate
  67648. * @param right defines the viewport right coordinate
  67649. * @param bottom defines the viewport bottom coordinate
  67650. * @param top defines the viewport top coordinate
  67651. * @param znear defines the near clip plane
  67652. * @param zfar defines the far clip plane
  67653. * @param result defines the target matrix
  67654. */
  67655. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  67656. /**
  67657. * Creates a left-handed perspective projection matrix
  67658. * @param width defines the viewport width
  67659. * @param height defines the viewport height
  67660. * @param znear defines the near clip plane
  67661. * @param zfar defines the far clip plane
  67662. * @returns a new matrix as a left-handed perspective projection matrix
  67663. */
  67664. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  67665. /**
  67666. * Creates a left-handed perspective projection matrix
  67667. * @param fov defines the horizontal field of view
  67668. * @param aspect defines the aspect ratio
  67669. * @param znear defines the near clip plane
  67670. * @param zfar defines the far clip plane
  67671. * @returns a new matrix as a left-handed perspective projection matrix
  67672. */
  67673. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67674. /**
  67675. * Stores a left-handed perspective projection into a given matrix
  67676. * @param fov defines the horizontal field of view
  67677. * @param aspect defines the aspect ratio
  67678. * @param znear defines the near clip plane
  67679. * @param zfar defines the far clip plane
  67680. * @param result defines the target matrix
  67681. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67682. */
  67683. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67684. /**
  67685. * Creates a right-handed perspective projection matrix
  67686. * @param fov defines the horizontal field of view
  67687. * @param aspect defines the aspect ratio
  67688. * @param znear defines the near clip plane
  67689. * @param zfar defines the far clip plane
  67690. * @returns a new matrix as a right-handed perspective projection matrix
  67691. */
  67692. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  67693. /**
  67694. * Stores a right-handed perspective projection into a given matrix
  67695. * @param fov defines the horizontal field of view
  67696. * @param aspect defines the aspect ratio
  67697. * @param znear defines the near clip plane
  67698. * @param zfar defines the far clip plane
  67699. * @param result defines the target matrix
  67700. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  67701. */
  67702. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  67703. /**
  67704. * Stores a perspective projection for WebVR info a given matrix
  67705. * @param fov defines the field of view
  67706. * @param znear defines the near clip plane
  67707. * @param zfar defines the far clip plane
  67708. * @param result defines the target matrix
  67709. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  67710. */
  67711. static PerspectiveFovWebVRToRef(fov: {
  67712. upDegrees: number;
  67713. downDegrees: number;
  67714. leftDegrees: number;
  67715. rightDegrees: number;
  67716. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  67717. /**
  67718. * Computes a complete transformation matrix
  67719. * @param viewport defines the viewport to use
  67720. * @param world defines the world matrix
  67721. * @param view defines the view matrix
  67722. * @param projection defines the projection matrix
  67723. * @param zmin defines the near clip plane
  67724. * @param zmax defines the far clip plane
  67725. * @returns the transformation matrix
  67726. */
  67727. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  67728. /**
  67729. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  67730. * @param matrix defines the matrix to use
  67731. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  67732. */
  67733. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  67734. /**
  67735. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  67736. * @param matrix defines the matrix to use
  67737. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  67738. */
  67739. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  67740. /**
  67741. * Compute the transpose of a given matrix
  67742. * @param matrix defines the matrix to transpose
  67743. * @returns the new matrix
  67744. */
  67745. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  67746. /**
  67747. * Compute the transpose of a matrix and store it in a target matrix
  67748. * @param matrix defines the matrix to transpose
  67749. * @param result defines the target matrix
  67750. */
  67751. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  67752. /**
  67753. * Computes a reflection matrix from a plane
  67754. * @param plane defines the reflection plane
  67755. * @returns a new matrix
  67756. */
  67757. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  67758. /**
  67759. * Computes a reflection matrix from a plane
  67760. * @param plane defines the reflection plane
  67761. * @param result defines the target matrix
  67762. */
  67763. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  67764. /**
  67765. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  67766. * @param xaxis defines the value of the 1st axis
  67767. * @param yaxis defines the value of the 2nd axis
  67768. * @param zaxis defines the value of the 3rd axis
  67769. * @param result defines the target matrix
  67770. */
  67771. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  67772. /**
  67773. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  67774. * @param quat defines the quaternion to use
  67775. * @param result defines the target matrix
  67776. */
  67777. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  67778. }
  67779. /**
  67780. * @hidden
  67781. */
  67782. export class TmpVectors {
  67783. static Vector2: Vector2[];
  67784. static Vector3: Vector3[];
  67785. static Vector4: Vector4[];
  67786. static Quaternion: Quaternion[];
  67787. static Matrix: Matrix[];
  67788. }
  67789. }
  67790. declare module BABYLON {
  67791. /** Defines the cross module used constants to avoid circular dependncies */
  67792. export class Constants {
  67793. /** Defines that alpha blending is disabled */
  67794. static readonly ALPHA_DISABLE: number;
  67795. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67796. static readonly ALPHA_ADD: number;
  67797. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67798. static readonly ALPHA_COMBINE: number;
  67799. /** Defines that alpha blending to DEST - SRC * DEST */
  67800. static readonly ALPHA_SUBTRACT: number;
  67801. /** Defines that alpha blending to SRC * DEST */
  67802. static readonly ALPHA_MULTIPLY: number;
  67803. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67804. static readonly ALPHA_MAXIMIZED: number;
  67805. /** Defines that alpha blending to SRC + DEST */
  67806. static readonly ALPHA_ONEONE: number;
  67807. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67808. static readonly ALPHA_PREMULTIPLIED: number;
  67809. /**
  67810. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67811. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67812. */
  67813. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67814. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67815. static readonly ALPHA_INTERPOLATE: number;
  67816. /**
  67817. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67818. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67819. */
  67820. static readonly ALPHA_SCREENMODE: number;
  67821. /** Defines that the ressource is not delayed*/
  67822. static readonly DELAYLOADSTATE_NONE: number;
  67823. /** Defines that the ressource was successfully delay loaded */
  67824. static readonly DELAYLOADSTATE_LOADED: number;
  67825. /** Defines that the ressource is currently delay loading */
  67826. static readonly DELAYLOADSTATE_LOADING: number;
  67827. /** Defines that the ressource is delayed and has not started loading */
  67828. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67830. static readonly NEVER: number;
  67831. /** 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 */
  67832. static readonly ALWAYS: number;
  67833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67834. static readonly LESS: number;
  67835. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67836. static readonly EQUAL: number;
  67837. /** 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 */
  67838. static readonly LEQUAL: number;
  67839. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67840. static readonly GREATER: number;
  67841. /** 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 */
  67842. static readonly GEQUAL: number;
  67843. /** 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 */
  67844. static readonly NOTEQUAL: number;
  67845. /** Passed to stencilOperation to specify that stencil value must be kept */
  67846. static readonly KEEP: number;
  67847. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67848. static readonly REPLACE: number;
  67849. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67850. static readonly INCR: number;
  67851. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67852. static readonly DECR: number;
  67853. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67854. static readonly INVERT: number;
  67855. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67856. static readonly INCR_WRAP: number;
  67857. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67858. static readonly DECR_WRAP: number;
  67859. /** Texture is not repeating outside of 0..1 UVs */
  67860. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67861. /** Texture is repeating outside of 0..1 UVs */
  67862. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67863. /** Texture is repeating and mirrored */
  67864. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67865. /** ALPHA */
  67866. static readonly TEXTUREFORMAT_ALPHA: number;
  67867. /** LUMINANCE */
  67868. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67869. /** LUMINANCE_ALPHA */
  67870. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67871. /** RGB */
  67872. static readonly TEXTUREFORMAT_RGB: number;
  67873. /** RGBA */
  67874. static readonly TEXTUREFORMAT_RGBA: number;
  67875. /** RED */
  67876. static readonly TEXTUREFORMAT_RED: number;
  67877. /** RED (2nd reference) */
  67878. static readonly TEXTUREFORMAT_R: number;
  67879. /** RG */
  67880. static readonly TEXTUREFORMAT_RG: number;
  67881. /** RED_INTEGER */
  67882. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67883. /** RED_INTEGER (2nd reference) */
  67884. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67885. /** RG_INTEGER */
  67886. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67887. /** RGB_INTEGER */
  67888. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67889. /** RGBA_INTEGER */
  67890. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67891. /** UNSIGNED_BYTE */
  67892. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67893. /** UNSIGNED_BYTE (2nd reference) */
  67894. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67895. /** FLOAT */
  67896. static readonly TEXTURETYPE_FLOAT: number;
  67897. /** HALF_FLOAT */
  67898. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67899. /** BYTE */
  67900. static readonly TEXTURETYPE_BYTE: number;
  67901. /** SHORT */
  67902. static readonly TEXTURETYPE_SHORT: number;
  67903. /** UNSIGNED_SHORT */
  67904. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67905. /** INT */
  67906. static readonly TEXTURETYPE_INT: number;
  67907. /** UNSIGNED_INT */
  67908. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67909. /** UNSIGNED_SHORT_4_4_4_4 */
  67910. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67911. /** UNSIGNED_SHORT_5_5_5_1 */
  67912. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67913. /** UNSIGNED_SHORT_5_6_5 */
  67914. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67915. /** UNSIGNED_INT_2_10_10_10_REV */
  67916. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67917. /** UNSIGNED_INT_24_8 */
  67918. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67919. /** UNSIGNED_INT_10F_11F_11F_REV */
  67920. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67921. /** UNSIGNED_INT_5_9_9_9_REV */
  67922. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67923. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67924. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67925. /** nearest is mag = nearest and min = nearest and mip = linear */
  67926. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67927. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67928. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67929. /** Trilinear is mag = linear and min = linear and mip = linear */
  67930. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67931. /** nearest is mag = nearest and min = nearest and mip = linear */
  67932. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67933. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67934. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67935. /** Trilinear is mag = linear and min = linear and mip = linear */
  67936. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67937. /** mag = nearest and min = nearest and mip = nearest */
  67938. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67939. /** mag = nearest and min = linear and mip = nearest */
  67940. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67941. /** mag = nearest and min = linear and mip = linear */
  67942. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67943. /** mag = nearest and min = linear and mip = none */
  67944. static readonly TEXTURE_NEAREST_LINEAR: number;
  67945. /** mag = nearest and min = nearest and mip = none */
  67946. static readonly TEXTURE_NEAREST_NEAREST: number;
  67947. /** mag = linear and min = nearest and mip = nearest */
  67948. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67949. /** mag = linear and min = nearest and mip = linear */
  67950. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67951. /** mag = linear and min = linear and mip = none */
  67952. static readonly TEXTURE_LINEAR_LINEAR: number;
  67953. /** mag = linear and min = nearest and mip = none */
  67954. static readonly TEXTURE_LINEAR_NEAREST: number;
  67955. /** Explicit coordinates mode */
  67956. static readonly TEXTURE_EXPLICIT_MODE: number;
  67957. /** Spherical coordinates mode */
  67958. static readonly TEXTURE_SPHERICAL_MODE: number;
  67959. /** Planar coordinates mode */
  67960. static readonly TEXTURE_PLANAR_MODE: number;
  67961. /** Cubic coordinates mode */
  67962. static readonly TEXTURE_CUBIC_MODE: number;
  67963. /** Projection coordinates mode */
  67964. static readonly TEXTURE_PROJECTION_MODE: number;
  67965. /** Skybox coordinates mode */
  67966. static readonly TEXTURE_SKYBOX_MODE: number;
  67967. /** Inverse Cubic coordinates mode */
  67968. static readonly TEXTURE_INVCUBIC_MODE: number;
  67969. /** Equirectangular coordinates mode */
  67970. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67971. /** Equirectangular Fixed coordinates mode */
  67972. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67973. /** Equirectangular Fixed Mirrored coordinates mode */
  67974. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67975. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67976. static readonly SCALEMODE_FLOOR: number;
  67977. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67978. static readonly SCALEMODE_NEAREST: number;
  67979. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67980. static readonly SCALEMODE_CEILING: number;
  67981. /**
  67982. * The dirty texture flag value
  67983. */
  67984. static readonly MATERIAL_TextureDirtyFlag: number;
  67985. /**
  67986. * The dirty light flag value
  67987. */
  67988. static readonly MATERIAL_LightDirtyFlag: number;
  67989. /**
  67990. * The dirty fresnel flag value
  67991. */
  67992. static readonly MATERIAL_FresnelDirtyFlag: number;
  67993. /**
  67994. * The dirty attribute flag value
  67995. */
  67996. static readonly MATERIAL_AttributesDirtyFlag: number;
  67997. /**
  67998. * The dirty misc flag value
  67999. */
  68000. static readonly MATERIAL_MiscDirtyFlag: number;
  68001. /**
  68002. * The all dirty flag value
  68003. */
  68004. static readonly MATERIAL_AllDirtyFlag: number;
  68005. /**
  68006. * Returns the triangle fill mode
  68007. */
  68008. static readonly MATERIAL_TriangleFillMode: number;
  68009. /**
  68010. * Returns the wireframe mode
  68011. */
  68012. static readonly MATERIAL_WireFrameFillMode: number;
  68013. /**
  68014. * Returns the point fill mode
  68015. */
  68016. static readonly MATERIAL_PointFillMode: number;
  68017. /**
  68018. * Returns the point list draw mode
  68019. */
  68020. static readonly MATERIAL_PointListDrawMode: number;
  68021. /**
  68022. * Returns the line list draw mode
  68023. */
  68024. static readonly MATERIAL_LineListDrawMode: number;
  68025. /**
  68026. * Returns the line loop draw mode
  68027. */
  68028. static readonly MATERIAL_LineLoopDrawMode: number;
  68029. /**
  68030. * Returns the line strip draw mode
  68031. */
  68032. static readonly MATERIAL_LineStripDrawMode: number;
  68033. /**
  68034. * Returns the triangle strip draw mode
  68035. */
  68036. static readonly MATERIAL_TriangleStripDrawMode: number;
  68037. /**
  68038. * Returns the triangle fan draw mode
  68039. */
  68040. static readonly MATERIAL_TriangleFanDrawMode: number;
  68041. /**
  68042. * Stores the clock-wise side orientation
  68043. */
  68044. static readonly MATERIAL_ClockWiseSideOrientation: number;
  68045. /**
  68046. * Stores the counter clock-wise side orientation
  68047. */
  68048. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  68049. /**
  68050. * Nothing
  68051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68052. */
  68053. static readonly ACTION_NothingTrigger: number;
  68054. /**
  68055. * On pick
  68056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68057. */
  68058. static readonly ACTION_OnPickTrigger: number;
  68059. /**
  68060. * On left pick
  68061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68062. */
  68063. static readonly ACTION_OnLeftPickTrigger: number;
  68064. /**
  68065. * On right pick
  68066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68067. */
  68068. static readonly ACTION_OnRightPickTrigger: number;
  68069. /**
  68070. * On center pick
  68071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68072. */
  68073. static readonly ACTION_OnCenterPickTrigger: number;
  68074. /**
  68075. * On pick down
  68076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68077. */
  68078. static readonly ACTION_OnPickDownTrigger: number;
  68079. /**
  68080. * On double pick
  68081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68082. */
  68083. static readonly ACTION_OnDoublePickTrigger: number;
  68084. /**
  68085. * On pick up
  68086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68087. */
  68088. static readonly ACTION_OnPickUpTrigger: number;
  68089. /**
  68090. * On pick out.
  68091. * This trigger will only be raised if you also declared a OnPickDown
  68092. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68093. */
  68094. static readonly ACTION_OnPickOutTrigger: number;
  68095. /**
  68096. * On long press
  68097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68098. */
  68099. static readonly ACTION_OnLongPressTrigger: number;
  68100. /**
  68101. * On pointer over
  68102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68103. */
  68104. static readonly ACTION_OnPointerOverTrigger: number;
  68105. /**
  68106. * On pointer out
  68107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68108. */
  68109. static readonly ACTION_OnPointerOutTrigger: number;
  68110. /**
  68111. * On every frame
  68112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68113. */
  68114. static readonly ACTION_OnEveryFrameTrigger: number;
  68115. /**
  68116. * On intersection enter
  68117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68118. */
  68119. static readonly ACTION_OnIntersectionEnterTrigger: number;
  68120. /**
  68121. * On intersection exit
  68122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68123. */
  68124. static readonly ACTION_OnIntersectionExitTrigger: number;
  68125. /**
  68126. * On key down
  68127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68128. */
  68129. static readonly ACTION_OnKeyDownTrigger: number;
  68130. /**
  68131. * On key up
  68132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  68133. */
  68134. static readonly ACTION_OnKeyUpTrigger: number;
  68135. /**
  68136. * Billboard mode will only apply to Y axis
  68137. */
  68138. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  68139. /**
  68140. * Billboard mode will apply to all axes
  68141. */
  68142. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  68143. /**
  68144. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  68145. */
  68146. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  68147. /**
  68148. * Gets or sets base Assets URL
  68149. */
  68150. static PARTICLES_BaseAssetsUrl: string;
  68151. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  68152. * Test order :
  68153. * Is the bounding sphere outside the frustum ?
  68154. * If not, are the bounding box vertices outside the frustum ?
  68155. * It not, then the cullable object is in the frustum.
  68156. */
  68157. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  68158. /** Culling strategy : Bounding Sphere Only.
  68159. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  68160. * It's also less accurate than the standard because some not visible objects can still be selected.
  68161. * Test : is the bounding sphere outside the frustum ?
  68162. * If not, then the cullable object is in the frustum.
  68163. */
  68164. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  68165. /** Culling strategy : Optimistic Inclusion.
  68166. * This in an inclusion test first, then the standard exclusion test.
  68167. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  68168. * 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.
  68169. * Anyway, it's as accurate as the standard strategy.
  68170. * Test :
  68171. * Is the cullable object bounding sphere center in the frustum ?
  68172. * If not, apply the default culling strategy.
  68173. */
  68174. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  68175. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  68176. * This in an inclusion test first, then the bounding sphere only exclusion test.
  68177. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  68178. * 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.
  68179. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  68180. * Test :
  68181. * Is the cullable object bounding sphere center in the frustum ?
  68182. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  68183. */
  68184. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  68185. /**
  68186. * No logging while loading
  68187. */
  68188. static readonly SCENELOADER_NO_LOGGING: number;
  68189. /**
  68190. * Minimal logging while loading
  68191. */
  68192. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  68193. /**
  68194. * Summary logging while loading
  68195. */
  68196. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  68197. /**
  68198. * Detailled logging while loading
  68199. */
  68200. static readonly SCENELOADER_DETAILED_LOGGING: number;
  68201. }
  68202. }
  68203. declare module BABYLON {
  68204. /**
  68205. * Class used to store and describe the pipeline context associated with an effect
  68206. */
  68207. export interface IPipelineContext {
  68208. /**
  68209. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  68210. */
  68211. isAsync: boolean;
  68212. /**
  68213. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  68214. */
  68215. isReady: boolean;
  68216. /** @hidden */
  68217. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  68218. }
  68219. }
  68220. declare module BABYLON {
  68221. /** @hidden */
  68222. export interface IShaderProcessor {
  68223. attributeProcessor?: (attribute: string) => string;
  68224. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  68225. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  68226. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  68227. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  68228. lineProcessor?: (line: string, isFragment: boolean) => string;
  68229. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68230. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  68231. }
  68232. }
  68233. declare module BABYLON {
  68234. /** @hidden */
  68235. export interface ProcessingOptions {
  68236. defines: string[];
  68237. indexParameters: any;
  68238. isFragment: boolean;
  68239. shouldUseHighPrecisionShader: boolean;
  68240. supportsUniformBuffers: boolean;
  68241. shadersRepository: string;
  68242. includesShadersStore: {
  68243. [key: string]: string;
  68244. };
  68245. processor?: IShaderProcessor;
  68246. version: string;
  68247. platformName: string;
  68248. lookForClosingBracketForUniformBuffer?: boolean;
  68249. }
  68250. }
  68251. declare module BABYLON {
  68252. /**
  68253. * Helper to manipulate strings
  68254. */
  68255. export class StringTools {
  68256. /**
  68257. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  68258. * @param str Source string
  68259. * @param suffix Suffix to search for in the source string
  68260. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68261. */
  68262. static EndsWith(str: string, suffix: string): boolean;
  68263. /**
  68264. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  68265. * @param str Source string
  68266. * @param suffix Suffix to search for in the source string
  68267. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  68268. */
  68269. static StartsWith(str: string, suffix: string): boolean;
  68270. }
  68271. }
  68272. declare module BABYLON {
  68273. /** @hidden */
  68274. export class ShaderCodeNode {
  68275. line: string;
  68276. children: ShaderCodeNode[];
  68277. additionalDefineKey?: string;
  68278. additionalDefineValue?: string;
  68279. isValid(preprocessors: {
  68280. [key: string]: string;
  68281. }): boolean;
  68282. process(preprocessors: {
  68283. [key: string]: string;
  68284. }, options: ProcessingOptions): string;
  68285. }
  68286. }
  68287. declare module BABYLON {
  68288. /** @hidden */
  68289. export class ShaderCodeCursor {
  68290. private _lines;
  68291. lineIndex: number;
  68292. readonly currentLine: string;
  68293. readonly canRead: boolean;
  68294. lines: string[];
  68295. }
  68296. }
  68297. declare module BABYLON {
  68298. /** @hidden */
  68299. export class ShaderCodeConditionNode extends ShaderCodeNode {
  68300. process(preprocessors: {
  68301. [key: string]: string;
  68302. }, options: ProcessingOptions): string;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /** @hidden */
  68307. export class ShaderDefineExpression {
  68308. isTrue(preprocessors: {
  68309. [key: string]: string;
  68310. }): boolean;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /** @hidden */
  68315. export class ShaderCodeTestNode extends ShaderCodeNode {
  68316. testExpression: ShaderDefineExpression;
  68317. isValid(preprocessors: {
  68318. [key: string]: string;
  68319. }): boolean;
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /** @hidden */
  68324. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68325. define: string;
  68326. not: boolean;
  68327. constructor(define: string, not?: boolean);
  68328. isTrue(preprocessors: {
  68329. [key: string]: string;
  68330. }): boolean;
  68331. }
  68332. }
  68333. declare module BABYLON {
  68334. /** @hidden */
  68335. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68336. leftOperand: ShaderDefineExpression;
  68337. rightOperand: ShaderDefineExpression;
  68338. isTrue(preprocessors: {
  68339. [key: string]: string;
  68340. }): boolean;
  68341. }
  68342. }
  68343. declare module BABYLON {
  68344. /** @hidden */
  68345. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68346. leftOperand: ShaderDefineExpression;
  68347. rightOperand: ShaderDefineExpression;
  68348. isTrue(preprocessors: {
  68349. [key: string]: string;
  68350. }): boolean;
  68351. }
  68352. }
  68353. declare module BABYLON {
  68354. /** @hidden */
  68355. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68356. define: string;
  68357. operand: string;
  68358. testValue: string;
  68359. constructor(define: string, operand: string, testValue: string);
  68360. isTrue(preprocessors: {
  68361. [key: string]: string;
  68362. }): boolean;
  68363. }
  68364. }
  68365. declare module BABYLON {
  68366. /**
  68367. * @ignore
  68368. * Application error to support additional information when loading a file
  68369. */
  68370. export class LoadFileError extends Error {
  68371. /** defines the optional web request */
  68372. request?: WebRequest | undefined;
  68373. private static _setPrototypeOf;
  68374. /**
  68375. * Creates a new LoadFileError
  68376. * @param message defines the message of the error
  68377. * @param request defines the optional web request
  68378. */
  68379. constructor(message: string,
  68380. /** defines the optional web request */
  68381. request?: WebRequest | undefined);
  68382. }
  68383. }
  68384. declare module BABYLON {
  68385. /**
  68386. * Class used to enable access to offline support
  68387. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68388. */
  68389. export interface IOfflineProvider {
  68390. /**
  68391. * Gets a boolean indicating if scene must be saved in the database
  68392. */
  68393. enableSceneOffline: boolean;
  68394. /**
  68395. * Gets a boolean indicating if textures must be saved in the database
  68396. */
  68397. enableTexturesOffline: boolean;
  68398. /**
  68399. * Open the offline support and make it available
  68400. * @param successCallback defines the callback to call on success
  68401. * @param errorCallback defines the callback to call on error
  68402. */
  68403. open(successCallback: () => void, errorCallback: () => void): void;
  68404. /**
  68405. * Loads an image from the offline support
  68406. * @param url defines the url to load from
  68407. * @param image defines the target DOM image
  68408. */
  68409. loadImage(url: string, image: HTMLImageElement): void;
  68410. /**
  68411. * Loads a file from offline support
  68412. * @param url defines the URL to load from
  68413. * @param sceneLoaded defines a callback to call on success
  68414. * @param progressCallBack defines a callback to call when progress changed
  68415. * @param errorCallback defines a callback to call on error
  68416. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68417. */
  68418. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68419. }
  68420. }
  68421. declare module BABYLON {
  68422. /**
  68423. * Class used to help managing file picking and drag'n'drop
  68424. * File Storage
  68425. */
  68426. export class FilesInputStore {
  68427. /**
  68428. * List of files ready to be loaded
  68429. */
  68430. static FilesToLoad: {
  68431. [key: string]: File;
  68432. };
  68433. }
  68434. }
  68435. declare module BABYLON {
  68436. /**
  68437. * Class used to define a retry strategy when error happens while loading assets
  68438. */
  68439. export class RetryStrategy {
  68440. /**
  68441. * Function used to defines an exponential back off strategy
  68442. * @param maxRetries defines the maximum number of retries (3 by default)
  68443. * @param baseInterval defines the interval between retries
  68444. * @returns the strategy function to use
  68445. */
  68446. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68447. }
  68448. }
  68449. declare module BABYLON {
  68450. /**
  68451. * @hidden
  68452. */
  68453. export class FileTools {
  68454. /**
  68455. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68456. */
  68457. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68458. /**
  68459. * Gets or sets the base URL to use to load assets
  68460. */
  68461. static BaseUrl: string;
  68462. /**
  68463. * Default behaviour for cors in the application.
  68464. * It can be a string if the expected behavior is identical in the entire app.
  68465. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68466. */
  68467. static CorsBehavior: string | ((url: string | string[]) => string);
  68468. /**
  68469. * Gets or sets a function used to pre-process url before using them to load assets
  68470. */
  68471. static PreprocessUrl: (url: string) => string;
  68472. /**
  68473. * Removes unwanted characters from an url
  68474. * @param url defines the url to clean
  68475. * @returns the cleaned url
  68476. */
  68477. private static _CleanUrl;
  68478. /**
  68479. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68480. * @param url define the url we are trying
  68481. * @param element define the dom element where to configure the cors policy
  68482. */
  68483. static SetCorsBehavior(url: string | string[], element: {
  68484. crossOrigin: string | null;
  68485. }): void;
  68486. /**
  68487. * Loads an image as an HTMLImageElement.
  68488. * @param input url string, ArrayBuffer, or Blob to load
  68489. * @param onLoad callback called when the image successfully loads
  68490. * @param onError callback called when the image fails to load
  68491. * @param offlineProvider offline provider for caching
  68492. * @returns the HTMLImageElement of the loaded image
  68493. */
  68494. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68495. /**
  68496. * Loads a file
  68497. * @param fileToLoad defines the file to load
  68498. * @param callback defines the callback to call when data is loaded
  68499. * @param progressCallBack defines the callback to call during loading process
  68500. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68501. * @returns a file request object
  68502. */
  68503. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68504. /**
  68505. * Loads a file
  68506. * @param url url string, ArrayBuffer, or Blob to load
  68507. * @param onSuccess callback called when the file successfully loads
  68508. * @param onProgress callback called while file is loading (if the server supports this mode)
  68509. * @param offlineProvider defines the offline provider for caching
  68510. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68511. * @param onError callback called when the file fails to load
  68512. * @returns a file request object
  68513. */
  68514. 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;
  68515. /**
  68516. * Checks if the loaded document was accessed via `file:`-Protocol.
  68517. * @returns boolean
  68518. */
  68519. static IsFileURL(): boolean;
  68520. }
  68521. }
  68522. declare module BABYLON {
  68523. /** @hidden */
  68524. export class ShaderProcessor {
  68525. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68526. private static _ProcessPrecision;
  68527. private static _ExtractOperation;
  68528. private static _BuildSubExpression;
  68529. private static _BuildExpression;
  68530. private static _MoveCursorWithinIf;
  68531. private static _MoveCursor;
  68532. private static _EvaluatePreProcessors;
  68533. private static _PreparePreProcessors;
  68534. private static _ProcessShaderConversion;
  68535. private static _ProcessIncludes;
  68536. }
  68537. }
  68538. declare module BABYLON {
  68539. /**
  68540. * Class used to hold a RBG color
  68541. */
  68542. export class Color3 {
  68543. /**
  68544. * Defines the red component (between 0 and 1, default is 0)
  68545. */
  68546. r: number;
  68547. /**
  68548. * Defines the green component (between 0 and 1, default is 0)
  68549. */
  68550. g: number;
  68551. /**
  68552. * Defines the blue component (between 0 and 1, default is 0)
  68553. */
  68554. b: number;
  68555. /**
  68556. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68557. * @param r defines the red component (between 0 and 1, default is 0)
  68558. * @param g defines the green component (between 0 and 1, default is 0)
  68559. * @param b defines the blue component (between 0 and 1, default is 0)
  68560. */
  68561. constructor(
  68562. /**
  68563. * Defines the red component (between 0 and 1, default is 0)
  68564. */
  68565. r?: number,
  68566. /**
  68567. * Defines the green component (between 0 and 1, default is 0)
  68568. */
  68569. g?: number,
  68570. /**
  68571. * Defines the blue component (between 0 and 1, default is 0)
  68572. */
  68573. b?: number);
  68574. /**
  68575. * Creates a string with the Color3 current values
  68576. * @returns the string representation of the Color3 object
  68577. */
  68578. toString(): string;
  68579. /**
  68580. * Returns the string "Color3"
  68581. * @returns "Color3"
  68582. */
  68583. getClassName(): string;
  68584. /**
  68585. * Compute the Color3 hash code
  68586. * @returns an unique number that can be used to hash Color3 objects
  68587. */
  68588. getHashCode(): number;
  68589. /**
  68590. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68591. * @param array defines the array where to store the r,g,b components
  68592. * @param index defines an optional index in the target array to define where to start storing values
  68593. * @returns the current Color3 object
  68594. */
  68595. toArray(array: FloatArray, index?: number): Color3;
  68596. /**
  68597. * Returns a new Color4 object from the current Color3 and the given alpha
  68598. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68599. * @returns a new Color4 object
  68600. */
  68601. toColor4(alpha?: number): Color4;
  68602. /**
  68603. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68604. * @returns the new array
  68605. */
  68606. asArray(): number[];
  68607. /**
  68608. * Returns the luminance value
  68609. * @returns a float value
  68610. */
  68611. toLuminance(): number;
  68612. /**
  68613. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68614. * @param otherColor defines the second operand
  68615. * @returns the new Color3 object
  68616. */
  68617. multiply(otherColor: DeepImmutable<Color3>): Color3;
  68618. /**
  68619. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68620. * @param otherColor defines the second operand
  68621. * @param result defines the Color3 object where to store the result
  68622. * @returns the current Color3
  68623. */
  68624. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68625. /**
  68626. * Determines equality between Color3 objects
  68627. * @param otherColor defines the second operand
  68628. * @returns true if the rgb values are equal to the given ones
  68629. */
  68630. equals(otherColor: DeepImmutable<Color3>): boolean;
  68631. /**
  68632. * Determines equality between the current Color3 object and a set of r,b,g values
  68633. * @param r defines the red component to check
  68634. * @param g defines the green component to check
  68635. * @param b defines the blue component to check
  68636. * @returns true if the rgb values are equal to the given ones
  68637. */
  68638. equalsFloats(r: number, g: number, b: number): boolean;
  68639. /**
  68640. * Multiplies in place each rgb value by scale
  68641. * @param scale defines the scaling factor
  68642. * @returns the updated Color3
  68643. */
  68644. scale(scale: number): Color3;
  68645. /**
  68646. * Multiplies the rgb values by scale and stores the result into "result"
  68647. * @param scale defines the scaling factor
  68648. * @param result defines the Color3 object where to store the result
  68649. * @returns the unmodified current Color3
  68650. */
  68651. scaleToRef(scale: number, result: Color3): Color3;
  68652. /**
  68653. * Scale the current Color3 values by a factor and add the result to a given Color3
  68654. * @param scale defines the scale factor
  68655. * @param result defines color to store the result into
  68656. * @returns the unmodified current Color3
  68657. */
  68658. scaleAndAddToRef(scale: number, result: Color3): Color3;
  68659. /**
  68660. * Clamps the rgb values by the min and max values and stores the result into "result"
  68661. * @param min defines minimum clamping value (default is 0)
  68662. * @param max defines maximum clamping value (default is 1)
  68663. * @param result defines color to store the result into
  68664. * @returns the original Color3
  68665. */
  68666. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  68667. /**
  68668. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68669. * @param otherColor defines the second operand
  68670. * @returns the new Color3
  68671. */
  68672. add(otherColor: DeepImmutable<Color3>): Color3;
  68673. /**
  68674. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68675. * @param otherColor defines the second operand
  68676. * @param result defines Color3 object to store the result into
  68677. * @returns the unmodified current Color3
  68678. */
  68679. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68680. /**
  68681. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68682. * @param otherColor defines the second operand
  68683. * @returns the new Color3
  68684. */
  68685. subtract(otherColor: DeepImmutable<Color3>): Color3;
  68686. /**
  68687. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68688. * @param otherColor defines the second operand
  68689. * @param result defines Color3 object to store the result into
  68690. * @returns the unmodified current Color3
  68691. */
  68692. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  68693. /**
  68694. * Copy the current object
  68695. * @returns a new Color3 copied the current one
  68696. */
  68697. clone(): Color3;
  68698. /**
  68699. * Copies the rgb values from the source in the current Color3
  68700. * @param source defines the source Color3 object
  68701. * @returns the updated Color3 object
  68702. */
  68703. copyFrom(source: DeepImmutable<Color3>): Color3;
  68704. /**
  68705. * Updates the Color3 rgb values from the given floats
  68706. * @param r defines the red component to read from
  68707. * @param g defines the green component to read from
  68708. * @param b defines the blue component to read from
  68709. * @returns the current Color3 object
  68710. */
  68711. copyFromFloats(r: number, g: number, b: number): Color3;
  68712. /**
  68713. * Updates the Color3 rgb values from the given floats
  68714. * @param r defines the red component to read from
  68715. * @param g defines the green component to read from
  68716. * @param b defines the blue component to read from
  68717. * @returns the current Color3 object
  68718. */
  68719. set(r: number, g: number, b: number): Color3;
  68720. /**
  68721. * Compute the Color3 hexadecimal code as a string
  68722. * @returns a string containing the hexadecimal representation of the Color3 object
  68723. */
  68724. toHexString(): string;
  68725. /**
  68726. * Computes a new Color3 converted from the current one to linear space
  68727. * @returns a new Color3 object
  68728. */
  68729. toLinearSpace(): Color3;
  68730. /**
  68731. * Converts current color in rgb space to HSV values
  68732. * @returns a new color3 representing the HSV values
  68733. */
  68734. toHSV(): Color3;
  68735. /**
  68736. * Converts current color in rgb space to HSV values
  68737. * @param result defines the Color3 where to store the HSV values
  68738. */
  68739. toHSVToRef(result: Color3): void;
  68740. /**
  68741. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68742. * @param convertedColor defines the Color3 object where to store the linear space version
  68743. * @returns the unmodified Color3
  68744. */
  68745. toLinearSpaceToRef(convertedColor: Color3): Color3;
  68746. /**
  68747. * Computes a new Color3 converted from the current one to gamma space
  68748. * @returns a new Color3 object
  68749. */
  68750. toGammaSpace(): Color3;
  68751. /**
  68752. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68753. * @param convertedColor defines the Color3 object where to store the gamma space version
  68754. * @returns the unmodified Color3
  68755. */
  68756. toGammaSpaceToRef(convertedColor: Color3): Color3;
  68757. private static _BlackReadOnly;
  68758. /**
  68759. * Convert Hue, saturation and value to a Color3 (RGB)
  68760. * @param hue defines the hue
  68761. * @param saturation defines the saturation
  68762. * @param value defines the value
  68763. * @param result defines the Color3 where to store the RGB values
  68764. */
  68765. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  68766. /**
  68767. * Creates a new Color3 from the string containing valid hexadecimal values
  68768. * @param hex defines a string containing valid hexadecimal values
  68769. * @returns a new Color3 object
  68770. */
  68771. static FromHexString(hex: string): Color3;
  68772. /**
  68773. * Creates a new Color3 from the starting index of the given array
  68774. * @param array defines the source array
  68775. * @param offset defines an offset in the source array
  68776. * @returns a new Color3 object
  68777. */
  68778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  68779. /**
  68780. * Creates a new Color3 from integer values (< 256)
  68781. * @param r defines the red component to read from (value between 0 and 255)
  68782. * @param g defines the green component to read from (value between 0 and 255)
  68783. * @param b defines the blue component to read from (value between 0 and 255)
  68784. * @returns a new Color3 object
  68785. */
  68786. static FromInts(r: number, g: number, b: number): Color3;
  68787. /**
  68788. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68789. * @param start defines the start Color3 value
  68790. * @param end defines the end Color3 value
  68791. * @param amount defines the gradient value between start and end
  68792. * @returns a new Color3 object
  68793. */
  68794. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  68795. /**
  68796. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68797. * @param left defines the start value
  68798. * @param right defines the end value
  68799. * @param amount defines the gradient factor
  68800. * @param result defines the Color3 object where to store the result
  68801. */
  68802. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  68803. /**
  68804. * Returns a Color3 value containing a red color
  68805. * @returns a new Color3 object
  68806. */
  68807. static Red(): Color3;
  68808. /**
  68809. * Returns a Color3 value containing a green color
  68810. * @returns a new Color3 object
  68811. */
  68812. static Green(): Color3;
  68813. /**
  68814. * Returns a Color3 value containing a blue color
  68815. * @returns a new Color3 object
  68816. */
  68817. static Blue(): Color3;
  68818. /**
  68819. * Returns a Color3 value containing a black color
  68820. * @returns a new Color3 object
  68821. */
  68822. static Black(): Color3;
  68823. /**
  68824. * Gets a Color3 value containing a black color that must not be updated
  68825. */
  68826. static readonly BlackReadOnly: DeepImmutable<Color3>;
  68827. /**
  68828. * Returns a Color3 value containing a white color
  68829. * @returns a new Color3 object
  68830. */
  68831. static White(): Color3;
  68832. /**
  68833. * Returns a Color3 value containing a purple color
  68834. * @returns a new Color3 object
  68835. */
  68836. static Purple(): Color3;
  68837. /**
  68838. * Returns a Color3 value containing a magenta color
  68839. * @returns a new Color3 object
  68840. */
  68841. static Magenta(): Color3;
  68842. /**
  68843. * Returns a Color3 value containing a yellow color
  68844. * @returns a new Color3 object
  68845. */
  68846. static Yellow(): Color3;
  68847. /**
  68848. * Returns a Color3 value containing a gray color
  68849. * @returns a new Color3 object
  68850. */
  68851. static Gray(): Color3;
  68852. /**
  68853. * Returns a Color3 value containing a teal color
  68854. * @returns a new Color3 object
  68855. */
  68856. static Teal(): Color3;
  68857. /**
  68858. * Returns a Color3 value containing a random color
  68859. * @returns a new Color3 object
  68860. */
  68861. static Random(): Color3;
  68862. }
  68863. /**
  68864. * Class used to hold a RBGA color
  68865. */
  68866. export class Color4 {
  68867. /**
  68868. * Defines the red component (between 0 and 1, default is 0)
  68869. */
  68870. r: number;
  68871. /**
  68872. * Defines the green component (between 0 and 1, default is 0)
  68873. */
  68874. g: number;
  68875. /**
  68876. * Defines the blue component (between 0 and 1, default is 0)
  68877. */
  68878. b: number;
  68879. /**
  68880. * Defines the alpha component (between 0 and 1, default is 1)
  68881. */
  68882. a: number;
  68883. /**
  68884. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68885. * @param r defines the red component (between 0 and 1, default is 0)
  68886. * @param g defines the green component (between 0 and 1, default is 0)
  68887. * @param b defines the blue component (between 0 and 1, default is 0)
  68888. * @param a defines the alpha component (between 0 and 1, default is 1)
  68889. */
  68890. constructor(
  68891. /**
  68892. * Defines the red component (between 0 and 1, default is 0)
  68893. */
  68894. r?: number,
  68895. /**
  68896. * Defines the green component (between 0 and 1, default is 0)
  68897. */
  68898. g?: number,
  68899. /**
  68900. * Defines the blue component (between 0 and 1, default is 0)
  68901. */
  68902. b?: number,
  68903. /**
  68904. * Defines the alpha component (between 0 and 1, default is 1)
  68905. */
  68906. a?: number);
  68907. /**
  68908. * Adds in place the given Color4 values to the current Color4 object
  68909. * @param right defines the second operand
  68910. * @returns the current updated Color4 object
  68911. */
  68912. addInPlace(right: DeepImmutable<Color4>): Color4;
  68913. /**
  68914. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68915. * @returns the new array
  68916. */
  68917. asArray(): number[];
  68918. /**
  68919. * Stores from the starting index in the given array the Color4 successive values
  68920. * @param array defines the array where to store the r,g,b components
  68921. * @param index defines an optional index in the target array to define where to start storing values
  68922. * @returns the current Color4 object
  68923. */
  68924. toArray(array: number[], index?: number): Color4;
  68925. /**
  68926. * Determines equality between Color4 objects
  68927. * @param otherColor defines the second operand
  68928. * @returns true if the rgba values are equal to the given ones
  68929. */
  68930. equals(otherColor: DeepImmutable<Color4>): boolean;
  68931. /**
  68932. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68933. * @param right defines the second operand
  68934. * @returns a new Color4 object
  68935. */
  68936. add(right: DeepImmutable<Color4>): Color4;
  68937. /**
  68938. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68939. * @param right defines the second operand
  68940. * @returns a new Color4 object
  68941. */
  68942. subtract(right: DeepImmutable<Color4>): Color4;
  68943. /**
  68944. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68945. * @param right defines the second operand
  68946. * @param result defines the Color4 object where to store the result
  68947. * @returns the current Color4 object
  68948. */
  68949. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  68950. /**
  68951. * Creates a new Color4 with the current Color4 values multiplied by scale
  68952. * @param scale defines the scaling factor to apply
  68953. * @returns a new Color4 object
  68954. */
  68955. scale(scale: number): Color4;
  68956. /**
  68957. * Multiplies the current Color4 values by scale and stores the result in "result"
  68958. * @param scale defines the scaling factor to apply
  68959. * @param result defines the Color4 object where to store the result
  68960. * @returns the current unmodified Color4
  68961. */
  68962. scaleToRef(scale: number, result: Color4): Color4;
  68963. /**
  68964. * Scale the current Color4 values by a factor and add the result to a given Color4
  68965. * @param scale defines the scale factor
  68966. * @param result defines the Color4 object where to store the result
  68967. * @returns the unmodified current Color4
  68968. */
  68969. scaleAndAddToRef(scale: number, result: Color4): Color4;
  68970. /**
  68971. * Clamps the rgb values by the min and max values and stores the result into "result"
  68972. * @param min defines minimum clamping value (default is 0)
  68973. * @param max defines maximum clamping value (default is 1)
  68974. * @param result defines color to store the result into.
  68975. * @returns the cuurent Color4
  68976. */
  68977. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  68978. /**
  68979. * Multipy an Color4 value by another and return a new Color4 object
  68980. * @param color defines the Color4 value to multiply by
  68981. * @returns a new Color4 object
  68982. */
  68983. multiply(color: Color4): Color4;
  68984. /**
  68985. * Multipy a Color4 value by another and push the result in a reference value
  68986. * @param color defines the Color4 value to multiply by
  68987. * @param result defines the Color4 to fill the result in
  68988. * @returns the result Color4
  68989. */
  68990. multiplyToRef(color: Color4, result: Color4): Color4;
  68991. /**
  68992. * Creates a string with the Color4 current values
  68993. * @returns the string representation of the Color4 object
  68994. */
  68995. toString(): string;
  68996. /**
  68997. * Returns the string "Color4"
  68998. * @returns "Color4"
  68999. */
  69000. getClassName(): string;
  69001. /**
  69002. * Compute the Color4 hash code
  69003. * @returns an unique number that can be used to hash Color4 objects
  69004. */
  69005. getHashCode(): number;
  69006. /**
  69007. * Creates a new Color4 copied from the current one
  69008. * @returns a new Color4 object
  69009. */
  69010. clone(): Color4;
  69011. /**
  69012. * Copies the given Color4 values into the current one
  69013. * @param source defines the source Color4 object
  69014. * @returns the current updated Color4 object
  69015. */
  69016. copyFrom(source: Color4): Color4;
  69017. /**
  69018. * Copies the given float values into the current one
  69019. * @param r defines the red component to read from
  69020. * @param g defines the green component to read from
  69021. * @param b defines the blue component to read from
  69022. * @param a defines the alpha component to read from
  69023. * @returns the current updated Color4 object
  69024. */
  69025. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  69026. /**
  69027. * Copies the given float values into the current one
  69028. * @param r defines the red component to read from
  69029. * @param g defines the green component to read from
  69030. * @param b defines the blue component to read from
  69031. * @param a defines the alpha component to read from
  69032. * @returns the current updated Color4 object
  69033. */
  69034. set(r: number, g: number, b: number, a: number): Color4;
  69035. /**
  69036. * Compute the Color4 hexadecimal code as a string
  69037. * @returns a string containing the hexadecimal representation of the Color4 object
  69038. */
  69039. toHexString(): string;
  69040. /**
  69041. * Computes a new Color4 converted from the current one to linear space
  69042. * @returns a new Color4 object
  69043. */
  69044. toLinearSpace(): Color4;
  69045. /**
  69046. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  69047. * @param convertedColor defines the Color4 object where to store the linear space version
  69048. * @returns the unmodified Color4
  69049. */
  69050. toLinearSpaceToRef(convertedColor: Color4): Color4;
  69051. /**
  69052. * Computes a new Color4 converted from the current one to gamma space
  69053. * @returns a new Color4 object
  69054. */
  69055. toGammaSpace(): Color4;
  69056. /**
  69057. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69058. * @param convertedColor defines the Color4 object where to store the gamma space version
  69059. * @returns the unmodified Color4
  69060. */
  69061. toGammaSpaceToRef(convertedColor: Color4): Color4;
  69062. /**
  69063. * Creates a new Color4 from the string containing valid hexadecimal values
  69064. * @param hex defines a string containing valid hexadecimal values
  69065. * @returns a new Color4 object
  69066. */
  69067. static FromHexString(hex: string): Color4;
  69068. /**
  69069. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69070. * @param left defines the start value
  69071. * @param right defines the end value
  69072. * @param amount defines the gradient factor
  69073. * @returns a new Color4 object
  69074. */
  69075. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  69076. /**
  69077. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69078. * @param left defines the start value
  69079. * @param right defines the end value
  69080. * @param amount defines the gradient factor
  69081. * @param result defines the Color4 object where to store data
  69082. */
  69083. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  69084. /**
  69085. * Creates a new Color4 from a Color3 and an alpha value
  69086. * @param color3 defines the source Color3 to read from
  69087. * @param alpha defines the alpha component (1.0 by default)
  69088. * @returns a new Color4 object
  69089. */
  69090. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  69091. /**
  69092. * Creates a new Color4 from the starting index element of the given array
  69093. * @param array defines the source array to read from
  69094. * @param offset defines the offset in the source array
  69095. * @returns a new Color4 object
  69096. */
  69097. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  69098. /**
  69099. * Creates a new Color3 from integer values (< 256)
  69100. * @param r defines the red component to read from (value between 0 and 255)
  69101. * @param g defines the green component to read from (value between 0 and 255)
  69102. * @param b defines the blue component to read from (value between 0 and 255)
  69103. * @param a defines the alpha component to read from (value between 0 and 255)
  69104. * @returns a new Color3 object
  69105. */
  69106. static FromInts(r: number, g: number, b: number, a: number): Color4;
  69107. /**
  69108. * Check the content of a given array and convert it to an array containing RGBA data
  69109. * If the original array was already containing count * 4 values then it is returned directly
  69110. * @param colors defines the array to check
  69111. * @param count defines the number of RGBA data to expect
  69112. * @returns an array containing count * 4 values (RGBA)
  69113. */
  69114. static CheckColors4(colors: number[], count: number): number[];
  69115. }
  69116. /**
  69117. * @hidden
  69118. */
  69119. export class TmpColors {
  69120. static Color3: Color3[];
  69121. static Color4: Color4[];
  69122. }
  69123. }
  69124. declare module BABYLON {
  69125. /**
  69126. * Class representing spherical harmonics coefficients to the 3rd degree
  69127. */
  69128. export class SphericalHarmonics {
  69129. /**
  69130. * Defines whether or not the harmonics have been prescaled for rendering.
  69131. */
  69132. preScaled: boolean;
  69133. /**
  69134. * The l0,0 coefficients of the spherical harmonics
  69135. */
  69136. l00: Vector3;
  69137. /**
  69138. * The l1,-1 coefficients of the spherical harmonics
  69139. */
  69140. l1_1: Vector3;
  69141. /**
  69142. * The l1,0 coefficients of the spherical harmonics
  69143. */
  69144. l10: Vector3;
  69145. /**
  69146. * The l1,1 coefficients of the spherical harmonics
  69147. */
  69148. l11: Vector3;
  69149. /**
  69150. * The l2,-2 coefficients of the spherical harmonics
  69151. */
  69152. l2_2: Vector3;
  69153. /**
  69154. * The l2,-1 coefficients of the spherical harmonics
  69155. */
  69156. l2_1: Vector3;
  69157. /**
  69158. * The l2,0 coefficients of the spherical harmonics
  69159. */
  69160. l20: Vector3;
  69161. /**
  69162. * The l2,1 coefficients of the spherical harmonics
  69163. */
  69164. l21: Vector3;
  69165. /**
  69166. * The l2,2 coefficients of the spherical harmonics
  69167. */
  69168. l22: Vector3;
  69169. /**
  69170. * Adds a light to the spherical harmonics
  69171. * @param direction the direction of the light
  69172. * @param color the color of the light
  69173. * @param deltaSolidAngle the delta solid angle of the light
  69174. */
  69175. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  69176. /**
  69177. * Scales the spherical harmonics by the given amount
  69178. * @param scale the amount to scale
  69179. */
  69180. scaleInPlace(scale: number): void;
  69181. /**
  69182. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  69183. *
  69184. * ```
  69185. * E_lm = A_l * L_lm
  69186. * ```
  69187. *
  69188. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  69189. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  69190. * the scaling factors are given in equation 9.
  69191. */
  69192. convertIncidentRadianceToIrradiance(): void;
  69193. /**
  69194. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  69195. *
  69196. * ```
  69197. * L = (1/pi) * E * rho
  69198. * ```
  69199. *
  69200. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  69201. */
  69202. convertIrradianceToLambertianRadiance(): void;
  69203. /**
  69204. * Integrates the reconstruction coefficients directly in to the SH preventing further
  69205. * required operations at run time.
  69206. *
  69207. * This is simply done by scaling back the SH with Ylm constants parameter.
  69208. * The trigonometric part being applied by the shader at run time.
  69209. */
  69210. preScaleForRendering(): void;
  69211. /**
  69212. * Constructs a spherical harmonics from an array.
  69213. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  69214. * @returns the spherical harmonics
  69215. */
  69216. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  69217. /**
  69218. * Gets the spherical harmonics from polynomial
  69219. * @param polynomial the spherical polynomial
  69220. * @returns the spherical harmonics
  69221. */
  69222. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  69223. }
  69224. /**
  69225. * Class representing spherical polynomial coefficients to the 3rd degree
  69226. */
  69227. export class SphericalPolynomial {
  69228. private _harmonics;
  69229. /**
  69230. * The spherical harmonics used to create the polynomials.
  69231. */
  69232. readonly preScaledHarmonics: SphericalHarmonics;
  69233. /**
  69234. * The x coefficients of the spherical polynomial
  69235. */
  69236. x: Vector3;
  69237. /**
  69238. * The y coefficients of the spherical polynomial
  69239. */
  69240. y: Vector3;
  69241. /**
  69242. * The z coefficients of the spherical polynomial
  69243. */
  69244. z: Vector3;
  69245. /**
  69246. * The xx coefficients of the spherical polynomial
  69247. */
  69248. xx: Vector3;
  69249. /**
  69250. * The yy coefficients of the spherical polynomial
  69251. */
  69252. yy: Vector3;
  69253. /**
  69254. * The zz coefficients of the spherical polynomial
  69255. */
  69256. zz: Vector3;
  69257. /**
  69258. * The xy coefficients of the spherical polynomial
  69259. */
  69260. xy: Vector3;
  69261. /**
  69262. * The yz coefficients of the spherical polynomial
  69263. */
  69264. yz: Vector3;
  69265. /**
  69266. * The zx coefficients of the spherical polynomial
  69267. */
  69268. zx: Vector3;
  69269. /**
  69270. * Adds an ambient color to the spherical polynomial
  69271. * @param color the color to add
  69272. */
  69273. addAmbient(color: Color3): void;
  69274. /**
  69275. * Scales the spherical polynomial by the given amount
  69276. * @param scale the amount to scale
  69277. */
  69278. scaleInPlace(scale: number): void;
  69279. /**
  69280. * Gets the spherical polynomial from harmonics
  69281. * @param harmonics the spherical harmonics
  69282. * @returns the spherical polynomial
  69283. */
  69284. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  69285. /**
  69286. * Constructs a spherical polynomial from an array.
  69287. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  69288. * @returns the spherical polynomial
  69289. */
  69290. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  69291. }
  69292. }
  69293. declare module BABYLON {
  69294. /**
  69295. * Define options used to create a render target texture
  69296. */
  69297. export class RenderTargetCreationOptions {
  69298. /**
  69299. * Specifies is mipmaps must be generated
  69300. */
  69301. generateMipMaps?: boolean;
  69302. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  69303. generateDepthBuffer?: boolean;
  69304. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  69305. generateStencilBuffer?: boolean;
  69306. /** Defines texture type (int by default) */
  69307. type?: number;
  69308. /** Defines sampling mode (trilinear by default) */
  69309. samplingMode?: number;
  69310. /** Defines format (RGBA by default) */
  69311. format?: number;
  69312. }
  69313. }
  69314. declare module BABYLON {
  69315. /**
  69316. * @hidden
  69317. **/
  69318. export class _AlphaState {
  69319. private _isAlphaBlendDirty;
  69320. private _isBlendFunctionParametersDirty;
  69321. private _isBlendEquationParametersDirty;
  69322. private _isBlendConstantsDirty;
  69323. private _alphaBlend;
  69324. private _blendFunctionParameters;
  69325. private _blendEquationParameters;
  69326. private _blendConstants;
  69327. /**
  69328. * Initializes the state.
  69329. */
  69330. constructor();
  69331. readonly isDirty: boolean;
  69332. alphaBlend: boolean;
  69333. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  69334. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  69335. setAlphaEquationParameters(rgb: number, alpha: number): void;
  69336. reset(): void;
  69337. apply(gl: WebGLRenderingContext): void;
  69338. }
  69339. }
  69340. declare module BABYLON {
  69341. /**
  69342. * @hidden
  69343. **/
  69344. export class _DepthCullingState {
  69345. private _isDepthTestDirty;
  69346. private _isDepthMaskDirty;
  69347. private _isDepthFuncDirty;
  69348. private _isCullFaceDirty;
  69349. private _isCullDirty;
  69350. private _isZOffsetDirty;
  69351. private _isFrontFaceDirty;
  69352. private _depthTest;
  69353. private _depthMask;
  69354. private _depthFunc;
  69355. private _cull;
  69356. private _cullFace;
  69357. private _zOffset;
  69358. private _frontFace;
  69359. /**
  69360. * Initializes the state.
  69361. */
  69362. constructor();
  69363. readonly isDirty: boolean;
  69364. zOffset: number;
  69365. cullFace: Nullable<number>;
  69366. cull: Nullable<boolean>;
  69367. depthFunc: Nullable<number>;
  69368. depthMask: boolean;
  69369. depthTest: boolean;
  69370. frontFace: Nullable<number>;
  69371. reset(): void;
  69372. apply(gl: WebGLRenderingContext): void;
  69373. }
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * @hidden
  69378. **/
  69379. export class _StencilState {
  69380. /** 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 */
  69381. static readonly ALWAYS: number;
  69382. /** Passed to stencilOperation to specify that stencil value must be kept */
  69383. static readonly KEEP: number;
  69384. /** Passed to stencilOperation to specify that stencil value must be replaced */
  69385. static readonly REPLACE: number;
  69386. private _isStencilTestDirty;
  69387. private _isStencilMaskDirty;
  69388. private _isStencilFuncDirty;
  69389. private _isStencilOpDirty;
  69390. private _stencilTest;
  69391. private _stencilMask;
  69392. private _stencilFunc;
  69393. private _stencilFuncRef;
  69394. private _stencilFuncMask;
  69395. private _stencilOpStencilFail;
  69396. private _stencilOpDepthFail;
  69397. private _stencilOpStencilDepthPass;
  69398. readonly isDirty: boolean;
  69399. stencilFunc: number;
  69400. stencilFuncRef: number;
  69401. stencilFuncMask: number;
  69402. stencilOpStencilFail: number;
  69403. stencilOpDepthFail: number;
  69404. stencilOpStencilDepthPass: number;
  69405. stencilMask: number;
  69406. stencilTest: boolean;
  69407. constructor();
  69408. reset(): void;
  69409. apply(gl: WebGLRenderingContext): void;
  69410. }
  69411. }
  69412. declare module BABYLON {
  69413. /**
  69414. * @hidden
  69415. **/
  69416. export class _TimeToken {
  69417. _startTimeQuery: Nullable<WebGLQuery>;
  69418. _endTimeQuery: Nullable<WebGLQuery>;
  69419. _timeElapsedQuery: Nullable<WebGLQuery>;
  69420. _timeElapsedQueryEnded: boolean;
  69421. }
  69422. }
  69423. declare module BABYLON {
  69424. /**
  69425. * Class used to evalaute queries containing `and` and `or` operators
  69426. */
  69427. export class AndOrNotEvaluator {
  69428. /**
  69429. * Evaluate a query
  69430. * @param query defines the query to evaluate
  69431. * @param evaluateCallback defines the callback used to filter result
  69432. * @returns true if the query matches
  69433. */
  69434. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  69435. private static _HandleParenthesisContent;
  69436. private static _SimplifyNegation;
  69437. }
  69438. }
  69439. declare module BABYLON {
  69440. /**
  69441. * Class used to store custom tags
  69442. */
  69443. export class Tags {
  69444. /**
  69445. * Adds support for tags on the given object
  69446. * @param obj defines the object to use
  69447. */
  69448. static EnableFor(obj: any): void;
  69449. /**
  69450. * Removes tags support
  69451. * @param obj defines the object to use
  69452. */
  69453. static DisableFor(obj: any): void;
  69454. /**
  69455. * Gets a boolean indicating if the given object has tags
  69456. * @param obj defines the object to use
  69457. * @returns a boolean
  69458. */
  69459. static HasTags(obj: any): boolean;
  69460. /**
  69461. * Gets the tags available on a given object
  69462. * @param obj defines the object to use
  69463. * @param asString defines if the tags must be returned as a string instead of an array of strings
  69464. * @returns the tags
  69465. */
  69466. static GetTags(obj: any, asString?: boolean): any;
  69467. /**
  69468. * Adds tags to an object
  69469. * @param obj defines the object to use
  69470. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  69471. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  69472. */
  69473. static AddTagsTo(obj: any, tagsString: string): void;
  69474. /**
  69475. * @hidden
  69476. */
  69477. static _AddTagTo(obj: any, tag: string): void;
  69478. /**
  69479. * Removes specific tags from a specific object
  69480. * @param obj defines the object to use
  69481. * @param tagsString defines the tags to remove
  69482. */
  69483. static RemoveTagsFrom(obj: any, tagsString: string): void;
  69484. /**
  69485. * @hidden
  69486. */
  69487. static _RemoveTagFrom(obj: any, tag: string): void;
  69488. /**
  69489. * Defines if tags hosted on an object match a given query
  69490. * @param obj defines the object to use
  69491. * @param tagsQuery defines the tag query
  69492. * @returns a boolean
  69493. */
  69494. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  69495. }
  69496. }
  69497. declare module BABYLON {
  69498. /**
  69499. * Defines potential orientation for back face culling
  69500. */
  69501. export enum Orientation {
  69502. /**
  69503. * Clockwise
  69504. */
  69505. CW = 0,
  69506. /** Counter clockwise */
  69507. CCW = 1
  69508. }
  69509. /** Class used to represent a Bezier curve */
  69510. export class BezierCurve {
  69511. /**
  69512. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  69513. * @param t defines the time
  69514. * @param x1 defines the left coordinate on X axis
  69515. * @param y1 defines the left coordinate on Y axis
  69516. * @param x2 defines the right coordinate on X axis
  69517. * @param y2 defines the right coordinate on Y axis
  69518. * @returns the interpolated value
  69519. */
  69520. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  69521. }
  69522. /**
  69523. * Defines angle representation
  69524. */
  69525. export class Angle {
  69526. private _radians;
  69527. /**
  69528. * Creates an Angle object of "radians" radians (float).
  69529. * @param radians the angle in radians
  69530. */
  69531. constructor(radians: number);
  69532. /**
  69533. * Get value in degrees
  69534. * @returns the Angle value in degrees (float)
  69535. */
  69536. degrees(): number;
  69537. /**
  69538. * Get value in radians
  69539. * @returns the Angle value in radians (float)
  69540. */
  69541. radians(): number;
  69542. /**
  69543. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  69544. * @param a defines first vector
  69545. * @param b defines second vector
  69546. * @returns a new Angle
  69547. */
  69548. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  69549. /**
  69550. * Gets a new Angle object from the given float in radians
  69551. * @param radians defines the angle value in radians
  69552. * @returns a new Angle
  69553. */
  69554. static FromRadians(radians: number): Angle;
  69555. /**
  69556. * Gets a new Angle object from the given float in degrees
  69557. * @param degrees defines the angle value in degrees
  69558. * @returns a new Angle
  69559. */
  69560. static FromDegrees(degrees: number): Angle;
  69561. }
  69562. /**
  69563. * This represents an arc in a 2d space.
  69564. */
  69565. export class Arc2 {
  69566. /** Defines the start point of the arc */
  69567. startPoint: Vector2;
  69568. /** Defines the mid point of the arc */
  69569. midPoint: Vector2;
  69570. /** Defines the end point of the arc */
  69571. endPoint: Vector2;
  69572. /**
  69573. * Defines the center point of the arc.
  69574. */
  69575. centerPoint: Vector2;
  69576. /**
  69577. * Defines the radius of the arc.
  69578. */
  69579. radius: number;
  69580. /**
  69581. * Defines the angle of the arc (from mid point to end point).
  69582. */
  69583. angle: Angle;
  69584. /**
  69585. * Defines the start angle of the arc (from start point to middle point).
  69586. */
  69587. startAngle: Angle;
  69588. /**
  69589. * Defines the orientation of the arc (clock wise/counter clock wise).
  69590. */
  69591. orientation: Orientation;
  69592. /**
  69593. * Creates an Arc object from the three given points : start, middle and end.
  69594. * @param startPoint Defines the start point of the arc
  69595. * @param midPoint Defines the midlle point of the arc
  69596. * @param endPoint Defines the end point of the arc
  69597. */
  69598. constructor(
  69599. /** Defines the start point of the arc */
  69600. startPoint: Vector2,
  69601. /** Defines the mid point of the arc */
  69602. midPoint: Vector2,
  69603. /** Defines the end point of the arc */
  69604. endPoint: Vector2);
  69605. }
  69606. /**
  69607. * Represents a 2D path made up of multiple 2D points
  69608. */
  69609. export class Path2 {
  69610. private _points;
  69611. private _length;
  69612. /**
  69613. * If the path start and end point are the same
  69614. */
  69615. closed: boolean;
  69616. /**
  69617. * Creates a Path2 object from the starting 2D coordinates x and y.
  69618. * @param x the starting points x value
  69619. * @param y the starting points y value
  69620. */
  69621. constructor(x: number, y: number);
  69622. /**
  69623. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  69624. * @param x the added points x value
  69625. * @param y the added points y value
  69626. * @returns the updated Path2.
  69627. */
  69628. addLineTo(x: number, y: number): Path2;
  69629. /**
  69630. * 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.
  69631. * @param midX middle point x value
  69632. * @param midY middle point y value
  69633. * @param endX end point x value
  69634. * @param endY end point y value
  69635. * @param numberOfSegments (default: 36)
  69636. * @returns the updated Path2.
  69637. */
  69638. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  69639. /**
  69640. * Closes the Path2.
  69641. * @returns the Path2.
  69642. */
  69643. close(): Path2;
  69644. /**
  69645. * Gets the sum of the distance between each sequential point in the path
  69646. * @returns the Path2 total length (float).
  69647. */
  69648. length(): number;
  69649. /**
  69650. * Gets the points which construct the path
  69651. * @returns the Path2 internal array of points.
  69652. */
  69653. getPoints(): Vector2[];
  69654. /**
  69655. * Retreives the point at the distance aways from the starting point
  69656. * @param normalizedLengthPosition the length along the path to retreive the point from
  69657. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  69658. */
  69659. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  69660. /**
  69661. * Creates a new path starting from an x and y position
  69662. * @param x starting x value
  69663. * @param y starting y value
  69664. * @returns a new Path2 starting at the coordinates (x, y).
  69665. */
  69666. static StartingAt(x: number, y: number): Path2;
  69667. }
  69668. /**
  69669. * Represents a 3D path made up of multiple 3D points
  69670. */
  69671. export class Path3D {
  69672. /**
  69673. * an array of Vector3, the curve axis of the Path3D
  69674. */
  69675. path: Vector3[];
  69676. private _curve;
  69677. private _distances;
  69678. private _tangents;
  69679. private _normals;
  69680. private _binormals;
  69681. private _raw;
  69682. /**
  69683. * new Path3D(path, normal, raw)
  69684. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  69685. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  69686. * @param path an array of Vector3, the curve axis of the Path3D
  69687. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  69688. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  69689. */
  69690. constructor(
  69691. /**
  69692. * an array of Vector3, the curve axis of the Path3D
  69693. */
  69694. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  69695. /**
  69696. * Returns the Path3D array of successive Vector3 designing its curve.
  69697. * @returns the Path3D array of successive Vector3 designing its curve.
  69698. */
  69699. getCurve(): Vector3[];
  69700. /**
  69701. * Returns an array populated with tangent vectors on each Path3D curve point.
  69702. * @returns an array populated with tangent vectors on each Path3D curve point.
  69703. */
  69704. getTangents(): Vector3[];
  69705. /**
  69706. * Returns an array populated with normal vectors on each Path3D curve point.
  69707. * @returns an array populated with normal vectors on each Path3D curve point.
  69708. */
  69709. getNormals(): Vector3[];
  69710. /**
  69711. * Returns an array populated with binormal vectors on each Path3D curve point.
  69712. * @returns an array populated with binormal vectors on each Path3D curve point.
  69713. */
  69714. getBinormals(): Vector3[];
  69715. /**
  69716. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  69717. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  69718. */
  69719. getDistances(): number[];
  69720. /**
  69721. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  69722. * @param path path which all values are copied into the curves points
  69723. * @param firstNormal which should be projected onto the curve
  69724. * @returns the same object updated.
  69725. */
  69726. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  69727. private _compute;
  69728. private _getFirstNonNullVector;
  69729. private _getLastNonNullVector;
  69730. private _normalVector;
  69731. }
  69732. /**
  69733. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69734. * A Curve3 is designed from a series of successive Vector3.
  69735. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  69736. */
  69737. export class Curve3 {
  69738. private _points;
  69739. private _length;
  69740. /**
  69741. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  69742. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  69743. * @param v1 (Vector3) the control point
  69744. * @param v2 (Vector3) the end point of the Quadratic Bezier
  69745. * @param nbPoints (integer) the wanted number of points in the curve
  69746. * @returns the created Curve3
  69747. */
  69748. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69749. /**
  69750. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  69751. * @param v0 (Vector3) the origin point of the Cubic Bezier
  69752. * @param v1 (Vector3) the first control point
  69753. * @param v2 (Vector3) the second control point
  69754. * @param v3 (Vector3) the end point of the Cubic Bezier
  69755. * @param nbPoints (integer) the wanted number of points in the curve
  69756. * @returns the created Curve3
  69757. */
  69758. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69759. /**
  69760. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  69761. * @param p1 (Vector3) the origin point of the Hermite Spline
  69762. * @param t1 (Vector3) the tangent vector at the origin point
  69763. * @param p2 (Vector3) the end point of the Hermite Spline
  69764. * @param t2 (Vector3) the tangent vector at the end point
  69765. * @param nbPoints (integer) the wanted number of points in the curve
  69766. * @returns the created Curve3
  69767. */
  69768. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  69769. /**
  69770. * Returns a Curve3 object along a CatmullRom Spline curve :
  69771. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  69772. * @param nbPoints (integer) the wanted number of points between each curve control points
  69773. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  69774. * @returns the created Curve3
  69775. */
  69776. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  69777. /**
  69778. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  69779. * A Curve3 is designed from a series of successive Vector3.
  69780. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  69781. * @param points points which make up the curve
  69782. */
  69783. constructor(points: Vector3[]);
  69784. /**
  69785. * @returns the Curve3 stored array of successive Vector3
  69786. */
  69787. getPoints(): Vector3[];
  69788. /**
  69789. * @returns the computed length (float) of the curve.
  69790. */
  69791. length(): number;
  69792. /**
  69793. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  69794. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  69795. * curveA and curveB keep unchanged.
  69796. * @param curve the curve to continue from this curve
  69797. * @returns the newly constructed curve
  69798. */
  69799. continue(curve: DeepImmutable<Curve3>): Curve3;
  69800. private _computeLength;
  69801. }
  69802. }
  69803. declare module BABYLON {
  69804. /**
  69805. * This represents the main contract an easing function should follow.
  69806. * Easing functions are used throughout the animation system.
  69807. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69808. */
  69809. export interface IEasingFunction {
  69810. /**
  69811. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69812. * of the easing function.
  69813. * The link below provides some of the most common examples of easing functions.
  69814. * @see https://easings.net/
  69815. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69816. * @returns the corresponding value on the curve defined by the easing function
  69817. */
  69818. ease(gradient: number): number;
  69819. }
  69820. /**
  69821. * Base class used for every default easing function.
  69822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69823. */
  69824. export class EasingFunction implements IEasingFunction {
  69825. /**
  69826. * Interpolation follows the mathematical formula associated with the easing function.
  69827. */
  69828. static readonly EASINGMODE_EASEIN: number;
  69829. /**
  69830. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69831. */
  69832. static readonly EASINGMODE_EASEOUT: number;
  69833. /**
  69834. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69835. */
  69836. static readonly EASINGMODE_EASEINOUT: number;
  69837. private _easingMode;
  69838. /**
  69839. * Sets the easing mode of the current function.
  69840. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69841. */
  69842. setEasingMode(easingMode: number): void;
  69843. /**
  69844. * Gets the current easing mode.
  69845. * @returns the easing mode
  69846. */
  69847. getEasingMode(): number;
  69848. /**
  69849. * @hidden
  69850. */
  69851. easeInCore(gradient: number): number;
  69852. /**
  69853. * Given an input gradient between 0 and 1, this returns the corresponding value
  69854. * of the easing function.
  69855. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69856. * @returns the corresponding value on the curve defined by the easing function
  69857. */
  69858. ease(gradient: number): number;
  69859. }
  69860. /**
  69861. * Easing function with a circle shape (see link below).
  69862. * @see https://easings.net/#easeInCirc
  69863. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69864. */
  69865. export class CircleEase extends EasingFunction implements IEasingFunction {
  69866. /** @hidden */
  69867. easeInCore(gradient: number): number;
  69868. }
  69869. /**
  69870. * Easing function with a ease back shape (see link below).
  69871. * @see https://easings.net/#easeInBack
  69872. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69873. */
  69874. export class BackEase extends EasingFunction implements IEasingFunction {
  69875. /** Defines the amplitude of the function */
  69876. amplitude: number;
  69877. /**
  69878. * Instantiates a back ease easing
  69879. * @see https://easings.net/#easeInBack
  69880. * @param amplitude Defines the amplitude of the function
  69881. */
  69882. constructor(
  69883. /** Defines the amplitude of the function */
  69884. amplitude?: number);
  69885. /** @hidden */
  69886. easeInCore(gradient: number): number;
  69887. }
  69888. /**
  69889. * Easing function with a bouncing shape (see link below).
  69890. * @see https://easings.net/#easeInBounce
  69891. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69892. */
  69893. export class BounceEase extends EasingFunction implements IEasingFunction {
  69894. /** Defines the number of bounces */
  69895. bounces: number;
  69896. /** Defines the amplitude of the bounce */
  69897. bounciness: number;
  69898. /**
  69899. * Instantiates a bounce easing
  69900. * @see https://easings.net/#easeInBounce
  69901. * @param bounces Defines the number of bounces
  69902. * @param bounciness Defines the amplitude of the bounce
  69903. */
  69904. constructor(
  69905. /** Defines the number of bounces */
  69906. bounces?: number,
  69907. /** Defines the amplitude of the bounce */
  69908. bounciness?: number);
  69909. /** @hidden */
  69910. easeInCore(gradient: number): number;
  69911. }
  69912. /**
  69913. * Easing function with a power of 3 shape (see link below).
  69914. * @see https://easings.net/#easeInCubic
  69915. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69916. */
  69917. export class CubicEase extends EasingFunction implements IEasingFunction {
  69918. /** @hidden */
  69919. easeInCore(gradient: number): number;
  69920. }
  69921. /**
  69922. * Easing function with an elastic shape (see link below).
  69923. * @see https://easings.net/#easeInElastic
  69924. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69925. */
  69926. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69927. /** Defines the number of oscillations*/
  69928. oscillations: number;
  69929. /** Defines the amplitude of the oscillations*/
  69930. springiness: number;
  69931. /**
  69932. * Instantiates an elastic easing function
  69933. * @see https://easings.net/#easeInElastic
  69934. * @param oscillations Defines the number of oscillations
  69935. * @param springiness Defines the amplitude of the oscillations
  69936. */
  69937. constructor(
  69938. /** Defines the number of oscillations*/
  69939. oscillations?: number,
  69940. /** Defines the amplitude of the oscillations*/
  69941. springiness?: number);
  69942. /** @hidden */
  69943. easeInCore(gradient: number): number;
  69944. }
  69945. /**
  69946. * Easing function with an exponential shape (see link below).
  69947. * @see https://easings.net/#easeInExpo
  69948. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69949. */
  69950. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69951. /** Defines the exponent of the function */
  69952. exponent: number;
  69953. /**
  69954. * Instantiates an exponential easing function
  69955. * @see https://easings.net/#easeInExpo
  69956. * @param exponent Defines the exponent of the function
  69957. */
  69958. constructor(
  69959. /** Defines the exponent of the function */
  69960. exponent?: number);
  69961. /** @hidden */
  69962. easeInCore(gradient: number): number;
  69963. }
  69964. /**
  69965. * Easing function with a power shape (see link below).
  69966. * @see https://easings.net/#easeInQuad
  69967. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69968. */
  69969. export class PowerEase extends EasingFunction implements IEasingFunction {
  69970. /** Defines the power of the function */
  69971. power: number;
  69972. /**
  69973. * Instantiates an power base easing function
  69974. * @see https://easings.net/#easeInQuad
  69975. * @param power Defines the power of the function
  69976. */
  69977. constructor(
  69978. /** Defines the power of the function */
  69979. power?: number);
  69980. /** @hidden */
  69981. easeInCore(gradient: number): number;
  69982. }
  69983. /**
  69984. * Easing function with a power of 2 shape (see link below).
  69985. * @see https://easings.net/#easeInQuad
  69986. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69987. */
  69988. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69989. /** @hidden */
  69990. easeInCore(gradient: number): number;
  69991. }
  69992. /**
  69993. * Easing function with a power of 4 shape (see link below).
  69994. * @see https://easings.net/#easeInQuart
  69995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69996. */
  69997. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69998. /** @hidden */
  69999. easeInCore(gradient: number): number;
  70000. }
  70001. /**
  70002. * Easing function with a power of 5 shape (see link below).
  70003. * @see https://easings.net/#easeInQuint
  70004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70005. */
  70006. export class QuinticEase extends EasingFunction implements IEasingFunction {
  70007. /** @hidden */
  70008. easeInCore(gradient: number): number;
  70009. }
  70010. /**
  70011. * Easing function with a sin shape (see link below).
  70012. * @see https://easings.net/#easeInSine
  70013. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70014. */
  70015. export class SineEase extends EasingFunction implements IEasingFunction {
  70016. /** @hidden */
  70017. easeInCore(gradient: number): number;
  70018. }
  70019. /**
  70020. * Easing function with a bezier shape (see link below).
  70021. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70022. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  70023. */
  70024. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  70025. /** Defines the x component of the start tangent in the bezier curve */
  70026. x1: number;
  70027. /** Defines the y component of the start tangent in the bezier curve */
  70028. y1: number;
  70029. /** Defines the x component of the end tangent in the bezier curve */
  70030. x2: number;
  70031. /** Defines the y component of the end tangent in the bezier curve */
  70032. y2: number;
  70033. /**
  70034. * Instantiates a bezier function
  70035. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  70036. * @param x1 Defines the x component of the start tangent in the bezier curve
  70037. * @param y1 Defines the y component of the start tangent in the bezier curve
  70038. * @param x2 Defines the x component of the end tangent in the bezier curve
  70039. * @param y2 Defines the y component of the end tangent in the bezier curve
  70040. */
  70041. constructor(
  70042. /** Defines the x component of the start tangent in the bezier curve */
  70043. x1?: number,
  70044. /** Defines the y component of the start tangent in the bezier curve */
  70045. y1?: number,
  70046. /** Defines the x component of the end tangent in the bezier curve */
  70047. x2?: number,
  70048. /** Defines the y component of the end tangent in the bezier curve */
  70049. y2?: number);
  70050. /** @hidden */
  70051. easeInCore(gradient: number): number;
  70052. }
  70053. }
  70054. declare module BABYLON {
  70055. /**
  70056. * Defines an interface which represents an animation key frame
  70057. */
  70058. export interface IAnimationKey {
  70059. /**
  70060. * Frame of the key frame
  70061. */
  70062. frame: number;
  70063. /**
  70064. * Value at the specifies key frame
  70065. */
  70066. value: any;
  70067. /**
  70068. * The input tangent for the cubic hermite spline
  70069. */
  70070. inTangent?: any;
  70071. /**
  70072. * The output tangent for the cubic hermite spline
  70073. */
  70074. outTangent?: any;
  70075. /**
  70076. * The animation interpolation type
  70077. */
  70078. interpolation?: AnimationKeyInterpolation;
  70079. }
  70080. /**
  70081. * Enum for the animation key frame interpolation type
  70082. */
  70083. export enum AnimationKeyInterpolation {
  70084. /**
  70085. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  70086. */
  70087. STEP = 1
  70088. }
  70089. }
  70090. declare module BABYLON {
  70091. /**
  70092. * Represents the range of an animation
  70093. */
  70094. export class AnimationRange {
  70095. /**The name of the animation range**/
  70096. name: string;
  70097. /**The starting frame of the animation */
  70098. from: number;
  70099. /**The ending frame of the animation*/
  70100. to: number;
  70101. /**
  70102. * Initializes the range of an animation
  70103. * @param name The name of the animation range
  70104. * @param from The starting frame of the animation
  70105. * @param to The ending frame of the animation
  70106. */
  70107. constructor(
  70108. /**The name of the animation range**/
  70109. name: string,
  70110. /**The starting frame of the animation */
  70111. from: number,
  70112. /**The ending frame of the animation*/
  70113. to: number);
  70114. /**
  70115. * Makes a copy of the animation range
  70116. * @returns A copy of the animation range
  70117. */
  70118. clone(): AnimationRange;
  70119. }
  70120. }
  70121. declare module BABYLON {
  70122. /**
  70123. * Composed of a frame, and an action function
  70124. */
  70125. export class AnimationEvent {
  70126. /** The frame for which the event is triggered **/
  70127. frame: number;
  70128. /** The event to perform when triggered **/
  70129. action: (currentFrame: number) => void;
  70130. /** Specifies if the event should be triggered only once**/
  70131. onlyOnce?: boolean | undefined;
  70132. /**
  70133. * Specifies if the animation event is done
  70134. */
  70135. isDone: boolean;
  70136. /**
  70137. * Initializes the animation event
  70138. * @param frame The frame for which the event is triggered
  70139. * @param action The event to perform when triggered
  70140. * @param onlyOnce Specifies if the event should be triggered only once
  70141. */
  70142. constructor(
  70143. /** The frame for which the event is triggered **/
  70144. frame: number,
  70145. /** The event to perform when triggered **/
  70146. action: (currentFrame: number) => void,
  70147. /** Specifies if the event should be triggered only once**/
  70148. onlyOnce?: boolean | undefined);
  70149. /** @hidden */
  70150. _clone(): AnimationEvent;
  70151. }
  70152. }
  70153. declare module BABYLON {
  70154. /**
  70155. * Interface used to define a behavior
  70156. */
  70157. export interface Behavior<T> {
  70158. /** gets or sets behavior's name */
  70159. name: string;
  70160. /**
  70161. * Function called when the behavior needs to be initialized (after attaching it to a target)
  70162. */
  70163. init(): void;
  70164. /**
  70165. * Called when the behavior is attached to a target
  70166. * @param target defines the target where the behavior is attached to
  70167. */
  70168. attach(target: T): void;
  70169. /**
  70170. * Called when the behavior is detached from its target
  70171. */
  70172. detach(): void;
  70173. }
  70174. /**
  70175. * Interface implemented by classes supporting behaviors
  70176. */
  70177. export interface IBehaviorAware<T> {
  70178. /**
  70179. * Attach a behavior
  70180. * @param behavior defines the behavior to attach
  70181. * @returns the current host
  70182. */
  70183. addBehavior(behavior: Behavior<T>): T;
  70184. /**
  70185. * Remove a behavior from the current object
  70186. * @param behavior defines the behavior to detach
  70187. * @returns the current host
  70188. */
  70189. removeBehavior(behavior: Behavior<T>): T;
  70190. /**
  70191. * Gets a behavior using its name to search
  70192. * @param name defines the name to search
  70193. * @returns the behavior or null if not found
  70194. */
  70195. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  70196. }
  70197. }
  70198. declare module BABYLON {
  70199. /**
  70200. * Defines an array and its length.
  70201. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70202. */
  70203. export interface ISmartArrayLike<T> {
  70204. /**
  70205. * The data of the array.
  70206. */
  70207. data: Array<T>;
  70208. /**
  70209. * The active length of the array.
  70210. */
  70211. length: number;
  70212. }
  70213. /**
  70214. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70215. */
  70216. export class SmartArray<T> implements ISmartArrayLike<T> {
  70217. /**
  70218. * The full set of data from the array.
  70219. */
  70220. data: Array<T>;
  70221. /**
  70222. * The active length of the array.
  70223. */
  70224. length: number;
  70225. protected _id: number;
  70226. /**
  70227. * Instantiates a Smart Array.
  70228. * @param capacity defines the default capacity of the array.
  70229. */
  70230. constructor(capacity: number);
  70231. /**
  70232. * Pushes a value at the end of the active data.
  70233. * @param value defines the object to push in the array.
  70234. */
  70235. push(value: T): void;
  70236. /**
  70237. * Iterates over the active data and apply the lambda to them.
  70238. * @param func defines the action to apply on each value.
  70239. */
  70240. forEach(func: (content: T) => void): void;
  70241. /**
  70242. * Sorts the full sets of data.
  70243. * @param compareFn defines the comparison function to apply.
  70244. */
  70245. sort(compareFn: (a: T, b: T) => number): void;
  70246. /**
  70247. * Resets the active data to an empty array.
  70248. */
  70249. reset(): void;
  70250. /**
  70251. * Releases all the data from the array as well as the array.
  70252. */
  70253. dispose(): void;
  70254. /**
  70255. * Concats the active data with a given array.
  70256. * @param array defines the data to concatenate with.
  70257. */
  70258. concat(array: any): void;
  70259. /**
  70260. * Returns the position of a value in the active data.
  70261. * @param value defines the value to find the index for
  70262. * @returns the index if found in the active data otherwise -1
  70263. */
  70264. indexOf(value: T): number;
  70265. /**
  70266. * Returns whether an element is part of the active data.
  70267. * @param value defines the value to look for
  70268. * @returns true if found in the active data otherwise false
  70269. */
  70270. contains(value: T): boolean;
  70271. private static _GlobalId;
  70272. }
  70273. /**
  70274. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70275. * The data in this array can only be present once
  70276. */
  70277. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70278. private _duplicateId;
  70279. /**
  70280. * Pushes a value at the end of the active data.
  70281. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70282. * @param value defines the object to push in the array.
  70283. */
  70284. push(value: T): void;
  70285. /**
  70286. * Pushes a value at the end of the active data.
  70287. * If the data is already present, it won t be added again
  70288. * @param value defines the object to push in the array.
  70289. * @returns true if added false if it was already present
  70290. */
  70291. pushNoDuplicate(value: T): boolean;
  70292. /**
  70293. * Resets the active data to an empty array.
  70294. */
  70295. reset(): void;
  70296. /**
  70297. * Concats the active data with a given array.
  70298. * This ensures no dupplicate will be present in the result.
  70299. * @param array defines the data to concatenate with.
  70300. */
  70301. concatWithNoDuplicate(array: any): void;
  70302. }
  70303. }
  70304. declare module BABYLON {
  70305. /**
  70306. * @ignore
  70307. * This is a list of all the different input types that are available in the application.
  70308. * Fo instance: ArcRotateCameraGamepadInput...
  70309. */
  70310. export var CameraInputTypes: {};
  70311. /**
  70312. * This is the contract to implement in order to create a new input class.
  70313. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70314. */
  70315. export interface ICameraInput<TCamera extends Camera> {
  70316. /**
  70317. * Defines the camera the input is attached to.
  70318. */
  70319. camera: Nullable<TCamera>;
  70320. /**
  70321. * Gets the class name of the current intput.
  70322. * @returns the class name
  70323. */
  70324. getClassName(): string;
  70325. /**
  70326. * Get the friendly name associated with the input class.
  70327. * @returns the input friendly name
  70328. */
  70329. getSimpleName(): string;
  70330. /**
  70331. * Attach the input controls to a specific dom element to get the input from.
  70332. * @param element Defines the element the controls should be listened from
  70333. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70334. */
  70335. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70336. /**
  70337. * Detach the current controls from the specified dom element.
  70338. * @param element Defines the element to stop listening the inputs from
  70339. */
  70340. detachControl(element: Nullable<HTMLElement>): void;
  70341. /**
  70342. * Update the current camera state depending on the inputs that have been used this frame.
  70343. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70344. */
  70345. checkInputs?: () => void;
  70346. }
  70347. /**
  70348. * Represents a map of input types to input instance or input index to input instance.
  70349. */
  70350. export interface CameraInputsMap<TCamera extends Camera> {
  70351. /**
  70352. * Accessor to the input by input type.
  70353. */
  70354. [name: string]: ICameraInput<TCamera>;
  70355. /**
  70356. * Accessor to the input by input index.
  70357. */
  70358. [idx: number]: ICameraInput<TCamera>;
  70359. }
  70360. /**
  70361. * This represents the input manager used within a camera.
  70362. * It helps dealing with all the different kind of input attached to a camera.
  70363. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70364. */
  70365. export class CameraInputsManager<TCamera extends Camera> {
  70366. /**
  70367. * Defines the list of inputs attahed to the camera.
  70368. */
  70369. attached: CameraInputsMap<TCamera>;
  70370. /**
  70371. * Defines the dom element the camera is collecting inputs from.
  70372. * This is null if the controls have not been attached.
  70373. */
  70374. attachedElement: Nullable<HTMLElement>;
  70375. /**
  70376. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70377. */
  70378. noPreventDefault: boolean;
  70379. /**
  70380. * Defined the camera the input manager belongs to.
  70381. */
  70382. camera: TCamera;
  70383. /**
  70384. * Update the current camera state depending on the inputs that have been used this frame.
  70385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70386. */
  70387. checkInputs: () => void;
  70388. /**
  70389. * Instantiate a new Camera Input Manager.
  70390. * @param camera Defines the camera the input manager blongs to
  70391. */
  70392. constructor(camera: TCamera);
  70393. /**
  70394. * Add an input method to a camera
  70395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70396. * @param input camera input method
  70397. */
  70398. add(input: ICameraInput<TCamera>): void;
  70399. /**
  70400. * Remove a specific input method from a camera
  70401. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70402. * @param inputToRemove camera input method
  70403. */
  70404. remove(inputToRemove: ICameraInput<TCamera>): void;
  70405. /**
  70406. * Remove a specific input type from a camera
  70407. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70408. * @param inputType the type of the input to remove
  70409. */
  70410. removeByType(inputType: string): void;
  70411. private _addCheckInputs;
  70412. /**
  70413. * Attach the input controls to the currently attached dom element to listen the events from.
  70414. * @param input Defines the input to attach
  70415. */
  70416. attachInput(input: ICameraInput<TCamera>): void;
  70417. /**
  70418. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70419. * @param element Defines the dom element to collect the events from
  70420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70421. */
  70422. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70423. /**
  70424. * Detach the current manager inputs controls from a specific dom element.
  70425. * @param element Defines the dom element to collect the events from
  70426. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70427. */
  70428. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70429. /**
  70430. * Rebuild the dynamic inputCheck function from the current list of
  70431. * defined inputs in the manager.
  70432. */
  70433. rebuildInputCheck(): void;
  70434. /**
  70435. * Remove all attached input methods from a camera
  70436. */
  70437. clear(): void;
  70438. /**
  70439. * Serialize the current input manager attached to a camera.
  70440. * This ensures than once parsed,
  70441. * the input associated to the camera will be identical to the current ones
  70442. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70443. */
  70444. serialize(serializedCamera: any): void;
  70445. /**
  70446. * Parses an input manager serialized JSON to restore the previous list of inputs
  70447. * and states associated to a camera.
  70448. * @param parsedCamera Defines the JSON to parse
  70449. */
  70450. parse(parsedCamera: any): void;
  70451. }
  70452. }
  70453. declare module BABYLON {
  70454. /**
  70455. * @hidden
  70456. */
  70457. export class IntersectionInfo {
  70458. bu: Nullable<number>;
  70459. bv: Nullable<number>;
  70460. distance: number;
  70461. faceId: number;
  70462. subMeshId: number;
  70463. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  70464. }
  70465. }
  70466. declare module BABYLON {
  70467. /**
  70468. * Represens a plane by the equation ax + by + cz + d = 0
  70469. */
  70470. export class Plane {
  70471. private static _TmpMatrix;
  70472. /**
  70473. * Normal of the plane (a,b,c)
  70474. */
  70475. normal: Vector3;
  70476. /**
  70477. * d component of the plane
  70478. */
  70479. d: number;
  70480. /**
  70481. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  70482. * @param a a component of the plane
  70483. * @param b b component of the plane
  70484. * @param c c component of the plane
  70485. * @param d d component of the plane
  70486. */
  70487. constructor(a: number, b: number, c: number, d: number);
  70488. /**
  70489. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  70490. */
  70491. asArray(): number[];
  70492. /**
  70493. * @returns a new plane copied from the current Plane.
  70494. */
  70495. clone(): Plane;
  70496. /**
  70497. * @returns the string "Plane".
  70498. */
  70499. getClassName(): string;
  70500. /**
  70501. * @returns the Plane hash code.
  70502. */
  70503. getHashCode(): number;
  70504. /**
  70505. * Normalize the current Plane in place.
  70506. * @returns the updated Plane.
  70507. */
  70508. normalize(): Plane;
  70509. /**
  70510. * Applies a transformation the plane and returns the result
  70511. * @param transformation the transformation matrix to be applied to the plane
  70512. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  70513. */
  70514. transform(transformation: DeepImmutable<Matrix>): Plane;
  70515. /**
  70516. * Calcualtte the dot product between the point and the plane normal
  70517. * @param point point to calculate the dot product with
  70518. * @returns the dot product (float) of the point coordinates and the plane normal.
  70519. */
  70520. dotCoordinate(point: DeepImmutable<Vector3>): number;
  70521. /**
  70522. * Updates the current Plane from the plane defined by the three given points.
  70523. * @param point1 one of the points used to contruct the plane
  70524. * @param point2 one of the points used to contruct the plane
  70525. * @param point3 one of the points used to contruct the plane
  70526. * @returns the updated Plane.
  70527. */
  70528. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70529. /**
  70530. * Checks if the plane is facing a given direction
  70531. * @param direction the direction to check if the plane is facing
  70532. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  70533. * @returns True is the vector "direction" is the same side than the plane normal.
  70534. */
  70535. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  70536. /**
  70537. * Calculates the distance to a point
  70538. * @param point point to calculate distance to
  70539. * @returns the signed distance (float) from the given point to the Plane.
  70540. */
  70541. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  70542. /**
  70543. * Creates a plane from an array
  70544. * @param array the array to create a plane from
  70545. * @returns a new Plane from the given array.
  70546. */
  70547. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  70548. /**
  70549. * Creates a plane from three points
  70550. * @param point1 point used to create the plane
  70551. * @param point2 point used to create the plane
  70552. * @param point3 point used to create the plane
  70553. * @returns a new Plane defined by the three given points.
  70554. */
  70555. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  70556. /**
  70557. * Creates a plane from an origin point and a normal
  70558. * @param origin origin of the plane to be constructed
  70559. * @param normal normal of the plane to be constructed
  70560. * @returns a new Plane the normal vector to this plane at the given origin point.
  70561. * Note : the vector "normal" is updated because normalized.
  70562. */
  70563. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  70564. /**
  70565. * Calculates the distance from a plane and a point
  70566. * @param origin origin of the plane to be constructed
  70567. * @param normal normal of the plane to be constructed
  70568. * @param point point to calculate distance to
  70569. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  70570. */
  70571. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  70572. }
  70573. }
  70574. declare module BABYLON {
  70575. /**
  70576. * Class used to store bounding sphere information
  70577. */
  70578. export class BoundingSphere {
  70579. /**
  70580. * Gets the center of the bounding sphere in local space
  70581. */
  70582. readonly center: Vector3;
  70583. /**
  70584. * Radius of the bounding sphere in local space
  70585. */
  70586. radius: number;
  70587. /**
  70588. * Gets the center of the bounding sphere in world space
  70589. */
  70590. readonly centerWorld: Vector3;
  70591. /**
  70592. * Radius of the bounding sphere in world space
  70593. */
  70594. radiusWorld: number;
  70595. /**
  70596. * Gets the minimum vector in local space
  70597. */
  70598. readonly minimum: Vector3;
  70599. /**
  70600. * Gets the maximum vector in local space
  70601. */
  70602. readonly maximum: Vector3;
  70603. private _worldMatrix;
  70604. private static readonly TmpVector3;
  70605. /**
  70606. * Creates a new bounding sphere
  70607. * @param min defines the minimum vector (in local space)
  70608. * @param max defines the maximum vector (in local space)
  70609. * @param worldMatrix defines the new world matrix
  70610. */
  70611. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70612. /**
  70613. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  70614. * @param min defines the new minimum vector (in local space)
  70615. * @param max defines the new maximum vector (in local space)
  70616. * @param worldMatrix defines the new world matrix
  70617. */
  70618. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70619. /**
  70620. * Scale the current bounding sphere by applying a scale factor
  70621. * @param factor defines the scale factor to apply
  70622. * @returns the current bounding box
  70623. */
  70624. scale(factor: number): BoundingSphere;
  70625. /**
  70626. * Gets the world matrix of the bounding box
  70627. * @returns a matrix
  70628. */
  70629. getWorldMatrix(): DeepImmutable<Matrix>;
  70630. /** @hidden */
  70631. _update(worldMatrix: DeepImmutable<Matrix>): void;
  70632. /**
  70633. * Tests if the bounding sphere is intersecting the frustum planes
  70634. * @param frustumPlanes defines the frustum planes to test
  70635. * @returns true if there is an intersection
  70636. */
  70637. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70638. /**
  70639. * Tests if the bounding sphere center is in between the frustum planes.
  70640. * Used for optimistic fast inclusion.
  70641. * @param frustumPlanes defines the frustum planes to test
  70642. * @returns true if the sphere center is in between the frustum planes
  70643. */
  70644. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70645. /**
  70646. * Tests if a point is inside the bounding sphere
  70647. * @param point defines the point to test
  70648. * @returns true if the point is inside the bounding sphere
  70649. */
  70650. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70651. /**
  70652. * Checks if two sphere intersct
  70653. * @param sphere0 sphere 0
  70654. * @param sphere1 sphere 1
  70655. * @returns true if the speres intersect
  70656. */
  70657. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  70658. }
  70659. }
  70660. declare module BABYLON {
  70661. /**
  70662. * Class used to store bounding box information
  70663. */
  70664. export class BoundingBox implements ICullable {
  70665. /**
  70666. * Gets the 8 vectors representing the bounding box in local space
  70667. */
  70668. readonly vectors: Vector3[];
  70669. /**
  70670. * Gets the center of the bounding box in local space
  70671. */
  70672. readonly center: Vector3;
  70673. /**
  70674. * Gets the center of the bounding box in world space
  70675. */
  70676. readonly centerWorld: Vector3;
  70677. /**
  70678. * Gets the extend size in local space
  70679. */
  70680. readonly extendSize: Vector3;
  70681. /**
  70682. * Gets the extend size in world space
  70683. */
  70684. readonly extendSizeWorld: Vector3;
  70685. /**
  70686. * Gets the OBB (object bounding box) directions
  70687. */
  70688. readonly directions: Vector3[];
  70689. /**
  70690. * Gets the 8 vectors representing the bounding box in world space
  70691. */
  70692. readonly vectorsWorld: Vector3[];
  70693. /**
  70694. * Gets the minimum vector in world space
  70695. */
  70696. readonly minimumWorld: Vector3;
  70697. /**
  70698. * Gets the maximum vector in world space
  70699. */
  70700. readonly maximumWorld: Vector3;
  70701. /**
  70702. * Gets the minimum vector in local space
  70703. */
  70704. readonly minimum: Vector3;
  70705. /**
  70706. * Gets the maximum vector in local space
  70707. */
  70708. readonly maximum: Vector3;
  70709. private _worldMatrix;
  70710. private static readonly TmpVector3;
  70711. /**
  70712. * @hidden
  70713. */
  70714. _tag: number;
  70715. /**
  70716. * Creates a new bounding box
  70717. * @param min defines the minimum vector (in local space)
  70718. * @param max defines the maximum vector (in local space)
  70719. * @param worldMatrix defines the new world matrix
  70720. */
  70721. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70722. /**
  70723. * Recreates the entire bounding box from scratch as if we call the constructor in place
  70724. * @param min defines the new minimum vector (in local space)
  70725. * @param max defines the new maximum vector (in local space)
  70726. * @param worldMatrix defines the new world matrix
  70727. */
  70728. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70729. /**
  70730. * Scale the current bounding box by applying a scale factor
  70731. * @param factor defines the scale factor to apply
  70732. * @returns the current bounding box
  70733. */
  70734. scale(factor: number): BoundingBox;
  70735. /**
  70736. * Gets the world matrix of the bounding box
  70737. * @returns a matrix
  70738. */
  70739. getWorldMatrix(): DeepImmutable<Matrix>;
  70740. /** @hidden */
  70741. _update(world: DeepImmutable<Matrix>): void;
  70742. /**
  70743. * Tests if the bounding box is intersecting the frustum planes
  70744. * @param frustumPlanes defines the frustum planes to test
  70745. * @returns true if there is an intersection
  70746. */
  70747. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70748. /**
  70749. * Tests if the bounding box is entirely inside the frustum planes
  70750. * @param frustumPlanes defines the frustum planes to test
  70751. * @returns true if there is an inclusion
  70752. */
  70753. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70754. /**
  70755. * Tests if a point is inside the bounding box
  70756. * @param point defines the point to test
  70757. * @returns true if the point is inside the bounding box
  70758. */
  70759. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70760. /**
  70761. * Tests if the bounding box intersects with a bounding sphere
  70762. * @param sphere defines the sphere to test
  70763. * @returns true if there is an intersection
  70764. */
  70765. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  70766. /**
  70767. * Tests if the bounding box intersects with a box defined by a min and max vectors
  70768. * @param min defines the min vector to use
  70769. * @param max defines the max vector to use
  70770. * @returns true if there is an intersection
  70771. */
  70772. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  70773. /**
  70774. * Tests if two bounding boxes are intersections
  70775. * @param box0 defines the first box to test
  70776. * @param box1 defines the second box to test
  70777. * @returns true if there is an intersection
  70778. */
  70779. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  70780. /**
  70781. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  70782. * @param minPoint defines the minimum vector of the bounding box
  70783. * @param maxPoint defines the maximum vector of the bounding box
  70784. * @param sphereCenter defines the sphere center
  70785. * @param sphereRadius defines the sphere radius
  70786. * @returns true if there is an intersection
  70787. */
  70788. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  70789. /**
  70790. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  70791. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70792. * @param frustumPlanes defines the frustum planes to test
  70793. * @return true if there is an inclusion
  70794. */
  70795. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70796. /**
  70797. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  70798. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  70799. * @param frustumPlanes defines the frustum planes to test
  70800. * @return true if there is an intersection
  70801. */
  70802. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70803. }
  70804. }
  70805. declare module BABYLON {
  70806. /** @hidden */
  70807. export class Collider {
  70808. /** Define if a collision was found */
  70809. collisionFound: boolean;
  70810. /**
  70811. * Define last intersection point in local space
  70812. */
  70813. intersectionPoint: Vector3;
  70814. /**
  70815. * Define last collided mesh
  70816. */
  70817. collidedMesh: Nullable<AbstractMesh>;
  70818. private _collisionPoint;
  70819. private _planeIntersectionPoint;
  70820. private _tempVector;
  70821. private _tempVector2;
  70822. private _tempVector3;
  70823. private _tempVector4;
  70824. private _edge;
  70825. private _baseToVertex;
  70826. private _destinationPoint;
  70827. private _slidePlaneNormal;
  70828. private _displacementVector;
  70829. /** @hidden */
  70830. _radius: Vector3;
  70831. /** @hidden */
  70832. _retry: number;
  70833. private _velocity;
  70834. private _basePoint;
  70835. private _epsilon;
  70836. /** @hidden */
  70837. _velocityWorldLength: number;
  70838. /** @hidden */
  70839. _basePointWorld: Vector3;
  70840. private _velocityWorld;
  70841. private _normalizedVelocity;
  70842. /** @hidden */
  70843. _initialVelocity: Vector3;
  70844. /** @hidden */
  70845. _initialPosition: Vector3;
  70846. private _nearestDistance;
  70847. private _collisionMask;
  70848. collisionMask: number;
  70849. /**
  70850. * Gets the plane normal used to compute the sliding response (in local space)
  70851. */
  70852. readonly slidePlaneNormal: Vector3;
  70853. /** @hidden */
  70854. _initialize(source: Vector3, dir: Vector3, e: number): void;
  70855. /** @hidden */
  70856. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  70857. /** @hidden */
  70858. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  70859. /** @hidden */
  70860. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70861. /** @hidden */
  70862. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  70863. /** @hidden */
  70864. _getResponse(pos: Vector3, vel: Vector3): void;
  70865. }
  70866. }
  70867. declare module BABYLON {
  70868. /**
  70869. * Interface for cullable objects
  70870. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  70871. */
  70872. export interface ICullable {
  70873. /**
  70874. * Checks if the object or part of the object is in the frustum
  70875. * @param frustumPlanes Camera near/planes
  70876. * @returns true if the object is in frustum otherwise false
  70877. */
  70878. isInFrustum(frustumPlanes: Plane[]): boolean;
  70879. /**
  70880. * Checks if a cullable object (mesh...) is in the camera frustum
  70881. * Unlike isInFrustum this cheks the full bounding box
  70882. * @param frustumPlanes Camera near/planes
  70883. * @returns true if the object is in frustum otherwise false
  70884. */
  70885. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  70886. }
  70887. /**
  70888. * Info for a bounding data of a mesh
  70889. */
  70890. export class BoundingInfo implements ICullable {
  70891. /**
  70892. * Bounding box for the mesh
  70893. */
  70894. readonly boundingBox: BoundingBox;
  70895. /**
  70896. * Bounding sphere for the mesh
  70897. */
  70898. readonly boundingSphere: BoundingSphere;
  70899. private _isLocked;
  70900. private static readonly TmpVector3;
  70901. /**
  70902. * Constructs bounding info
  70903. * @param minimum min vector of the bounding box/sphere
  70904. * @param maximum max vector of the bounding box/sphere
  70905. * @param worldMatrix defines the new world matrix
  70906. */
  70907. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  70908. /**
  70909. * Recreates the entire bounding info from scratch as if we call the constructor in place
  70910. * @param min defines the new minimum vector (in local space)
  70911. * @param max defines the new maximum vector (in local space)
  70912. * @param worldMatrix defines the new world matrix
  70913. */
  70914. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  70915. /**
  70916. * min vector of the bounding box/sphere
  70917. */
  70918. readonly minimum: Vector3;
  70919. /**
  70920. * max vector of the bounding box/sphere
  70921. */
  70922. readonly maximum: Vector3;
  70923. /**
  70924. * If the info is locked and won't be updated to avoid perf overhead
  70925. */
  70926. isLocked: boolean;
  70927. /**
  70928. * Updates the bounding sphere and box
  70929. * @param world world matrix to be used to update
  70930. */
  70931. update(world: DeepImmutable<Matrix>): void;
  70932. /**
  70933. * Recreate the bounding info to be centered around a specific point given a specific extend.
  70934. * @param center New center of the bounding info
  70935. * @param extend New extend of the bounding info
  70936. * @returns the current bounding info
  70937. */
  70938. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  70939. /**
  70940. * Scale the current bounding info by applying a scale factor
  70941. * @param factor defines the scale factor to apply
  70942. * @returns the current bounding info
  70943. */
  70944. scale(factor: number): BoundingInfo;
  70945. /**
  70946. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  70947. * @param frustumPlanes defines the frustum to test
  70948. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  70949. * @returns true if the bounding info is in the frustum planes
  70950. */
  70951. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  70952. /**
  70953. * Gets the world distance between the min and max points of the bounding box
  70954. */
  70955. readonly diagonalLength: number;
  70956. /**
  70957. * Checks if a cullable object (mesh...) is in the camera frustum
  70958. * Unlike isInFrustum this cheks the full bounding box
  70959. * @param frustumPlanes Camera near/planes
  70960. * @returns true if the object is in frustum otherwise false
  70961. */
  70962. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  70963. /** @hidden */
  70964. _checkCollision(collider: Collider): boolean;
  70965. /**
  70966. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  70967. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70968. * @param point the point to check intersection with
  70969. * @returns if the point intersects
  70970. */
  70971. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  70972. /**
  70973. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70974. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70975. * @param boundingInfo the bounding info to check intersection with
  70976. * @param precise if the intersection should be done using OBB
  70977. * @returns if the bounding info intersects
  70978. */
  70979. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70980. }
  70981. }
  70982. declare module BABYLON {
  70983. /**
  70984. * Extracts minimum and maximum values from a list of indexed positions
  70985. * @param positions defines the positions to use
  70986. * @param indices defines the indices to the positions
  70987. * @param indexStart defines the start index
  70988. * @param indexCount defines the end index
  70989. * @param bias defines bias value to add to the result
  70990. * @return minimum and maximum values
  70991. */
  70992. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  70993. minimum: Vector3;
  70994. maximum: Vector3;
  70995. };
  70996. /**
  70997. * Extracts minimum and maximum values from a list of positions
  70998. * @param positions defines the positions to use
  70999. * @param start defines the start index in the positions array
  71000. * @param count defines the number of positions to handle
  71001. * @param bias defines bias value to add to the result
  71002. * @param stride defines the stride size to use (distance between two positions in the positions array)
  71003. * @return minimum and maximum values
  71004. */
  71005. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  71006. minimum: Vector3;
  71007. maximum: Vector3;
  71008. };
  71009. }
  71010. declare module BABYLON {
  71011. /**
  71012. * Enum that determines the text-wrapping mode to use.
  71013. */
  71014. export enum InspectableType {
  71015. /**
  71016. * Checkbox for booleans
  71017. */
  71018. Checkbox = 0,
  71019. /**
  71020. * Sliders for numbers
  71021. */
  71022. Slider = 1,
  71023. /**
  71024. * Vector3
  71025. */
  71026. Vector3 = 2,
  71027. /**
  71028. * Quaternions
  71029. */
  71030. Quaternion = 3,
  71031. /**
  71032. * Color3
  71033. */
  71034. Color3 = 4,
  71035. /**
  71036. * String
  71037. */
  71038. String = 5
  71039. }
  71040. /**
  71041. * Interface used to define custom inspectable properties.
  71042. * This interface is used by the inspector to display custom property grids
  71043. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  71044. */
  71045. export interface IInspectable {
  71046. /**
  71047. * Gets the label to display
  71048. */
  71049. label: string;
  71050. /**
  71051. * Gets the name of the property to edit
  71052. */
  71053. propertyName: string;
  71054. /**
  71055. * Gets the type of the editor to use
  71056. */
  71057. type: InspectableType;
  71058. /**
  71059. * Gets the minimum value of the property when using in "slider" mode
  71060. */
  71061. min?: number;
  71062. /**
  71063. * Gets the maximum value of the property when using in "slider" mode
  71064. */
  71065. max?: number;
  71066. /**
  71067. * Gets the setp to use when using in "slider" mode
  71068. */
  71069. step?: number;
  71070. }
  71071. }
  71072. declare module BABYLON {
  71073. /**
  71074. * Class used to provide helper for timing
  71075. */
  71076. export class TimingTools {
  71077. /**
  71078. * Polyfill for setImmediate
  71079. * @param action defines the action to execute after the current execution block
  71080. */
  71081. static SetImmediate(action: () => void): void;
  71082. }
  71083. }
  71084. declare module BABYLON {
  71085. /**
  71086. * Class used to enable instatition of objects by class name
  71087. */
  71088. export class InstantiationTools {
  71089. /**
  71090. * Use this object to register external classes like custom textures or material
  71091. * to allow the laoders to instantiate them
  71092. */
  71093. static RegisteredExternalClasses: {
  71094. [key: string]: Object;
  71095. };
  71096. /**
  71097. * Tries to instantiate a new object from a given class name
  71098. * @param className defines the class name to instantiate
  71099. * @returns the new object or null if the system was not able to do the instantiation
  71100. */
  71101. static Instantiate(className: string): any;
  71102. }
  71103. }
  71104. declare module BABYLON {
  71105. /**
  71106. * This represents the required contract to create a new type of texture loader.
  71107. */
  71108. export interface IInternalTextureLoader {
  71109. /**
  71110. * Defines wether the loader supports cascade loading the different faces.
  71111. */
  71112. supportCascades: boolean;
  71113. /**
  71114. * This returns if the loader support the current file information.
  71115. * @param extension defines the file extension of the file being loaded
  71116. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71117. * @param fallback defines the fallback internal texture if any
  71118. * @param isBase64 defines whether the texture is encoded as a base64
  71119. * @param isBuffer defines whether the texture data are stored as a buffer
  71120. * @returns true if the loader can load the specified file
  71121. */
  71122. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71123. /**
  71124. * Transform the url before loading if required.
  71125. * @param rootUrl the url of the texture
  71126. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71127. * @returns the transformed texture
  71128. */
  71129. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71130. /**
  71131. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71132. * @param rootUrl the url of the texture
  71133. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71134. * @returns the fallback texture
  71135. */
  71136. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71137. /**
  71138. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71139. * @param data contains the texture data
  71140. * @param texture defines the BabylonJS internal texture
  71141. * @param createPolynomials will be true if polynomials have been requested
  71142. * @param onLoad defines the callback to trigger once the texture is ready
  71143. * @param onError defines the callback to trigger in case of error
  71144. */
  71145. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71146. /**
  71147. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71148. * @param data contains the texture data
  71149. * @param texture defines the BabylonJS internal texture
  71150. * @param callback defines the method to call once ready to upload
  71151. */
  71152. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71153. }
  71154. }
  71155. declare module BABYLON {
  71156. interface Engine {
  71157. /**
  71158. * Creates a depth stencil cube texture.
  71159. * This is only available in WebGL 2.
  71160. * @param size The size of face edge in the cube texture.
  71161. * @param options The options defining the cube texture.
  71162. * @returns The cube texture
  71163. */
  71164. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  71165. /**
  71166. * Creates a cube texture
  71167. * @param rootUrl defines the url where the files to load is located
  71168. * @param scene defines the current scene
  71169. * @param files defines the list of files to load (1 per face)
  71170. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71171. * @param onLoad defines an optional callback raised when the texture is loaded
  71172. * @param onError defines an optional callback raised if there is an issue to load the texture
  71173. * @param format defines the format of the data
  71174. * @param forcedExtension defines the extension to use to pick the right loader
  71175. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71176. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71177. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71178. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  71179. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  71180. * @returns the cube texture as an InternalTexture
  71181. */
  71182. 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;
  71183. /**
  71184. * Creates a cube texture
  71185. * @param rootUrl defines the url where the files to load is located
  71186. * @param scene defines the current scene
  71187. * @param files defines the list of files to load (1 per face)
  71188. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71189. * @param onLoad defines an optional callback raised when the texture is loaded
  71190. * @param onError defines an optional callback raised if there is an issue to load the texture
  71191. * @param format defines the format of the data
  71192. * @param forcedExtension defines the extension to use to pick the right loader
  71193. * @returns the cube texture as an InternalTexture
  71194. */
  71195. 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;
  71196. /**
  71197. * Creates a cube texture
  71198. * @param rootUrl defines the url where the files to load is located
  71199. * @param scene defines the current scene
  71200. * @param files defines the list of files to load (1 per face)
  71201. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  71202. * @param onLoad defines an optional callback raised when the texture is loaded
  71203. * @param onError defines an optional callback raised if there is an issue to load the texture
  71204. * @param format defines the format of the data
  71205. * @param forcedExtension defines the extension to use to pick the right loader
  71206. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  71207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71209. * @returns the cube texture as an InternalTexture
  71210. */
  71211. 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;
  71212. /** @hidden */
  71213. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71214. /** @hidden */
  71215. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71216. /** @hidden */
  71217. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  71218. /** @hidden */
  71219. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  71220. }
  71221. }
  71222. declare module BABYLON {
  71223. /**
  71224. * Class for creating a cube texture
  71225. */
  71226. export class CubeTexture extends BaseTexture {
  71227. private _delayedOnLoad;
  71228. /**
  71229. * The url of the texture
  71230. */
  71231. url: string;
  71232. /**
  71233. * Gets or sets the center of the bounding box associated with the cube texture.
  71234. * It must define where the camera used to render the texture was set
  71235. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71236. */
  71237. boundingBoxPosition: Vector3;
  71238. private _boundingBoxSize;
  71239. /**
  71240. * Gets or sets the size of the bounding box associated with the cube texture
  71241. * When defined, the cubemap will switch to local mode
  71242. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  71243. * @example https://www.babylonjs-playground.com/#RNASML
  71244. */
  71245. /**
  71246. * Returns the bounding box size
  71247. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  71248. */
  71249. boundingBoxSize: Vector3;
  71250. protected _rotationY: number;
  71251. /**
  71252. * Sets texture matrix rotation angle around Y axis in radians.
  71253. */
  71254. /**
  71255. * Gets texture matrix rotation angle around Y axis radians.
  71256. */
  71257. rotationY: number;
  71258. /**
  71259. * Are mip maps generated for this texture or not.
  71260. */
  71261. readonly noMipmap: boolean;
  71262. private _noMipmap;
  71263. private _files;
  71264. private _extensions;
  71265. private _textureMatrix;
  71266. private _format;
  71267. private _createPolynomials;
  71268. /** @hidden */
  71269. _prefiltered: boolean;
  71270. /**
  71271. * Creates a cube texture from an array of image urls
  71272. * @param files defines an array of image urls
  71273. * @param scene defines the hosting scene
  71274. * @param noMipmap specifies if mip maps are not used
  71275. * @returns a cube texture
  71276. */
  71277. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  71278. /**
  71279. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  71280. * @param url defines the url of the prefiltered texture
  71281. * @param scene defines the scene the texture is attached to
  71282. * @param forcedExtension defines the extension of the file if different from the url
  71283. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71284. * @return the prefiltered texture
  71285. */
  71286. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  71287. /**
  71288. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  71289. * as prefiltered data.
  71290. * @param rootUrl defines the url of the texture or the root name of the six images
  71291. * @param scene defines the scene the texture is attached to
  71292. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  71293. * @param noMipmap defines if mipmaps should be created or not
  71294. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  71295. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  71296. * @param onError defines a callback triggered in case of error during load
  71297. * @param format defines the internal format to use for the texture once loaded
  71298. * @param prefiltered defines whether or not the texture is created from prefiltered data
  71299. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  71300. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  71301. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  71302. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  71303. * @return the cube texture
  71304. */
  71305. 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);
  71306. /**
  71307. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  71308. */
  71309. readonly isPrefiltered: boolean;
  71310. /**
  71311. * Get the current class name of the texture useful for serialization or dynamic coding.
  71312. * @returns "CubeTexture"
  71313. */
  71314. getClassName(): string;
  71315. /**
  71316. * Update the url (and optional buffer) of this texture if url was null during construction.
  71317. * @param url the url of the texture
  71318. * @param forcedExtension defines the extension to use
  71319. * @param onLoad callback called when the texture is loaded (defaults to null)
  71320. */
  71321. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  71322. /**
  71323. * Delays loading of the cube texture
  71324. * @param forcedExtension defines the extension to use
  71325. */
  71326. delayLoad(forcedExtension?: string): void;
  71327. /**
  71328. * Returns the reflection texture matrix
  71329. * @returns the reflection texture matrix
  71330. */
  71331. getReflectionTextureMatrix(): Matrix;
  71332. /**
  71333. * Sets the reflection texture matrix
  71334. * @param value Reflection texture matrix
  71335. */
  71336. setReflectionTextureMatrix(value: Matrix): void;
  71337. /**
  71338. * Parses text to create a cube texture
  71339. * @param parsedTexture define the serialized text to read from
  71340. * @param scene defines the hosting scene
  71341. * @param rootUrl defines the root url of the cube texture
  71342. * @returns a cube texture
  71343. */
  71344. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  71345. /**
  71346. * Makes a clone, or deep copy, of the cube texture
  71347. * @returns a new cube texture
  71348. */
  71349. clone(): CubeTexture;
  71350. }
  71351. }
  71352. declare module BABYLON {
  71353. /**
  71354. * Manages the defines for the Material
  71355. */
  71356. export class MaterialDefines {
  71357. /** @hidden */
  71358. protected _keys: string[];
  71359. private _isDirty;
  71360. /** @hidden */
  71361. _renderId: number;
  71362. /** @hidden */
  71363. _areLightsDirty: boolean;
  71364. /** @hidden */
  71365. _areAttributesDirty: boolean;
  71366. /** @hidden */
  71367. _areTexturesDirty: boolean;
  71368. /** @hidden */
  71369. _areFresnelDirty: boolean;
  71370. /** @hidden */
  71371. _areMiscDirty: boolean;
  71372. /** @hidden */
  71373. _areImageProcessingDirty: boolean;
  71374. /** @hidden */
  71375. _normals: boolean;
  71376. /** @hidden */
  71377. _uvs: boolean;
  71378. /** @hidden */
  71379. _needNormals: boolean;
  71380. /** @hidden */
  71381. _needUVs: boolean;
  71382. [id: string]: any;
  71383. /**
  71384. * Specifies if the material needs to be re-calculated
  71385. */
  71386. readonly isDirty: boolean;
  71387. /**
  71388. * Marks the material to indicate that it has been re-calculated
  71389. */
  71390. markAsProcessed(): void;
  71391. /**
  71392. * Marks the material to indicate that it needs to be re-calculated
  71393. */
  71394. markAsUnprocessed(): void;
  71395. /**
  71396. * Marks the material to indicate all of its defines need to be re-calculated
  71397. */
  71398. markAllAsDirty(): void;
  71399. /**
  71400. * Marks the material to indicate that image processing needs to be re-calculated
  71401. */
  71402. markAsImageProcessingDirty(): void;
  71403. /**
  71404. * Marks the material to indicate the lights need to be re-calculated
  71405. */
  71406. markAsLightDirty(): void;
  71407. /**
  71408. * Marks the attribute state as changed
  71409. */
  71410. markAsAttributesDirty(): void;
  71411. /**
  71412. * Marks the texture state as changed
  71413. */
  71414. markAsTexturesDirty(): void;
  71415. /**
  71416. * Marks the fresnel state as changed
  71417. */
  71418. markAsFresnelDirty(): void;
  71419. /**
  71420. * Marks the misc state as changed
  71421. */
  71422. markAsMiscDirty(): void;
  71423. /**
  71424. * Rebuilds the material defines
  71425. */
  71426. rebuild(): void;
  71427. /**
  71428. * Specifies if two material defines are equal
  71429. * @param other - A material define instance to compare to
  71430. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  71431. */
  71432. isEqual(other: MaterialDefines): boolean;
  71433. /**
  71434. * Clones this instance's defines to another instance
  71435. * @param other - material defines to clone values to
  71436. */
  71437. cloneTo(other: MaterialDefines): void;
  71438. /**
  71439. * Resets the material define values
  71440. */
  71441. reset(): void;
  71442. /**
  71443. * Converts the material define values to a string
  71444. * @returns - String of material define information
  71445. */
  71446. toString(): string;
  71447. }
  71448. }
  71449. declare module BABYLON {
  71450. /**
  71451. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  71452. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  71453. * 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;
  71454. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  71455. */
  71456. export class ColorCurves {
  71457. private _dirty;
  71458. private _tempColor;
  71459. private _globalCurve;
  71460. private _highlightsCurve;
  71461. private _midtonesCurve;
  71462. private _shadowsCurve;
  71463. private _positiveCurve;
  71464. private _negativeCurve;
  71465. private _globalHue;
  71466. private _globalDensity;
  71467. private _globalSaturation;
  71468. private _globalExposure;
  71469. /**
  71470. * Gets the global Hue value.
  71471. * 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).
  71472. */
  71473. /**
  71474. * Sets the global Hue value.
  71475. * 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).
  71476. */
  71477. globalHue: number;
  71478. /**
  71479. * Gets the global Density value.
  71480. * 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.
  71481. * Values less than zero provide a filter of opposite hue.
  71482. */
  71483. /**
  71484. * Sets the global Density value.
  71485. * 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.
  71486. * Values less than zero provide a filter of opposite hue.
  71487. */
  71488. globalDensity: number;
  71489. /**
  71490. * Gets the global Saturation value.
  71491. * 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.
  71492. */
  71493. /**
  71494. * Sets the global Saturation value.
  71495. * 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.
  71496. */
  71497. globalSaturation: number;
  71498. /**
  71499. * Gets the global Exposure value.
  71500. * 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.
  71501. */
  71502. /**
  71503. * Sets the global Exposure value.
  71504. * 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.
  71505. */
  71506. globalExposure: number;
  71507. private _highlightsHue;
  71508. private _highlightsDensity;
  71509. private _highlightsSaturation;
  71510. private _highlightsExposure;
  71511. /**
  71512. * Gets the highlights Hue value.
  71513. * 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).
  71514. */
  71515. /**
  71516. * Sets the highlights Hue value.
  71517. * 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).
  71518. */
  71519. highlightsHue: number;
  71520. /**
  71521. * Gets the highlights Density value.
  71522. * 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.
  71523. * Values less than zero provide a filter of opposite hue.
  71524. */
  71525. /**
  71526. * Sets the highlights Density value.
  71527. * 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.
  71528. * Values less than zero provide a filter of opposite hue.
  71529. */
  71530. highlightsDensity: number;
  71531. /**
  71532. * Gets the highlights Saturation value.
  71533. * 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.
  71534. */
  71535. /**
  71536. * Sets the highlights Saturation value.
  71537. * 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.
  71538. */
  71539. highlightsSaturation: number;
  71540. /**
  71541. * Gets the highlights Exposure value.
  71542. * 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.
  71543. */
  71544. /**
  71545. * Sets the highlights Exposure value.
  71546. * 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.
  71547. */
  71548. highlightsExposure: number;
  71549. private _midtonesHue;
  71550. private _midtonesDensity;
  71551. private _midtonesSaturation;
  71552. private _midtonesExposure;
  71553. /**
  71554. * Gets the midtones Hue value.
  71555. * 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).
  71556. */
  71557. /**
  71558. * Sets the midtones Hue value.
  71559. * 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).
  71560. */
  71561. midtonesHue: number;
  71562. /**
  71563. * Gets the midtones Density value.
  71564. * 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.
  71565. * Values less than zero provide a filter of opposite hue.
  71566. */
  71567. /**
  71568. * Sets the midtones Density value.
  71569. * 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.
  71570. * Values less than zero provide a filter of opposite hue.
  71571. */
  71572. midtonesDensity: number;
  71573. /**
  71574. * Gets the midtones Saturation value.
  71575. * 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.
  71576. */
  71577. /**
  71578. * Sets the midtones Saturation value.
  71579. * 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.
  71580. */
  71581. midtonesSaturation: number;
  71582. /**
  71583. * Gets the midtones Exposure value.
  71584. * 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.
  71585. */
  71586. /**
  71587. * Sets the midtones Exposure value.
  71588. * 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.
  71589. */
  71590. midtonesExposure: number;
  71591. private _shadowsHue;
  71592. private _shadowsDensity;
  71593. private _shadowsSaturation;
  71594. private _shadowsExposure;
  71595. /**
  71596. * Gets the shadows Hue value.
  71597. * 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).
  71598. */
  71599. /**
  71600. * Sets the shadows Hue value.
  71601. * 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).
  71602. */
  71603. shadowsHue: number;
  71604. /**
  71605. * Gets the shadows Density value.
  71606. * 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.
  71607. * Values less than zero provide a filter of opposite hue.
  71608. */
  71609. /**
  71610. * Sets the shadows Density value.
  71611. * 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.
  71612. * Values less than zero provide a filter of opposite hue.
  71613. */
  71614. shadowsDensity: number;
  71615. /**
  71616. * Gets the shadows Saturation value.
  71617. * 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.
  71618. */
  71619. /**
  71620. * Sets the shadows Saturation value.
  71621. * 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.
  71622. */
  71623. shadowsSaturation: number;
  71624. /**
  71625. * Gets the shadows Exposure value.
  71626. * 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.
  71627. */
  71628. /**
  71629. * Sets the shadows Exposure value.
  71630. * 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.
  71631. */
  71632. shadowsExposure: number;
  71633. /**
  71634. * Returns the class name
  71635. * @returns The class name
  71636. */
  71637. getClassName(): string;
  71638. /**
  71639. * Binds the color curves to the shader.
  71640. * @param colorCurves The color curve to bind
  71641. * @param effect The effect to bind to
  71642. * @param positiveUniform The positive uniform shader parameter
  71643. * @param neutralUniform The neutral uniform shader parameter
  71644. * @param negativeUniform The negative uniform shader parameter
  71645. */
  71646. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  71647. /**
  71648. * Prepare the list of uniforms associated with the ColorCurves effects.
  71649. * @param uniformsList The list of uniforms used in the effect
  71650. */
  71651. static PrepareUniforms(uniformsList: string[]): void;
  71652. /**
  71653. * Returns color grading data based on a hue, density, saturation and exposure value.
  71654. * @param filterHue The hue of the color filter.
  71655. * @param filterDensity The density of the color filter.
  71656. * @param saturation The saturation.
  71657. * @param exposure The exposure.
  71658. * @param result The result data container.
  71659. */
  71660. private getColorGradingDataToRef;
  71661. /**
  71662. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  71663. * @param value The input slider value in range [-100,100].
  71664. * @returns Adjusted value.
  71665. */
  71666. private static applyColorGradingSliderNonlinear;
  71667. /**
  71668. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  71669. * @param hue The hue (H) input.
  71670. * @param saturation The saturation (S) input.
  71671. * @param brightness The brightness (B) input.
  71672. * @result An RGBA color represented as Vector4.
  71673. */
  71674. private static fromHSBToRef;
  71675. /**
  71676. * Returns a value clamped between min and max
  71677. * @param value The value to clamp
  71678. * @param min The minimum of value
  71679. * @param max The maximum of value
  71680. * @returns The clamped value.
  71681. */
  71682. private static clamp;
  71683. /**
  71684. * Clones the current color curve instance.
  71685. * @return The cloned curves
  71686. */
  71687. clone(): ColorCurves;
  71688. /**
  71689. * Serializes the current color curve instance to a json representation.
  71690. * @return a JSON representation
  71691. */
  71692. serialize(): any;
  71693. /**
  71694. * Parses the color curve from a json representation.
  71695. * @param source the JSON source to parse
  71696. * @return The parsed curves
  71697. */
  71698. static Parse(source: any): ColorCurves;
  71699. }
  71700. }
  71701. declare module BABYLON {
  71702. /**
  71703. * Interface to follow in your material defines to integrate easily the
  71704. * Image proccessing functions.
  71705. * @hidden
  71706. */
  71707. export interface IImageProcessingConfigurationDefines {
  71708. IMAGEPROCESSING: boolean;
  71709. VIGNETTE: boolean;
  71710. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71711. VIGNETTEBLENDMODEOPAQUE: boolean;
  71712. TONEMAPPING: boolean;
  71713. TONEMAPPING_ACES: boolean;
  71714. CONTRAST: boolean;
  71715. EXPOSURE: boolean;
  71716. COLORCURVES: boolean;
  71717. COLORGRADING: boolean;
  71718. COLORGRADING3D: boolean;
  71719. SAMPLER3DGREENDEPTH: boolean;
  71720. SAMPLER3DBGRMAP: boolean;
  71721. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71722. }
  71723. /**
  71724. * @hidden
  71725. */
  71726. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  71727. IMAGEPROCESSING: boolean;
  71728. VIGNETTE: boolean;
  71729. VIGNETTEBLENDMODEMULTIPLY: boolean;
  71730. VIGNETTEBLENDMODEOPAQUE: boolean;
  71731. TONEMAPPING: boolean;
  71732. TONEMAPPING_ACES: boolean;
  71733. CONTRAST: boolean;
  71734. COLORCURVES: boolean;
  71735. COLORGRADING: boolean;
  71736. COLORGRADING3D: boolean;
  71737. SAMPLER3DGREENDEPTH: boolean;
  71738. SAMPLER3DBGRMAP: boolean;
  71739. IMAGEPROCESSINGPOSTPROCESS: boolean;
  71740. EXPOSURE: boolean;
  71741. constructor();
  71742. }
  71743. /**
  71744. * This groups together the common properties used for image processing either in direct forward pass
  71745. * or through post processing effect depending on the use of the image processing pipeline in your scene
  71746. * or not.
  71747. */
  71748. export class ImageProcessingConfiguration {
  71749. /**
  71750. * Default tone mapping applied in BabylonJS.
  71751. */
  71752. static readonly TONEMAPPING_STANDARD: number;
  71753. /**
  71754. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  71755. * to other engines rendering to increase portability.
  71756. */
  71757. static readonly TONEMAPPING_ACES: number;
  71758. /**
  71759. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  71760. */
  71761. colorCurves: Nullable<ColorCurves>;
  71762. private _colorCurvesEnabled;
  71763. /**
  71764. * Gets wether the color curves effect is enabled.
  71765. */
  71766. /**
  71767. * Sets wether the color curves effect is enabled.
  71768. */
  71769. colorCurvesEnabled: boolean;
  71770. private _colorGradingTexture;
  71771. /**
  71772. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71773. */
  71774. /**
  71775. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  71776. */
  71777. colorGradingTexture: Nullable<BaseTexture>;
  71778. private _colorGradingEnabled;
  71779. /**
  71780. * Gets wether the color grading effect is enabled.
  71781. */
  71782. /**
  71783. * Sets wether the color grading effect is enabled.
  71784. */
  71785. colorGradingEnabled: boolean;
  71786. private _colorGradingWithGreenDepth;
  71787. /**
  71788. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  71789. */
  71790. /**
  71791. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  71792. */
  71793. colorGradingWithGreenDepth: boolean;
  71794. private _colorGradingBGR;
  71795. /**
  71796. * Gets wether the color grading texture contains BGR values.
  71797. */
  71798. /**
  71799. * Sets wether the color grading texture contains BGR values.
  71800. */
  71801. colorGradingBGR: boolean;
  71802. /** @hidden */
  71803. _exposure: number;
  71804. /**
  71805. * Gets the Exposure used in the effect.
  71806. */
  71807. /**
  71808. * Sets the Exposure used in the effect.
  71809. */
  71810. exposure: number;
  71811. private _toneMappingEnabled;
  71812. /**
  71813. * Gets wether the tone mapping effect is enabled.
  71814. */
  71815. /**
  71816. * Sets wether the tone mapping effect is enabled.
  71817. */
  71818. toneMappingEnabled: boolean;
  71819. private _toneMappingType;
  71820. /**
  71821. * Gets the type of tone mapping effect.
  71822. */
  71823. /**
  71824. * Sets the type of tone mapping effect used in BabylonJS.
  71825. */
  71826. toneMappingType: number;
  71827. protected _contrast: number;
  71828. /**
  71829. * Gets the contrast used in the effect.
  71830. */
  71831. /**
  71832. * Sets the contrast used in the effect.
  71833. */
  71834. contrast: number;
  71835. /**
  71836. * Vignette stretch size.
  71837. */
  71838. vignetteStretch: number;
  71839. /**
  71840. * Vignette centre X Offset.
  71841. */
  71842. vignetteCentreX: number;
  71843. /**
  71844. * Vignette centre Y Offset.
  71845. */
  71846. vignetteCentreY: number;
  71847. /**
  71848. * Vignette weight or intensity of the vignette effect.
  71849. */
  71850. vignetteWeight: number;
  71851. /**
  71852. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  71853. * if vignetteEnabled is set to true.
  71854. */
  71855. vignetteColor: Color4;
  71856. /**
  71857. * Camera field of view used by the Vignette effect.
  71858. */
  71859. vignetteCameraFov: number;
  71860. private _vignetteBlendMode;
  71861. /**
  71862. * Gets the vignette blend mode allowing different kind of effect.
  71863. */
  71864. /**
  71865. * Sets the vignette blend mode allowing different kind of effect.
  71866. */
  71867. vignetteBlendMode: number;
  71868. private _vignetteEnabled;
  71869. /**
  71870. * Gets wether the vignette effect is enabled.
  71871. */
  71872. /**
  71873. * Sets wether the vignette effect is enabled.
  71874. */
  71875. vignetteEnabled: boolean;
  71876. private _applyByPostProcess;
  71877. /**
  71878. * Gets wether the image processing is applied through a post process or not.
  71879. */
  71880. /**
  71881. * Sets wether the image processing is applied through a post process or not.
  71882. */
  71883. applyByPostProcess: boolean;
  71884. private _isEnabled;
  71885. /**
  71886. * Gets wether the image processing is enabled or not.
  71887. */
  71888. /**
  71889. * Sets wether the image processing is enabled or not.
  71890. */
  71891. isEnabled: boolean;
  71892. /**
  71893. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  71894. */
  71895. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  71896. /**
  71897. * Method called each time the image processing information changes requires to recompile the effect.
  71898. */
  71899. protected _updateParameters(): void;
  71900. /**
  71901. * Gets the current class name.
  71902. * @return "ImageProcessingConfiguration"
  71903. */
  71904. getClassName(): string;
  71905. /**
  71906. * Prepare the list of uniforms associated with the Image Processing effects.
  71907. * @param uniforms The list of uniforms used in the effect
  71908. * @param defines the list of defines currently in use
  71909. */
  71910. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  71911. /**
  71912. * Prepare the list of samplers associated with the Image Processing effects.
  71913. * @param samplersList The list of uniforms used in the effect
  71914. * @param defines the list of defines currently in use
  71915. */
  71916. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  71917. /**
  71918. * Prepare the list of defines associated to the shader.
  71919. * @param defines the list of defines to complete
  71920. * @param forPostProcess Define if we are currently in post process mode or not
  71921. */
  71922. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  71923. /**
  71924. * Returns true if all the image processing information are ready.
  71925. * @returns True if ready, otherwise, false
  71926. */
  71927. isReady(): boolean;
  71928. /**
  71929. * Binds the image processing to the shader.
  71930. * @param effect The effect to bind to
  71931. * @param aspectRatio Define the current aspect ratio of the effect
  71932. */
  71933. bind(effect: Effect, aspectRatio?: number): void;
  71934. /**
  71935. * Clones the current image processing instance.
  71936. * @return The cloned image processing
  71937. */
  71938. clone(): ImageProcessingConfiguration;
  71939. /**
  71940. * Serializes the current image processing instance to a json representation.
  71941. * @return a JSON representation
  71942. */
  71943. serialize(): any;
  71944. /**
  71945. * Parses the image processing from a json representation.
  71946. * @param source the JSON source to parse
  71947. * @return The parsed image processing
  71948. */
  71949. static Parse(source: any): ImageProcessingConfiguration;
  71950. private static _VIGNETTEMODE_MULTIPLY;
  71951. private static _VIGNETTEMODE_OPAQUE;
  71952. /**
  71953. * Used to apply the vignette as a mix with the pixel color.
  71954. */
  71955. static readonly VIGNETTEMODE_MULTIPLY: number;
  71956. /**
  71957. * Used to apply the vignette as a replacement of the pixel color.
  71958. */
  71959. static readonly VIGNETTEMODE_OPAQUE: number;
  71960. }
  71961. }
  71962. declare module BABYLON {
  71963. /** @hidden */
  71964. export var postprocessVertexShader: {
  71965. name: string;
  71966. shader: string;
  71967. };
  71968. }
  71969. declare module BABYLON {
  71970. /** Defines supported spaces */
  71971. export enum Space {
  71972. /** Local (object) space */
  71973. LOCAL = 0,
  71974. /** World space */
  71975. WORLD = 1,
  71976. /** Bone space */
  71977. BONE = 2
  71978. }
  71979. /** Defines the 3 main axes */
  71980. export class Axis {
  71981. /** X axis */
  71982. static X: Vector3;
  71983. /** Y axis */
  71984. static Y: Vector3;
  71985. /** Z axis */
  71986. static Z: Vector3;
  71987. }
  71988. }
  71989. declare module BABYLON {
  71990. /**
  71991. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  71992. * This is the base of the follow, arc rotate cameras and Free camera
  71993. * @see http://doc.babylonjs.com/features/cameras
  71994. */
  71995. export class TargetCamera extends Camera {
  71996. private static _RigCamTransformMatrix;
  71997. private static _TargetTransformMatrix;
  71998. private static _TargetFocalPoint;
  71999. /**
  72000. * Define the current direction the camera is moving to
  72001. */
  72002. cameraDirection: Vector3;
  72003. /**
  72004. * Define the current rotation the camera is rotating to
  72005. */
  72006. cameraRotation: Vector2;
  72007. /**
  72008. * When set, the up vector of the camera will be updated by the rotation of the camera
  72009. */
  72010. updateUpVectorFromRotation: boolean;
  72011. private _tmpQuaternion;
  72012. /**
  72013. * Define the current rotation of the camera
  72014. */
  72015. rotation: Vector3;
  72016. /**
  72017. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  72018. */
  72019. rotationQuaternion: Quaternion;
  72020. /**
  72021. * Define the current speed of the camera
  72022. */
  72023. speed: number;
  72024. /**
  72025. * Add cconstraint to the camera to prevent it to move freely in all directions and
  72026. * around all axis.
  72027. */
  72028. noRotationConstraint: boolean;
  72029. /**
  72030. * Define the current target of the camera as an object or a position.
  72031. */
  72032. lockedTarget: any;
  72033. /** @hidden */
  72034. _currentTarget: Vector3;
  72035. /** @hidden */
  72036. _initialFocalDistance: number;
  72037. /** @hidden */
  72038. _viewMatrix: Matrix;
  72039. /** @hidden */
  72040. _camMatrix: Matrix;
  72041. /** @hidden */
  72042. _cameraTransformMatrix: Matrix;
  72043. /** @hidden */
  72044. _cameraRotationMatrix: Matrix;
  72045. /** @hidden */
  72046. _referencePoint: Vector3;
  72047. /** @hidden */
  72048. _transformedReferencePoint: Vector3;
  72049. protected _globalCurrentTarget: Vector3;
  72050. protected _globalCurrentUpVector: Vector3;
  72051. /** @hidden */
  72052. _reset: () => void;
  72053. private _defaultUp;
  72054. /**
  72055. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  72056. * This is the base of the follow, arc rotate cameras and Free camera
  72057. * @see http://doc.babylonjs.com/features/cameras
  72058. * @param name Defines the name of the camera in the scene
  72059. * @param position Defines the start position of the camera in the scene
  72060. * @param scene Defines the scene the camera belongs to
  72061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  72062. */
  72063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  72064. /**
  72065. * Gets the position in front of the camera at a given distance.
  72066. * @param distance The distance from the camera we want the position to be
  72067. * @returns the position
  72068. */
  72069. getFrontPosition(distance: number): Vector3;
  72070. /** @hidden */
  72071. _getLockedTargetPosition(): Nullable<Vector3>;
  72072. private _storedPosition;
  72073. private _storedRotation;
  72074. private _storedRotationQuaternion;
  72075. /**
  72076. * Store current camera state of the camera (fov, position, rotation, etc..)
  72077. * @returns the camera
  72078. */
  72079. storeState(): Camera;
  72080. /**
  72081. * Restored camera state. You must call storeState() first
  72082. * @returns whether it was successful or not
  72083. * @hidden
  72084. */
  72085. _restoreStateValues(): boolean;
  72086. /** @hidden */
  72087. _initCache(): void;
  72088. /** @hidden */
  72089. _updateCache(ignoreParentClass?: boolean): void;
  72090. /** @hidden */
  72091. _isSynchronizedViewMatrix(): boolean;
  72092. /** @hidden */
  72093. _computeLocalCameraSpeed(): number;
  72094. /**
  72095. * Defines the target the camera should look at.
  72096. * @param target Defines the new target as a Vector or a mesh
  72097. */
  72098. setTarget(target: Vector3): void;
  72099. /**
  72100. * Return the current target position of the camera. This value is expressed in local space.
  72101. * @returns the target position
  72102. */
  72103. getTarget(): Vector3;
  72104. /** @hidden */
  72105. _decideIfNeedsToMove(): boolean;
  72106. /** @hidden */
  72107. _updatePosition(): void;
  72108. /** @hidden */
  72109. _checkInputs(): void;
  72110. protected _updateCameraRotationMatrix(): void;
  72111. /**
  72112. * 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)
  72113. * @returns the current camera
  72114. */
  72115. private _rotateUpVectorWithCameraRotationMatrix;
  72116. private _cachedRotationZ;
  72117. private _cachedQuaternionRotationZ;
  72118. /** @hidden */
  72119. _getViewMatrix(): Matrix;
  72120. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  72121. /**
  72122. * @hidden
  72123. */
  72124. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  72125. /**
  72126. * @hidden
  72127. */
  72128. _updateRigCameras(): void;
  72129. private _getRigCamPositionAndTarget;
  72130. /**
  72131. * Gets the current object class name.
  72132. * @return the class name
  72133. */
  72134. getClassName(): string;
  72135. }
  72136. }
  72137. declare module BABYLON {
  72138. /**
  72139. * Gather the list of keyboard event types as constants.
  72140. */
  72141. export class KeyboardEventTypes {
  72142. /**
  72143. * The keydown event is fired when a key becomes active (pressed).
  72144. */
  72145. static readonly KEYDOWN: number;
  72146. /**
  72147. * The keyup event is fired when a key has been released.
  72148. */
  72149. static readonly KEYUP: number;
  72150. }
  72151. /**
  72152. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72153. */
  72154. export class KeyboardInfo {
  72155. /**
  72156. * Defines the type of event (KeyboardEventTypes)
  72157. */
  72158. type: number;
  72159. /**
  72160. * Defines the related dom event
  72161. */
  72162. event: KeyboardEvent;
  72163. /**
  72164. * Instantiates a new keyboard info.
  72165. * This class is used to store keyboard related info for the onKeyboardObservable event.
  72166. * @param type Defines the type of event (KeyboardEventTypes)
  72167. * @param event Defines the related dom event
  72168. */
  72169. constructor(
  72170. /**
  72171. * Defines the type of event (KeyboardEventTypes)
  72172. */
  72173. type: number,
  72174. /**
  72175. * Defines the related dom event
  72176. */
  72177. event: KeyboardEvent);
  72178. }
  72179. /**
  72180. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72181. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  72182. */
  72183. export class KeyboardInfoPre extends KeyboardInfo {
  72184. /**
  72185. * Defines the type of event (KeyboardEventTypes)
  72186. */
  72187. type: number;
  72188. /**
  72189. * Defines the related dom event
  72190. */
  72191. event: KeyboardEvent;
  72192. /**
  72193. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  72194. */
  72195. skipOnPointerObservable: boolean;
  72196. /**
  72197. * Instantiates a new keyboard pre info.
  72198. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  72199. * @param type Defines the type of event (KeyboardEventTypes)
  72200. * @param event Defines the related dom event
  72201. */
  72202. constructor(
  72203. /**
  72204. * Defines the type of event (KeyboardEventTypes)
  72205. */
  72206. type: number,
  72207. /**
  72208. * Defines the related dom event
  72209. */
  72210. event: KeyboardEvent);
  72211. }
  72212. }
  72213. declare module BABYLON {
  72214. /**
  72215. * Manage the keyboard inputs to control the movement of a free camera.
  72216. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72217. */
  72218. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  72219. /**
  72220. * Defines the camera the input is attached to.
  72221. */
  72222. camera: FreeCamera;
  72223. /**
  72224. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  72225. */
  72226. keysUp: number[];
  72227. /**
  72228. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  72229. */
  72230. keysDown: number[];
  72231. /**
  72232. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  72233. */
  72234. keysLeft: number[];
  72235. /**
  72236. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  72237. */
  72238. keysRight: number[];
  72239. private _keys;
  72240. private _onCanvasBlurObserver;
  72241. private _onKeyboardObserver;
  72242. private _engine;
  72243. private _scene;
  72244. /**
  72245. * Attach the input controls to a specific dom element to get the input from.
  72246. * @param element Defines the element the controls should be listened from
  72247. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72248. */
  72249. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72250. /**
  72251. * Detach the current controls from the specified dom element.
  72252. * @param element Defines the element to stop listening the inputs from
  72253. */
  72254. detachControl(element: Nullable<HTMLElement>): void;
  72255. /**
  72256. * Update the current camera state depending on the inputs that have been used this frame.
  72257. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72258. */
  72259. checkInputs(): void;
  72260. /**
  72261. * Gets the class name of the current intput.
  72262. * @returns the class name
  72263. */
  72264. getClassName(): string;
  72265. /** @hidden */
  72266. _onLostFocus(): void;
  72267. /**
  72268. * Get the friendly name associated with the input class.
  72269. * @returns the input friendly name
  72270. */
  72271. getSimpleName(): string;
  72272. }
  72273. }
  72274. declare module BABYLON {
  72275. /**
  72276. * Interface describing all the common properties and methods a shadow light needs to implement.
  72277. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  72278. * as well as binding the different shadow properties to the effects.
  72279. */
  72280. export interface IShadowLight extends Light {
  72281. /**
  72282. * The light id in the scene (used in scene.findLighById for instance)
  72283. */
  72284. id: string;
  72285. /**
  72286. * The position the shdow will be casted from.
  72287. */
  72288. position: Vector3;
  72289. /**
  72290. * In 2d mode (needCube being false), the direction used to cast the shadow.
  72291. */
  72292. direction: Vector3;
  72293. /**
  72294. * The transformed position. Position of the light in world space taking parenting in account.
  72295. */
  72296. transformedPosition: Vector3;
  72297. /**
  72298. * The transformed direction. Direction of the light in world space taking parenting in account.
  72299. */
  72300. transformedDirection: Vector3;
  72301. /**
  72302. * The friendly name of the light in the scene.
  72303. */
  72304. name: string;
  72305. /**
  72306. * Defines the shadow projection clipping minimum z value.
  72307. */
  72308. shadowMinZ: number;
  72309. /**
  72310. * Defines the shadow projection clipping maximum z value.
  72311. */
  72312. shadowMaxZ: number;
  72313. /**
  72314. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72315. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72316. */
  72317. computeTransformedInformation(): boolean;
  72318. /**
  72319. * Gets the scene the light belongs to.
  72320. * @returns The scene
  72321. */
  72322. getScene(): Scene;
  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. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72330. * @param matrix The materix to updated with the projection information
  72331. * @param viewMatrix The transform matrix of the light
  72332. * @param renderList The list of mesh to render in the map
  72333. * @returns The current light
  72334. */
  72335. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72336. /**
  72337. * Gets the current depth scale used in ESM.
  72338. * @returns The scale
  72339. */
  72340. getDepthScale(): number;
  72341. /**
  72342. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72343. * @returns true if a cube texture needs to be use
  72344. */
  72345. needCube(): boolean;
  72346. /**
  72347. * Detects if the projection matrix requires to be recomputed this frame.
  72348. * @returns true if it requires to be recomputed otherwise, false.
  72349. */
  72350. needProjectionMatrixCompute(): boolean;
  72351. /**
  72352. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72353. */
  72354. forceProjectionMatrixCompute(): void;
  72355. /**
  72356. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72357. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72358. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72359. */
  72360. getShadowDirection(faceIndex?: number): Vector3;
  72361. /**
  72362. * Gets the minZ used for shadow according to both the scene and the light.
  72363. * @param activeCamera The camera we are returning the min for
  72364. * @returns the depth min z
  72365. */
  72366. getDepthMinZ(activeCamera: Camera): number;
  72367. /**
  72368. * Gets the maxZ used for shadow according to both the scene and the light.
  72369. * @param activeCamera The camera we are returning the max for
  72370. * @returns the depth max z
  72371. */
  72372. getDepthMaxZ(activeCamera: Camera): number;
  72373. }
  72374. /**
  72375. * Base implementation IShadowLight
  72376. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  72377. */
  72378. export abstract class ShadowLight extends Light implements IShadowLight {
  72379. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  72380. protected _position: Vector3;
  72381. protected _setPosition(value: Vector3): void;
  72382. /**
  72383. * Sets the position the shadow will be casted from. Also use as the light position for both
  72384. * point and spot lights.
  72385. */
  72386. /**
  72387. * Sets the position the shadow will be casted from. Also use as the light position for both
  72388. * point and spot lights.
  72389. */
  72390. position: Vector3;
  72391. protected _direction: Vector3;
  72392. protected _setDirection(value: Vector3): void;
  72393. /**
  72394. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  72395. * Also use as the light direction on spot and directional lights.
  72396. */
  72397. /**
  72398. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  72399. * Also use as the light direction on spot and directional lights.
  72400. */
  72401. direction: Vector3;
  72402. private _shadowMinZ;
  72403. /**
  72404. * Gets the shadow projection clipping minimum z value.
  72405. */
  72406. /**
  72407. * Sets the shadow projection clipping minimum z value.
  72408. */
  72409. shadowMinZ: number;
  72410. private _shadowMaxZ;
  72411. /**
  72412. * Sets the shadow projection clipping maximum z value.
  72413. */
  72414. /**
  72415. * Gets the shadow projection clipping maximum z value.
  72416. */
  72417. shadowMaxZ: number;
  72418. /**
  72419. * Callback defining a custom Projection Matrix Builder.
  72420. * This can be used to override the default projection matrix computation.
  72421. */
  72422. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  72423. /**
  72424. * The transformed position. Position of the light in world space taking parenting in account.
  72425. */
  72426. transformedPosition: Vector3;
  72427. /**
  72428. * The transformed direction. Direction of the light in world space taking parenting in account.
  72429. */
  72430. transformedDirection: Vector3;
  72431. private _needProjectionMatrixCompute;
  72432. /**
  72433. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  72434. * @returns true if the information has been computed, false if it does not need to (no parenting)
  72435. */
  72436. computeTransformedInformation(): boolean;
  72437. /**
  72438. * Return the depth scale used for the shadow map.
  72439. * @returns the depth scale.
  72440. */
  72441. getDepthScale(): number;
  72442. /**
  72443. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  72444. * @param faceIndex The index of the face we are computed the direction to generate shadow
  72445. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  72446. */
  72447. getShadowDirection(faceIndex?: number): Vector3;
  72448. /**
  72449. * Returns the ShadowLight absolute position in the World.
  72450. * @returns the position vector in world space
  72451. */
  72452. getAbsolutePosition(): Vector3;
  72453. /**
  72454. * Sets the ShadowLight direction toward the passed target.
  72455. * @param target The point to target in local space
  72456. * @returns the updated ShadowLight direction
  72457. */
  72458. setDirectionToTarget(target: Vector3): Vector3;
  72459. /**
  72460. * Returns the light rotation in euler definition.
  72461. * @returns the x y z rotation in local space.
  72462. */
  72463. getRotation(): Vector3;
  72464. /**
  72465. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  72466. * @returns true if a cube texture needs to be use
  72467. */
  72468. needCube(): boolean;
  72469. /**
  72470. * Detects if the projection matrix requires to be recomputed this frame.
  72471. * @returns true if it requires to be recomputed otherwise, false.
  72472. */
  72473. needProjectionMatrixCompute(): boolean;
  72474. /**
  72475. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  72476. */
  72477. forceProjectionMatrixCompute(): void;
  72478. /** @hidden */
  72479. _initCache(): void;
  72480. /** @hidden */
  72481. _isSynchronized(): boolean;
  72482. /**
  72483. * Computes the world matrix of the node
  72484. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72485. * @returns the world matrix
  72486. */
  72487. computeWorldMatrix(force?: boolean): Matrix;
  72488. /**
  72489. * Gets the minZ used for shadow according to both the scene and the light.
  72490. * @param activeCamera The camera we are returning the min for
  72491. * @returns the depth min z
  72492. */
  72493. getDepthMinZ(activeCamera: Camera): number;
  72494. /**
  72495. * Gets the maxZ used for shadow according to both the scene and the light.
  72496. * @param activeCamera The camera we are returning the max for
  72497. * @returns the depth max z
  72498. */
  72499. getDepthMaxZ(activeCamera: Camera): number;
  72500. /**
  72501. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  72502. * @param matrix The materix to updated with the projection information
  72503. * @param viewMatrix The transform matrix of the light
  72504. * @param renderList The list of mesh to render in the map
  72505. * @returns The current light
  72506. */
  72507. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  72508. }
  72509. }
  72510. declare module BABYLON {
  72511. /**
  72512. * "Static Class" containing the most commonly used helper while dealing with material for
  72513. * rendering purpose.
  72514. *
  72515. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  72516. *
  72517. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  72518. */
  72519. export class MaterialHelper {
  72520. /**
  72521. * Bind the current view position to an effect.
  72522. * @param effect The effect to be bound
  72523. * @param scene The scene the eyes position is used from
  72524. */
  72525. static BindEyePosition(effect: Effect, scene: Scene): void;
  72526. /**
  72527. * Helps preparing the defines values about the UVs in used in the effect.
  72528. * UVs are shared as much as we can accross channels in the shaders.
  72529. * @param texture The texture we are preparing the UVs for
  72530. * @param defines The defines to update
  72531. * @param key The channel key "diffuse", "specular"... used in the shader
  72532. */
  72533. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  72534. /**
  72535. * Binds a texture matrix value to its corrsponding uniform
  72536. * @param texture The texture to bind the matrix for
  72537. * @param uniformBuffer The uniform buffer receivin the data
  72538. * @param key The channel key "diffuse", "specular"... used in the shader
  72539. */
  72540. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  72541. /**
  72542. * Gets the current status of the fog (should it be enabled?)
  72543. * @param mesh defines the mesh to evaluate for fog support
  72544. * @param scene defines the hosting scene
  72545. * @returns true if fog must be enabled
  72546. */
  72547. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  72548. /**
  72549. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  72550. * @param mesh defines the current mesh
  72551. * @param scene defines the current scene
  72552. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  72553. * @param pointsCloud defines if point cloud rendering has to be turned on
  72554. * @param fogEnabled defines if fog has to be turned on
  72555. * @param alphaTest defines if alpha testing has to be turned on
  72556. * @param defines defines the current list of defines
  72557. */
  72558. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  72559. /**
  72560. * Helper used to prepare the list of defines associated with frame values for shader compilation
  72561. * @param scene defines the current scene
  72562. * @param engine defines the current engine
  72563. * @param defines specifies the list of active defines
  72564. * @param useInstances defines if instances have to be turned on
  72565. * @param useClipPlane defines if clip plane have to be turned on
  72566. */
  72567. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  72568. /**
  72569. * Prepares the defines for bones
  72570. * @param mesh The mesh containing the geometry data we will draw
  72571. * @param defines The defines to update
  72572. */
  72573. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  72574. /**
  72575. * Prepares the defines for morph targets
  72576. * @param mesh The mesh containing the geometry data we will draw
  72577. * @param defines The defines to update
  72578. */
  72579. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  72580. /**
  72581. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  72582. * @param mesh The mesh containing the geometry data we will draw
  72583. * @param defines The defines to update
  72584. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  72585. * @param useBones Precise whether bones should be used or not (override mesh info)
  72586. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  72587. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  72588. * @returns false if defines are considered not dirty and have not been checked
  72589. */
  72590. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  72591. /**
  72592. * Prepares the defines related to multiview
  72593. * @param scene The scene we are intending to draw
  72594. * @param defines The defines to update
  72595. */
  72596. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  72597. /**
  72598. * Prepares the defines related to the light information passed in parameter
  72599. * @param scene The scene we are intending to draw
  72600. * @param mesh The mesh the effect is compiling for
  72601. * @param light The light the effect is compiling for
  72602. * @param lightIndex The index of the light
  72603. * @param defines The defines to update
  72604. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72605. * @param state Defines the current state regarding what is needed (normals, etc...)
  72606. */
  72607. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  72608. needNormals: boolean;
  72609. needRebuild: boolean;
  72610. shadowEnabled: boolean;
  72611. specularEnabled: boolean;
  72612. lightmapMode: boolean;
  72613. }): void;
  72614. /**
  72615. * Prepares the defines related to the light information passed in parameter
  72616. * @param scene The scene we are intending to draw
  72617. * @param mesh The mesh the effect is compiling for
  72618. * @param defines The defines to update
  72619. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  72620. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  72621. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  72622. * @returns true if normals will be required for the rest of the effect
  72623. */
  72624. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  72625. /**
  72626. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  72627. * @param lightIndex defines the light index
  72628. * @param uniformsList The uniform list
  72629. * @param samplersList The sampler list
  72630. * @param projectedLightTexture defines if projected texture must be used
  72631. * @param uniformBuffersList defines an optional list of uniform buffers
  72632. */
  72633. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  72634. /**
  72635. * Prepares the uniforms and samplers list to be used in the effect
  72636. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  72637. * @param samplersList The sampler list
  72638. * @param defines The defines helping in the list generation
  72639. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  72640. */
  72641. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  72642. /**
  72643. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  72644. * @param defines The defines to update while falling back
  72645. * @param fallbacks The authorized effect fallbacks
  72646. * @param maxSimultaneousLights The maximum number of lights allowed
  72647. * @param rank the current rank of the Effect
  72648. * @returns The newly affected rank
  72649. */
  72650. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  72651. private static _TmpMorphInfluencers;
  72652. /**
  72653. * Prepares the list of attributes required for morph targets according to the effect defines.
  72654. * @param attribs The current list of supported attribs
  72655. * @param mesh The mesh to prepare the morph targets attributes for
  72656. * @param influencers The number of influencers
  72657. */
  72658. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  72659. /**
  72660. * Prepares the list of attributes required for morph targets according to the effect defines.
  72661. * @param attribs The current list of supported attribs
  72662. * @param mesh The mesh to prepare the morph targets attributes for
  72663. * @param defines The current Defines of the effect
  72664. */
  72665. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  72666. /**
  72667. * Prepares the list of attributes required for bones according to the effect defines.
  72668. * @param attribs The current list of supported attribs
  72669. * @param mesh The mesh to prepare the bones attributes for
  72670. * @param defines The current Defines of the effect
  72671. * @param fallbacks The current efffect fallback strategy
  72672. */
  72673. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  72674. /**
  72675. * Check and prepare the list of attributes required for instances according to the effect defines.
  72676. * @param attribs The current list of supported attribs
  72677. * @param defines The current MaterialDefines of the effect
  72678. */
  72679. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  72680. /**
  72681. * Add the list of attributes required for instances to the attribs array.
  72682. * @param attribs The current list of supported attribs
  72683. */
  72684. static PushAttributesForInstances(attribs: string[]): void;
  72685. /**
  72686. * Binds the light shadow information to the effect for the given mesh.
  72687. * @param light The light containing the generator
  72688. * @param scene The scene the lights belongs to
  72689. * @param mesh The mesh we are binding the information to render
  72690. * @param lightIndex The light index in the effect used to render the mesh
  72691. * @param effect The effect we are binding the data to
  72692. */
  72693. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  72694. /**
  72695. * Binds the light information to the effect.
  72696. * @param light The light containing the generator
  72697. * @param effect The effect we are binding the data to
  72698. * @param lightIndex The light index in the effect used to render
  72699. */
  72700. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  72701. /**
  72702. * Binds the lights information from the scene to the effect for the given mesh.
  72703. * @param light Light to bind
  72704. * @param lightIndex Light index
  72705. * @param scene The scene where the light belongs to
  72706. * @param mesh The mesh we are binding the information to render
  72707. * @param effect The effect we are binding the data to
  72708. * @param useSpecular Defines if specular is supported
  72709. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72710. */
  72711. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  72712. /**
  72713. * Binds the lights information from the scene to the effect for the given mesh.
  72714. * @param scene The scene the lights belongs to
  72715. * @param mesh The mesh we are binding the information to render
  72716. * @param effect The effect we are binding the data to
  72717. * @param defines The generated defines for the effect
  72718. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  72719. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  72720. */
  72721. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  72722. private static _tempFogColor;
  72723. /**
  72724. * Binds the fog information from the scene to the effect for the given mesh.
  72725. * @param scene The scene the lights belongs to
  72726. * @param mesh The mesh we are binding the information to render
  72727. * @param effect The effect we are binding the data to
  72728. * @param linearSpace Defines if the fog effect is applied in linear space
  72729. */
  72730. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  72731. /**
  72732. * Binds the bones information from the mesh to the effect.
  72733. * @param mesh The mesh we are binding the information to render
  72734. * @param effect The effect we are binding the data to
  72735. */
  72736. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  72737. /**
  72738. * Binds the morph targets information from the mesh to the effect.
  72739. * @param abstractMesh The mesh we are binding the information to render
  72740. * @param effect The effect we are binding the data to
  72741. */
  72742. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  72743. /**
  72744. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  72745. * @param defines The generated defines used in the effect
  72746. * @param effect The effect we are binding the data to
  72747. * @param scene The scene we are willing to render with logarithmic scale for
  72748. */
  72749. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  72750. /**
  72751. * Binds the clip plane information from the scene to the effect.
  72752. * @param scene The scene the clip plane information are extracted from
  72753. * @param effect The effect we are binding the data to
  72754. */
  72755. static BindClipPlane(effect: Effect, scene: Scene): void;
  72756. }
  72757. }
  72758. declare module BABYLON {
  72759. /** @hidden */
  72760. export var packingFunctions: {
  72761. name: string;
  72762. shader: string;
  72763. };
  72764. }
  72765. declare module BABYLON {
  72766. /** @hidden */
  72767. export var shadowMapPixelShader: {
  72768. name: string;
  72769. shader: string;
  72770. };
  72771. }
  72772. declare module BABYLON {
  72773. /** @hidden */
  72774. export var bonesDeclaration: {
  72775. name: string;
  72776. shader: string;
  72777. };
  72778. }
  72779. declare module BABYLON {
  72780. /** @hidden */
  72781. export var morphTargetsVertexGlobalDeclaration: {
  72782. name: string;
  72783. shader: string;
  72784. };
  72785. }
  72786. declare module BABYLON {
  72787. /** @hidden */
  72788. export var morphTargetsVertexDeclaration: {
  72789. name: string;
  72790. shader: string;
  72791. };
  72792. }
  72793. declare module BABYLON {
  72794. /** @hidden */
  72795. export var instancesDeclaration: {
  72796. name: string;
  72797. shader: string;
  72798. };
  72799. }
  72800. declare module BABYLON {
  72801. /** @hidden */
  72802. export var helperFunctions: {
  72803. name: string;
  72804. shader: string;
  72805. };
  72806. }
  72807. declare module BABYLON {
  72808. /** @hidden */
  72809. export var morphTargetsVertex: {
  72810. name: string;
  72811. shader: string;
  72812. };
  72813. }
  72814. declare module BABYLON {
  72815. /** @hidden */
  72816. export var instancesVertex: {
  72817. name: string;
  72818. shader: string;
  72819. };
  72820. }
  72821. declare module BABYLON {
  72822. /** @hidden */
  72823. export var bonesVertex: {
  72824. name: string;
  72825. shader: string;
  72826. };
  72827. }
  72828. declare module BABYLON {
  72829. /** @hidden */
  72830. export var shadowMapVertexShader: {
  72831. name: string;
  72832. shader: string;
  72833. };
  72834. }
  72835. declare module BABYLON {
  72836. /** @hidden */
  72837. export var depthBoxBlurPixelShader: {
  72838. name: string;
  72839. shader: string;
  72840. };
  72841. }
  72842. declare module BABYLON {
  72843. /**
  72844. * Defines the options associated with the creation of a custom shader for a shadow generator.
  72845. */
  72846. export interface ICustomShaderOptions {
  72847. /**
  72848. * Gets or sets the custom shader name to use
  72849. */
  72850. shaderName: string;
  72851. /**
  72852. * The list of attribute names used in the shader
  72853. */
  72854. attributes?: string[];
  72855. /**
  72856. * The list of unifrom names used in the shader
  72857. */
  72858. uniforms?: string[];
  72859. /**
  72860. * The list of sampler names used in the shader
  72861. */
  72862. samplers?: string[];
  72863. /**
  72864. * The list of defines used in the shader
  72865. */
  72866. defines?: string[];
  72867. }
  72868. /**
  72869. * Interface to implement to create a shadow generator compatible with BJS.
  72870. */
  72871. export interface IShadowGenerator {
  72872. /**
  72873. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72874. * @returns The render target texture if present otherwise, null
  72875. */
  72876. getShadowMap(): Nullable<RenderTargetTexture>;
  72877. /**
  72878. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72879. * @returns The render target texture if the shadow map is present otherwise, null
  72880. */
  72881. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72882. /**
  72883. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72884. * @param subMesh The submesh we want to render in the shadow map
  72885. * @param useInstances Defines wether will draw in the map using instances
  72886. * @returns true if ready otherwise, false
  72887. */
  72888. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72889. /**
  72890. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72891. * @param defines Defines of the material we want to update
  72892. * @param lightIndex Index of the light in the enabled light list of the material
  72893. */
  72894. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  72895. /**
  72896. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72897. * defined in the generator but impacting the effect).
  72898. * It implies the unifroms available on the materials are the standard BJS ones.
  72899. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72900. * @param effect The effect we are binfing the information for
  72901. */
  72902. bindShadowLight(lightIndex: string, effect: Effect): void;
  72903. /**
  72904. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72905. * (eq to shadow prjection matrix * light transform matrix)
  72906. * @returns The transform matrix used to create the shadow map
  72907. */
  72908. getTransformMatrix(): Matrix;
  72909. /**
  72910. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72911. * Cube and 2D textures for instance.
  72912. */
  72913. recreateShadowMap(): void;
  72914. /**
  72915. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72916. * @param onCompiled Callback triggered at the and of the effects compilation
  72917. * @param options Sets of optional options forcing the compilation with different modes
  72918. */
  72919. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72920. useInstances: boolean;
  72921. }>): void;
  72922. /**
  72923. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72924. * @param options Sets of optional options forcing the compilation with different modes
  72925. * @returns A promise that resolves when the compilation completes
  72926. */
  72927. forceCompilationAsync(options?: Partial<{
  72928. useInstances: boolean;
  72929. }>): Promise<void>;
  72930. /**
  72931. * Serializes the shadow generator setup to a json object.
  72932. * @returns The serialized JSON object
  72933. */
  72934. serialize(): any;
  72935. /**
  72936. * Disposes the Shadow map and related Textures and effects.
  72937. */
  72938. dispose(): void;
  72939. }
  72940. /**
  72941. * Default implementation IShadowGenerator.
  72942. * This is the main object responsible of generating shadows in the framework.
  72943. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  72944. */
  72945. export class ShadowGenerator implements IShadowGenerator {
  72946. /**
  72947. * Shadow generator mode None: no filtering applied.
  72948. */
  72949. static readonly FILTER_NONE: number;
  72950. /**
  72951. * Shadow generator mode ESM: Exponential Shadow Mapping.
  72952. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72953. */
  72954. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  72955. /**
  72956. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  72957. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  72958. */
  72959. static readonly FILTER_POISSONSAMPLING: number;
  72960. /**
  72961. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  72962. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72963. */
  72964. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  72965. /**
  72966. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  72967. * edge artifacts on steep falloff.
  72968. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72969. */
  72970. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  72971. /**
  72972. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  72973. * edge artifacts on steep falloff.
  72974. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  72975. */
  72976. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  72977. /**
  72978. * Shadow generator mode PCF: Percentage Closer Filtering
  72979. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72980. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  72981. */
  72982. static readonly FILTER_PCF: number;
  72983. /**
  72984. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  72985. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  72986. * Contact Hardening
  72987. */
  72988. static readonly FILTER_PCSS: number;
  72989. /**
  72990. * Reserved for PCF and PCSS
  72991. * Highest Quality.
  72992. *
  72993. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  72994. *
  72995. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  72996. */
  72997. static readonly QUALITY_HIGH: number;
  72998. /**
  72999. * Reserved for PCF and PCSS
  73000. * Good tradeoff for quality/perf cross devices
  73001. *
  73002. * Execute PCF on a 3*3 kernel.
  73003. *
  73004. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73005. */
  73006. static readonly QUALITY_MEDIUM: number;
  73007. /**
  73008. * Reserved for PCF and PCSS
  73009. * The lowest quality but the fastest.
  73010. *
  73011. * Execute PCF on a 1*1 kernel.
  73012. *
  73013. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73014. */
  73015. static readonly QUALITY_LOW: number;
  73016. /** Gets or sets the custom shader name to use */
  73017. customShaderOptions: ICustomShaderOptions;
  73018. /**
  73019. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73020. */
  73021. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73022. /**
  73023. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73024. */
  73025. onAfterShadowMapRenderObservable: Observable<Effect>;
  73026. /**
  73027. * Observable triggered before a mesh is rendered in the shadow map.
  73028. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73029. */
  73030. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73031. /**
  73032. * Observable triggered after a mesh is rendered in the shadow map.
  73033. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73034. */
  73035. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73036. private _bias;
  73037. /**
  73038. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73039. */
  73040. /**
  73041. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73042. */
  73043. bias: number;
  73044. private _normalBias;
  73045. /**
  73046. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73047. */
  73048. /**
  73049. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73050. */
  73051. normalBias: number;
  73052. private _blurBoxOffset;
  73053. /**
  73054. * Gets the blur box offset: offset applied during the blur pass.
  73055. * Only useful if useKernelBlur = false
  73056. */
  73057. /**
  73058. * Sets the blur box offset: offset applied during the blur pass.
  73059. * Only useful if useKernelBlur = false
  73060. */
  73061. blurBoxOffset: number;
  73062. private _blurScale;
  73063. /**
  73064. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73065. * 2 means half of the size.
  73066. */
  73067. /**
  73068. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73069. * 2 means half of the size.
  73070. */
  73071. blurScale: number;
  73072. private _blurKernel;
  73073. /**
  73074. * Gets the blur kernel: kernel size of the blur pass.
  73075. * Only useful if useKernelBlur = true
  73076. */
  73077. /**
  73078. * Sets the blur kernel: kernel size of the blur pass.
  73079. * Only useful if useKernelBlur = true
  73080. */
  73081. blurKernel: number;
  73082. private _useKernelBlur;
  73083. /**
  73084. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73085. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73086. */
  73087. /**
  73088. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73089. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73090. */
  73091. useKernelBlur: boolean;
  73092. private _depthScale;
  73093. /**
  73094. * Gets the depth scale used in ESM mode.
  73095. */
  73096. /**
  73097. * Sets the depth scale used in ESM mode.
  73098. * This can override the scale stored on the light.
  73099. */
  73100. depthScale: number;
  73101. private _filter;
  73102. /**
  73103. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  73104. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73105. */
  73106. /**
  73107. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  73108. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  73109. */
  73110. filter: number;
  73111. /**
  73112. * Gets if the current filter is set to Poisson Sampling.
  73113. */
  73114. /**
  73115. * Sets the current filter to Poisson Sampling.
  73116. */
  73117. usePoissonSampling: boolean;
  73118. /**
  73119. * Gets if the current filter is set to ESM.
  73120. */
  73121. /**
  73122. * Sets the current filter is to ESM.
  73123. */
  73124. useExponentialShadowMap: boolean;
  73125. /**
  73126. * Gets if the current filter is set to filtered ESM.
  73127. */
  73128. /**
  73129. * Gets if the current filter is set to filtered ESM.
  73130. */
  73131. useBlurExponentialShadowMap: boolean;
  73132. /**
  73133. * Gets if the current filter is set to "close ESM" (using the inverse of the
  73134. * exponential to prevent steep falloff artifacts).
  73135. */
  73136. /**
  73137. * Sets the current filter to "close ESM" (using the inverse of the
  73138. * exponential to prevent steep falloff artifacts).
  73139. */
  73140. useCloseExponentialShadowMap: boolean;
  73141. /**
  73142. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  73143. * exponential to prevent steep falloff artifacts).
  73144. */
  73145. /**
  73146. * Sets the current filter to filtered "close ESM" (using the inverse of the
  73147. * exponential to prevent steep falloff artifacts).
  73148. */
  73149. useBlurCloseExponentialShadowMap: boolean;
  73150. /**
  73151. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  73152. */
  73153. /**
  73154. * Sets the current filter to "PCF" (percentage closer filtering).
  73155. */
  73156. usePercentageCloserFiltering: boolean;
  73157. private _filteringQuality;
  73158. /**
  73159. * Gets the PCF or PCSS Quality.
  73160. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73161. */
  73162. /**
  73163. * Sets the PCF or PCSS Quality.
  73164. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  73165. */
  73166. filteringQuality: number;
  73167. /**
  73168. * Gets if the current filter is set to "PCSS" (contact hardening).
  73169. */
  73170. /**
  73171. * Sets the current filter to "PCSS" (contact hardening).
  73172. */
  73173. useContactHardeningShadow: boolean;
  73174. private _contactHardeningLightSizeUVRatio;
  73175. /**
  73176. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73177. * Using a ratio helps keeping shape stability independently of the map size.
  73178. *
  73179. * It does not account for the light projection as it was having too much
  73180. * instability during the light setup or during light position changes.
  73181. *
  73182. * Only valid if useContactHardeningShadow is true.
  73183. */
  73184. /**
  73185. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  73186. * Using a ratio helps keeping shape stability independently of the map size.
  73187. *
  73188. * It does not account for the light projection as it was having too much
  73189. * instability during the light setup or during light position changes.
  73190. *
  73191. * Only valid if useContactHardeningShadow is true.
  73192. */
  73193. contactHardeningLightSizeUVRatio: number;
  73194. private _darkness;
  73195. /** Gets or sets the actual darkness of a shadow */
  73196. darkness: number;
  73197. /**
  73198. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  73199. * 0 means strongest and 1 would means no shadow.
  73200. * @returns the darkness.
  73201. */
  73202. getDarkness(): number;
  73203. /**
  73204. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  73205. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  73206. * @returns the shadow generator allowing fluent coding.
  73207. */
  73208. setDarkness(darkness: number): ShadowGenerator;
  73209. private _transparencyShadow;
  73210. /** Gets or sets the ability to have transparent shadow */
  73211. transparencyShadow: boolean;
  73212. /**
  73213. * Sets the ability to have transparent shadow (boolean).
  73214. * @param transparent True if transparent else False
  73215. * @returns the shadow generator allowing fluent coding
  73216. */
  73217. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  73218. private _shadowMap;
  73219. private _shadowMap2;
  73220. /**
  73221. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73222. * @returns The render target texture if present otherwise, null
  73223. */
  73224. getShadowMap(): Nullable<RenderTargetTexture>;
  73225. /**
  73226. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73227. * @returns The render target texture if the shadow map is present otherwise, null
  73228. */
  73229. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73230. /**
  73231. * Gets the class name of that object
  73232. * @returns "ShadowGenerator"
  73233. */
  73234. getClassName(): string;
  73235. /**
  73236. * Helper function to add a mesh and its descendants to the list of shadow casters.
  73237. * @param mesh Mesh to add
  73238. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  73239. * @returns the Shadow Generator itself
  73240. */
  73241. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73242. /**
  73243. * Helper function to remove a mesh and its descendants from the list of shadow casters
  73244. * @param mesh Mesh to remove
  73245. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  73246. * @returns the Shadow Generator itself
  73247. */
  73248. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  73249. /**
  73250. * Controls the extent to which the shadows fade out at the edge of the frustum
  73251. * Used only by directionals and spots
  73252. */
  73253. frustumEdgeFalloff: number;
  73254. private _light;
  73255. /**
  73256. * Returns the associated light object.
  73257. * @returns the light generating the shadow
  73258. */
  73259. getLight(): IShadowLight;
  73260. /**
  73261. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  73262. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  73263. * It might on the other hand introduce peter panning.
  73264. */
  73265. forceBackFacesOnly: boolean;
  73266. private _scene;
  73267. private _lightDirection;
  73268. private _effect;
  73269. private _viewMatrix;
  73270. private _projectionMatrix;
  73271. private _transformMatrix;
  73272. private _cachedPosition;
  73273. private _cachedDirection;
  73274. private _cachedDefines;
  73275. private _currentRenderID;
  73276. private _boxBlurPostprocess;
  73277. private _kernelBlurXPostprocess;
  73278. private _kernelBlurYPostprocess;
  73279. private _blurPostProcesses;
  73280. private _mapSize;
  73281. private _currentFaceIndex;
  73282. private _currentFaceIndexCache;
  73283. private _textureType;
  73284. private _defaultTextureMatrix;
  73285. /** @hidden */
  73286. static _SceneComponentInitialization: (scene: Scene) => void;
  73287. /**
  73288. * Creates a ShadowGenerator object.
  73289. * A ShadowGenerator is the required tool to use the shadows.
  73290. * Each light casting shadows needs to use its own ShadowGenerator.
  73291. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  73292. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  73293. * @param light The light object generating the shadows.
  73294. * @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.
  73295. */
  73296. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  73297. private _initializeGenerator;
  73298. private _initializeShadowMap;
  73299. private _initializeBlurRTTAndPostProcesses;
  73300. private _renderForShadowMap;
  73301. private _renderSubMeshForShadowMap;
  73302. private _applyFilterValues;
  73303. /**
  73304. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73305. * @param onCompiled Callback triggered at the and of the effects compilation
  73306. * @param options Sets of optional options forcing the compilation with different modes
  73307. */
  73308. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73309. useInstances: boolean;
  73310. }>): void;
  73311. /**
  73312. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73313. * @param options Sets of optional options forcing the compilation with different modes
  73314. * @returns A promise that resolves when the compilation completes
  73315. */
  73316. forceCompilationAsync(options?: Partial<{
  73317. useInstances: boolean;
  73318. }>): Promise<void>;
  73319. /**
  73320. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73321. * @param subMesh The submesh we want to render in the shadow map
  73322. * @param useInstances Defines wether will draw in the map using instances
  73323. * @returns true if ready otherwise, false
  73324. */
  73325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73326. /**
  73327. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73328. * @param defines Defines of the material we want to update
  73329. * @param lightIndex Index of the light in the enabled light list of the material
  73330. */
  73331. prepareDefines(defines: any, lightIndex: number): void;
  73332. /**
  73333. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73334. * defined in the generator but impacting the effect).
  73335. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73336. * @param effect The effect we are binfing the information for
  73337. */
  73338. bindShadowLight(lightIndex: string, effect: Effect): void;
  73339. /**
  73340. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73341. * (eq to shadow prjection matrix * light transform matrix)
  73342. * @returns The transform matrix used to create the shadow map
  73343. */
  73344. getTransformMatrix(): Matrix;
  73345. /**
  73346. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73347. * Cube and 2D textures for instance.
  73348. */
  73349. recreateShadowMap(): void;
  73350. private _disposeBlurPostProcesses;
  73351. private _disposeRTTandPostProcesses;
  73352. /**
  73353. * Disposes the ShadowGenerator.
  73354. * Returns nothing.
  73355. */
  73356. dispose(): void;
  73357. /**
  73358. * Serializes the shadow generator setup to a json object.
  73359. * @returns The serialized JSON object
  73360. */
  73361. serialize(): any;
  73362. /**
  73363. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  73364. * @param parsedShadowGenerator The JSON object to parse
  73365. * @param scene The scene to create the shadow map for
  73366. * @returns The parsed shadow generator
  73367. */
  73368. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  73369. }
  73370. }
  73371. declare module BABYLON {
  73372. /**
  73373. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  73374. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  73375. * 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.
  73376. */
  73377. export abstract class Light extends Node {
  73378. /**
  73379. * Falloff Default: light is falling off following the material specification:
  73380. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  73381. */
  73382. static readonly FALLOFF_DEFAULT: number;
  73383. /**
  73384. * Falloff Physical: light is falling off following the inverse squared distance law.
  73385. */
  73386. static readonly FALLOFF_PHYSICAL: number;
  73387. /**
  73388. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  73389. * to enhance interoperability with other engines.
  73390. */
  73391. static readonly FALLOFF_GLTF: number;
  73392. /**
  73393. * Falloff Standard: light is falling off like in the standard material
  73394. * to enhance interoperability with other materials.
  73395. */
  73396. static readonly FALLOFF_STANDARD: number;
  73397. /**
  73398. * If every light affecting the material is in this lightmapMode,
  73399. * material.lightmapTexture adds or multiplies
  73400. * (depends on material.useLightmapAsShadowmap)
  73401. * after every other light calculations.
  73402. */
  73403. static readonly LIGHTMAP_DEFAULT: number;
  73404. /**
  73405. * material.lightmapTexture as only diffuse lighting from this light
  73406. * adds only specular lighting from this light
  73407. * adds dynamic shadows
  73408. */
  73409. static readonly LIGHTMAP_SPECULAR: number;
  73410. /**
  73411. * material.lightmapTexture as only lighting
  73412. * no light calculation from this light
  73413. * only adds dynamic shadows from this light
  73414. */
  73415. static readonly LIGHTMAP_SHADOWSONLY: number;
  73416. /**
  73417. * Each light type uses the default quantity according to its type:
  73418. * point/spot lights use luminous intensity
  73419. * directional lights use illuminance
  73420. */
  73421. static readonly INTENSITYMODE_AUTOMATIC: number;
  73422. /**
  73423. * lumen (lm)
  73424. */
  73425. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  73426. /**
  73427. * candela (lm/sr)
  73428. */
  73429. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  73430. /**
  73431. * lux (lm/m^2)
  73432. */
  73433. static readonly INTENSITYMODE_ILLUMINANCE: number;
  73434. /**
  73435. * nit (cd/m^2)
  73436. */
  73437. static readonly INTENSITYMODE_LUMINANCE: number;
  73438. /**
  73439. * Light type const id of the point light.
  73440. */
  73441. static readonly LIGHTTYPEID_POINTLIGHT: number;
  73442. /**
  73443. * Light type const id of the directional light.
  73444. */
  73445. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  73446. /**
  73447. * Light type const id of the spot light.
  73448. */
  73449. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  73450. /**
  73451. * Light type const id of the hemispheric light.
  73452. */
  73453. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  73454. /**
  73455. * Diffuse gives the basic color to an object.
  73456. */
  73457. diffuse: Color3;
  73458. /**
  73459. * Specular produces a highlight color on an object.
  73460. * Note: This is note affecting PBR materials.
  73461. */
  73462. specular: Color3;
  73463. /**
  73464. * Defines the falloff type for this light. This lets overrriding how punctual light are
  73465. * falling off base on range or angle.
  73466. * This can be set to any values in Light.FALLOFF_x.
  73467. *
  73468. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  73469. * other types of materials.
  73470. */
  73471. falloffType: number;
  73472. /**
  73473. * Strength of the light.
  73474. * Note: By default it is define in the framework own unit.
  73475. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  73476. */
  73477. intensity: number;
  73478. private _range;
  73479. protected _inverseSquaredRange: number;
  73480. /**
  73481. * Defines how far from the source the light is impacting in scene units.
  73482. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73483. */
  73484. /**
  73485. * Defines how far from the source the light is impacting in scene units.
  73486. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  73487. */
  73488. range: number;
  73489. /**
  73490. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  73491. * of light.
  73492. */
  73493. private _photometricScale;
  73494. private _intensityMode;
  73495. /**
  73496. * Gets the photometric scale used to interpret the intensity.
  73497. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73498. */
  73499. /**
  73500. * Sets the photometric scale used to interpret the intensity.
  73501. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  73502. */
  73503. intensityMode: number;
  73504. private _radius;
  73505. /**
  73506. * Gets the light radius used by PBR Materials to simulate soft area lights.
  73507. */
  73508. /**
  73509. * sets the light radius used by PBR Materials to simulate soft area lights.
  73510. */
  73511. radius: number;
  73512. private _renderPriority;
  73513. /**
  73514. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  73515. * exceeding the number allowed of the materials.
  73516. */
  73517. renderPriority: number;
  73518. private _shadowEnabled;
  73519. /**
  73520. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73521. * the current shadow generator.
  73522. */
  73523. /**
  73524. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  73525. * the current shadow generator.
  73526. */
  73527. shadowEnabled: boolean;
  73528. private _includedOnlyMeshes;
  73529. /**
  73530. * Gets the only meshes impacted by this light.
  73531. */
  73532. /**
  73533. * Sets the only meshes impacted by this light.
  73534. */
  73535. includedOnlyMeshes: AbstractMesh[];
  73536. private _excludedMeshes;
  73537. /**
  73538. * Gets the meshes not impacted by this light.
  73539. */
  73540. /**
  73541. * Sets the meshes not impacted by this light.
  73542. */
  73543. excludedMeshes: AbstractMesh[];
  73544. private _excludeWithLayerMask;
  73545. /**
  73546. * Gets the layer id use to find what meshes are not impacted by the light.
  73547. * Inactive if 0
  73548. */
  73549. /**
  73550. * Sets the layer id use to find what meshes are not impacted by the light.
  73551. * Inactive if 0
  73552. */
  73553. excludeWithLayerMask: number;
  73554. private _includeOnlyWithLayerMask;
  73555. /**
  73556. * Gets the layer id use to find what meshes are impacted by the light.
  73557. * Inactive if 0
  73558. */
  73559. /**
  73560. * Sets the layer id use to find what meshes are impacted by the light.
  73561. * Inactive if 0
  73562. */
  73563. includeOnlyWithLayerMask: number;
  73564. private _lightmapMode;
  73565. /**
  73566. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73567. */
  73568. /**
  73569. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  73570. */
  73571. lightmapMode: number;
  73572. /**
  73573. * Shadow generator associted to the light.
  73574. * @hidden Internal use only.
  73575. */
  73576. _shadowGenerator: Nullable<IShadowGenerator>;
  73577. /**
  73578. * @hidden Internal use only.
  73579. */
  73580. _excludedMeshesIds: string[];
  73581. /**
  73582. * @hidden Internal use only.
  73583. */
  73584. _includedOnlyMeshesIds: string[];
  73585. /**
  73586. * The current light unifom buffer.
  73587. * @hidden Internal use only.
  73588. */
  73589. _uniformBuffer: UniformBuffer;
  73590. /**
  73591. * Creates a Light object in the scene.
  73592. * Documentation : https://doc.babylonjs.com/babylon101/lights
  73593. * @param name The firendly name of the light
  73594. * @param scene The scene the light belongs too
  73595. */
  73596. constructor(name: string, scene: Scene);
  73597. protected abstract _buildUniformLayout(): void;
  73598. /**
  73599. * Sets the passed Effect "effect" with the Light information.
  73600. * @param effect The effect to update
  73601. * @param lightIndex The index of the light in the effect to update
  73602. * @returns The light
  73603. */
  73604. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  73605. /**
  73606. * Returns the string "Light".
  73607. * @returns the class name
  73608. */
  73609. getClassName(): string;
  73610. /** @hidden */
  73611. readonly _isLight: boolean;
  73612. /**
  73613. * Converts the light information to a readable string for debug purpose.
  73614. * @param fullDetails Supports for multiple levels of logging within scene loading
  73615. * @returns the human readable light info
  73616. */
  73617. toString(fullDetails?: boolean): string;
  73618. /** @hidden */
  73619. protected _syncParentEnabledState(): void;
  73620. /**
  73621. * Set the enabled state of this node.
  73622. * @param value - the new enabled state
  73623. */
  73624. setEnabled(value: boolean): void;
  73625. /**
  73626. * Returns the Light associated shadow generator if any.
  73627. * @return the associated shadow generator.
  73628. */
  73629. getShadowGenerator(): Nullable<IShadowGenerator>;
  73630. /**
  73631. * Returns a Vector3, the absolute light position in the World.
  73632. * @returns the world space position of the light
  73633. */
  73634. getAbsolutePosition(): Vector3;
  73635. /**
  73636. * Specifies if the light will affect the passed mesh.
  73637. * @param mesh The mesh to test against the light
  73638. * @return true the mesh is affected otherwise, false.
  73639. */
  73640. canAffectMesh(mesh: AbstractMesh): boolean;
  73641. /**
  73642. * Sort function to order lights for rendering.
  73643. * @param a First Light object to compare to second.
  73644. * @param b Second Light object to compare first.
  73645. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  73646. */
  73647. static CompareLightsPriority(a: Light, b: Light): number;
  73648. /**
  73649. * Releases resources associated with this node.
  73650. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  73651. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  73652. */
  73653. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  73654. /**
  73655. * Returns the light type ID (integer).
  73656. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  73657. */
  73658. getTypeID(): number;
  73659. /**
  73660. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  73661. * @returns the scaled intensity in intensity mode unit
  73662. */
  73663. getScaledIntensity(): number;
  73664. /**
  73665. * Returns a new Light object, named "name", from the current one.
  73666. * @param name The name of the cloned light
  73667. * @returns the new created light
  73668. */
  73669. clone(name: string): Nullable<Light>;
  73670. /**
  73671. * Serializes the current light into a Serialization object.
  73672. * @returns the serialized object.
  73673. */
  73674. serialize(): any;
  73675. /**
  73676. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  73677. * This new light is named "name" and added to the passed scene.
  73678. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  73679. * @param name The friendly name of the light
  73680. * @param scene The scene the new light will belong to
  73681. * @returns the constructor function
  73682. */
  73683. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  73684. /**
  73685. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  73686. * @param parsedLight The JSON representation of the light
  73687. * @param scene The scene to create the parsed light in
  73688. * @returns the created light after parsing
  73689. */
  73690. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  73691. private _hookArrayForExcluded;
  73692. private _hookArrayForIncludedOnly;
  73693. private _resyncMeshes;
  73694. /**
  73695. * Forces the meshes to update their light related information in their rendering used effects
  73696. * @hidden Internal Use Only
  73697. */
  73698. _markMeshesAsLightDirty(): void;
  73699. /**
  73700. * Recomputes the cached photometric scale if needed.
  73701. */
  73702. private _computePhotometricScale;
  73703. /**
  73704. * Returns the Photometric Scale according to the light type and intensity mode.
  73705. */
  73706. private _getPhotometricScale;
  73707. /**
  73708. * Reorder the light in the scene according to their defined priority.
  73709. * @hidden Internal Use Only
  73710. */
  73711. _reorderLightsInScene(): void;
  73712. /**
  73713. * Prepares the list of defines specific to the light type.
  73714. * @param defines the list of defines
  73715. * @param lightIndex defines the index of the light for the effect
  73716. */
  73717. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  73718. }
  73719. }
  73720. declare module BABYLON {
  73721. /**
  73722. * Interface used to define Action
  73723. */
  73724. export interface IAction {
  73725. /**
  73726. * Trigger for the action
  73727. */
  73728. trigger: number;
  73729. /** Options of the trigger */
  73730. triggerOptions: any;
  73731. /**
  73732. * Gets the trigger parameters
  73733. * @returns the trigger parameters
  73734. */
  73735. getTriggerParameter(): any;
  73736. /**
  73737. * Internal only - executes current action event
  73738. * @hidden
  73739. */
  73740. _executeCurrent(evt?: ActionEvent): void;
  73741. /**
  73742. * Serialize placeholder for child classes
  73743. * @param parent of child
  73744. * @returns the serialized object
  73745. */
  73746. serialize(parent: any): any;
  73747. /**
  73748. * Internal only
  73749. * @hidden
  73750. */
  73751. _prepare(): void;
  73752. /**
  73753. * Internal only - manager for action
  73754. * @hidden
  73755. */
  73756. _actionManager: AbstractActionManager;
  73757. /**
  73758. * Adds action to chain of actions, may be a DoNothingAction
  73759. * @param action defines the next action to execute
  73760. * @returns The action passed in
  73761. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73762. */
  73763. then(action: IAction): IAction;
  73764. }
  73765. /**
  73766. * The action to be carried out following a trigger
  73767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  73768. */
  73769. export class Action implements IAction {
  73770. /** the trigger, with or without parameters, for the action */
  73771. triggerOptions: any;
  73772. /**
  73773. * Trigger for the action
  73774. */
  73775. trigger: number;
  73776. /**
  73777. * Internal only - manager for action
  73778. * @hidden
  73779. */
  73780. _actionManager: ActionManager;
  73781. private _nextActiveAction;
  73782. private _child;
  73783. private _condition?;
  73784. private _triggerParameter;
  73785. /**
  73786. * An event triggered prior to action being executed.
  73787. */
  73788. onBeforeExecuteObservable: Observable<Action>;
  73789. /**
  73790. * Creates a new Action
  73791. * @param triggerOptions the trigger, with or without parameters, for the action
  73792. * @param condition an optional determinant of action
  73793. */
  73794. constructor(
  73795. /** the trigger, with or without parameters, for the action */
  73796. triggerOptions: any, condition?: Condition);
  73797. /**
  73798. * Internal only
  73799. * @hidden
  73800. */
  73801. _prepare(): void;
  73802. /**
  73803. * Gets the trigger parameters
  73804. * @returns the trigger parameters
  73805. */
  73806. getTriggerParameter(): any;
  73807. /**
  73808. * Internal only - executes current action event
  73809. * @hidden
  73810. */
  73811. _executeCurrent(evt?: ActionEvent): void;
  73812. /**
  73813. * Execute placeholder for child classes
  73814. * @param evt optional action event
  73815. */
  73816. execute(evt?: ActionEvent): void;
  73817. /**
  73818. * Skips to next active action
  73819. */
  73820. skipToNextActiveAction(): void;
  73821. /**
  73822. * Adds action to chain of actions, may be a DoNothingAction
  73823. * @param action defines the next action to execute
  73824. * @returns The action passed in
  73825. * @see https://www.babylonjs-playground.com/#1T30HR#0
  73826. */
  73827. then(action: Action): Action;
  73828. /**
  73829. * Internal only
  73830. * @hidden
  73831. */
  73832. _getProperty(propertyPath: string): string;
  73833. /**
  73834. * Internal only
  73835. * @hidden
  73836. */
  73837. _getEffectiveTarget(target: any, propertyPath: string): any;
  73838. /**
  73839. * Serialize placeholder for child classes
  73840. * @param parent of child
  73841. * @returns the serialized object
  73842. */
  73843. serialize(parent: any): any;
  73844. /**
  73845. * Internal only called by serialize
  73846. * @hidden
  73847. */
  73848. protected _serialize(serializedAction: any, parent?: any): any;
  73849. /**
  73850. * Internal only
  73851. * @hidden
  73852. */
  73853. static _SerializeValueAsString: (value: any) => string;
  73854. /**
  73855. * Internal only
  73856. * @hidden
  73857. */
  73858. static _GetTargetProperty: (target: Node | Scene) => {
  73859. name: string;
  73860. targetType: string;
  73861. value: string;
  73862. };
  73863. }
  73864. }
  73865. declare module BABYLON {
  73866. /**
  73867. * A Condition applied to an Action
  73868. */
  73869. export class Condition {
  73870. /**
  73871. * Internal only - manager for action
  73872. * @hidden
  73873. */
  73874. _actionManager: ActionManager;
  73875. /**
  73876. * Internal only
  73877. * @hidden
  73878. */
  73879. _evaluationId: number;
  73880. /**
  73881. * Internal only
  73882. * @hidden
  73883. */
  73884. _currentResult: boolean;
  73885. /**
  73886. * Creates a new Condition
  73887. * @param actionManager the manager of the action the condition is applied to
  73888. */
  73889. constructor(actionManager: ActionManager);
  73890. /**
  73891. * Check if the current condition is valid
  73892. * @returns a boolean
  73893. */
  73894. isValid(): boolean;
  73895. /**
  73896. * Internal only
  73897. * @hidden
  73898. */
  73899. _getProperty(propertyPath: string): string;
  73900. /**
  73901. * Internal only
  73902. * @hidden
  73903. */
  73904. _getEffectiveTarget(target: any, propertyPath: string): any;
  73905. /**
  73906. * Serialize placeholder for child classes
  73907. * @returns the serialized object
  73908. */
  73909. serialize(): any;
  73910. /**
  73911. * Internal only
  73912. * @hidden
  73913. */
  73914. protected _serialize(serializedCondition: any): any;
  73915. }
  73916. /**
  73917. * Defines specific conditional operators as extensions of Condition
  73918. */
  73919. export class ValueCondition extends Condition {
  73920. /** path to specify the property of the target the conditional operator uses */
  73921. propertyPath: string;
  73922. /** the value compared by the conditional operator against the current value of the property */
  73923. value: any;
  73924. /** the conditional operator, default ValueCondition.IsEqual */
  73925. operator: number;
  73926. /**
  73927. * Internal only
  73928. * @hidden
  73929. */
  73930. private static _IsEqual;
  73931. /**
  73932. * Internal only
  73933. * @hidden
  73934. */
  73935. private static _IsDifferent;
  73936. /**
  73937. * Internal only
  73938. * @hidden
  73939. */
  73940. private static _IsGreater;
  73941. /**
  73942. * Internal only
  73943. * @hidden
  73944. */
  73945. private static _IsLesser;
  73946. /**
  73947. * returns the number for IsEqual
  73948. */
  73949. static readonly IsEqual: number;
  73950. /**
  73951. * Returns the number for IsDifferent
  73952. */
  73953. static readonly IsDifferent: number;
  73954. /**
  73955. * Returns the number for IsGreater
  73956. */
  73957. static readonly IsGreater: number;
  73958. /**
  73959. * Returns the number for IsLesser
  73960. */
  73961. static readonly IsLesser: number;
  73962. /**
  73963. * Internal only The action manager for the condition
  73964. * @hidden
  73965. */
  73966. _actionManager: ActionManager;
  73967. /**
  73968. * Internal only
  73969. * @hidden
  73970. */
  73971. private _target;
  73972. /**
  73973. * Internal only
  73974. * @hidden
  73975. */
  73976. private _effectiveTarget;
  73977. /**
  73978. * Internal only
  73979. * @hidden
  73980. */
  73981. private _property;
  73982. /**
  73983. * Creates a new ValueCondition
  73984. * @param actionManager manager for the action the condition applies to
  73985. * @param target for the action
  73986. * @param propertyPath path to specify the property of the target the conditional operator uses
  73987. * @param value the value compared by the conditional operator against the current value of the property
  73988. * @param operator the conditional operator, default ValueCondition.IsEqual
  73989. */
  73990. constructor(actionManager: ActionManager, target: any,
  73991. /** path to specify the property of the target the conditional operator uses */
  73992. propertyPath: string,
  73993. /** the value compared by the conditional operator against the current value of the property */
  73994. value: any,
  73995. /** the conditional operator, default ValueCondition.IsEqual */
  73996. operator?: number);
  73997. /**
  73998. * Compares the given value with the property value for the specified conditional operator
  73999. * @returns the result of the comparison
  74000. */
  74001. isValid(): boolean;
  74002. /**
  74003. * Serialize the ValueCondition into a JSON compatible object
  74004. * @returns serialization object
  74005. */
  74006. serialize(): any;
  74007. /**
  74008. * Gets the name of the conditional operator for the ValueCondition
  74009. * @param operator the conditional operator
  74010. * @returns the name
  74011. */
  74012. static GetOperatorName(operator: number): string;
  74013. }
  74014. /**
  74015. * Defines a predicate condition as an extension of Condition
  74016. */
  74017. export class PredicateCondition extends Condition {
  74018. /** defines the predicate function used to validate the condition */
  74019. predicate: () => boolean;
  74020. /**
  74021. * Internal only - manager for action
  74022. * @hidden
  74023. */
  74024. _actionManager: ActionManager;
  74025. /**
  74026. * Creates a new PredicateCondition
  74027. * @param actionManager manager for the action the condition applies to
  74028. * @param predicate defines the predicate function used to validate the condition
  74029. */
  74030. constructor(actionManager: ActionManager,
  74031. /** defines the predicate function used to validate the condition */
  74032. predicate: () => boolean);
  74033. /**
  74034. * @returns the validity of the predicate condition
  74035. */
  74036. isValid(): boolean;
  74037. }
  74038. /**
  74039. * Defines a state condition as an extension of Condition
  74040. */
  74041. export class StateCondition extends Condition {
  74042. /** Value to compare with target state */
  74043. value: string;
  74044. /**
  74045. * Internal only - manager for action
  74046. * @hidden
  74047. */
  74048. _actionManager: ActionManager;
  74049. /**
  74050. * Internal only
  74051. * @hidden
  74052. */
  74053. private _target;
  74054. /**
  74055. * Creates a new StateCondition
  74056. * @param actionManager manager for the action the condition applies to
  74057. * @param target of the condition
  74058. * @param value to compare with target state
  74059. */
  74060. constructor(actionManager: ActionManager, target: any,
  74061. /** Value to compare with target state */
  74062. value: string);
  74063. /**
  74064. * Gets a boolean indicating if the current condition is met
  74065. * @returns the validity of the state
  74066. */
  74067. isValid(): boolean;
  74068. /**
  74069. * Serialize the StateCondition into a JSON compatible object
  74070. * @returns serialization object
  74071. */
  74072. serialize(): any;
  74073. }
  74074. }
  74075. declare module BABYLON {
  74076. /**
  74077. * This defines an action responsible to toggle a boolean once triggered.
  74078. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74079. */
  74080. export class SwitchBooleanAction extends Action {
  74081. /**
  74082. * The path to the boolean property in the target object
  74083. */
  74084. propertyPath: string;
  74085. private _target;
  74086. private _effectiveTarget;
  74087. private _property;
  74088. /**
  74089. * Instantiate the action
  74090. * @param triggerOptions defines the trigger options
  74091. * @param target defines the object containing the boolean
  74092. * @param propertyPath defines the path to the boolean property in the target object
  74093. * @param condition defines the trigger related conditions
  74094. */
  74095. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  74096. /** @hidden */
  74097. _prepare(): void;
  74098. /**
  74099. * Execute the action toggle the boolean value.
  74100. */
  74101. execute(): void;
  74102. /**
  74103. * Serializes the actions and its related information.
  74104. * @param parent defines the object to serialize in
  74105. * @returns the serialized object
  74106. */
  74107. serialize(parent: any): any;
  74108. }
  74109. /**
  74110. * This defines an action responsible to set a the state field of the target
  74111. * to a desired value once triggered.
  74112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74113. */
  74114. export class SetStateAction extends Action {
  74115. /**
  74116. * The value to store in the state field.
  74117. */
  74118. value: string;
  74119. private _target;
  74120. /**
  74121. * Instantiate the action
  74122. * @param triggerOptions defines the trigger options
  74123. * @param target defines the object containing the state property
  74124. * @param value defines the value to store in the state field
  74125. * @param condition defines the trigger related conditions
  74126. */
  74127. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  74128. /**
  74129. * Execute the action and store the value on the target state property.
  74130. */
  74131. execute(): void;
  74132. /**
  74133. * Serializes the actions and its related information.
  74134. * @param parent defines the object to serialize in
  74135. * @returns the serialized object
  74136. */
  74137. serialize(parent: any): any;
  74138. }
  74139. /**
  74140. * This defines an action responsible to set a property of the target
  74141. * to a desired value once triggered.
  74142. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74143. */
  74144. export class SetValueAction extends Action {
  74145. /**
  74146. * The path of the property to set in the target.
  74147. */
  74148. propertyPath: string;
  74149. /**
  74150. * The value to set in the property
  74151. */
  74152. value: any;
  74153. private _target;
  74154. private _effectiveTarget;
  74155. private _property;
  74156. /**
  74157. * Instantiate the action
  74158. * @param triggerOptions defines the trigger options
  74159. * @param target defines the object containing the property
  74160. * @param propertyPath defines the path of the property to set in the target
  74161. * @param value defines the value to set in the property
  74162. * @param condition defines the trigger related conditions
  74163. */
  74164. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74165. /** @hidden */
  74166. _prepare(): void;
  74167. /**
  74168. * Execute the action and set the targetted property to the desired value.
  74169. */
  74170. execute(): void;
  74171. /**
  74172. * Serializes the actions and its related information.
  74173. * @param parent defines the object to serialize in
  74174. * @returns the serialized object
  74175. */
  74176. serialize(parent: any): any;
  74177. }
  74178. /**
  74179. * This defines an action responsible to increment the target value
  74180. * to a desired value once triggered.
  74181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74182. */
  74183. export class IncrementValueAction extends Action {
  74184. /**
  74185. * The path of the property to increment in the target.
  74186. */
  74187. propertyPath: string;
  74188. /**
  74189. * The value we should increment the property by.
  74190. */
  74191. value: any;
  74192. private _target;
  74193. private _effectiveTarget;
  74194. private _property;
  74195. /**
  74196. * Instantiate the action
  74197. * @param triggerOptions defines the trigger options
  74198. * @param target defines the object containing the property
  74199. * @param propertyPath defines the path of the property to increment in the target
  74200. * @param value defines the value value we should increment the property by
  74201. * @param condition defines the trigger related conditions
  74202. */
  74203. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  74204. /** @hidden */
  74205. _prepare(): void;
  74206. /**
  74207. * Execute the action and increment the target of the value amount.
  74208. */
  74209. execute(): void;
  74210. /**
  74211. * Serializes the actions and its related information.
  74212. * @param parent defines the object to serialize in
  74213. * @returns the serialized object
  74214. */
  74215. serialize(parent: any): any;
  74216. }
  74217. /**
  74218. * This defines an action responsible to start an animation once triggered.
  74219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74220. */
  74221. export class PlayAnimationAction extends Action {
  74222. /**
  74223. * Where the animation should start (animation frame)
  74224. */
  74225. from: number;
  74226. /**
  74227. * Where the animation should stop (animation frame)
  74228. */
  74229. to: number;
  74230. /**
  74231. * Define if the animation should loop or stop after the first play.
  74232. */
  74233. loop?: boolean;
  74234. private _target;
  74235. /**
  74236. * Instantiate the action
  74237. * @param triggerOptions defines the trigger options
  74238. * @param target defines the target animation or animation name
  74239. * @param from defines from where the animation should start (animation frame)
  74240. * @param end defines where the animation should stop (animation frame)
  74241. * @param loop defines if the animation should loop or stop after the first play
  74242. * @param condition defines the trigger related conditions
  74243. */
  74244. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  74245. /** @hidden */
  74246. _prepare(): void;
  74247. /**
  74248. * Execute the action and play the animation.
  74249. */
  74250. execute(): void;
  74251. /**
  74252. * Serializes the actions and its related information.
  74253. * @param parent defines the object to serialize in
  74254. * @returns the serialized object
  74255. */
  74256. serialize(parent: any): any;
  74257. }
  74258. /**
  74259. * This defines an action responsible to stop an animation once triggered.
  74260. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74261. */
  74262. export class StopAnimationAction extends Action {
  74263. private _target;
  74264. /**
  74265. * Instantiate the action
  74266. * @param triggerOptions defines the trigger options
  74267. * @param target defines the target animation or animation name
  74268. * @param condition defines the trigger related conditions
  74269. */
  74270. constructor(triggerOptions: any, target: any, condition?: Condition);
  74271. /** @hidden */
  74272. _prepare(): void;
  74273. /**
  74274. * Execute the action and stop the animation.
  74275. */
  74276. execute(): void;
  74277. /**
  74278. * Serializes the actions and its related information.
  74279. * @param parent defines the object to serialize in
  74280. * @returns the serialized object
  74281. */
  74282. serialize(parent: any): any;
  74283. }
  74284. /**
  74285. * This defines an action responsible that does nothing once triggered.
  74286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74287. */
  74288. export class DoNothingAction extends Action {
  74289. /**
  74290. * Instantiate the action
  74291. * @param triggerOptions defines the trigger options
  74292. * @param condition defines the trigger related conditions
  74293. */
  74294. constructor(triggerOptions?: any, condition?: Condition);
  74295. /**
  74296. * Execute the action and do nothing.
  74297. */
  74298. execute(): void;
  74299. /**
  74300. * Serializes the actions and its related information.
  74301. * @param parent defines the object to serialize in
  74302. * @returns the serialized object
  74303. */
  74304. serialize(parent: any): any;
  74305. }
  74306. /**
  74307. * This defines an action responsible to trigger several actions once triggered.
  74308. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74309. */
  74310. export class CombineAction extends Action {
  74311. /**
  74312. * The list of aggregated animations to run.
  74313. */
  74314. children: Action[];
  74315. /**
  74316. * Instantiate the action
  74317. * @param triggerOptions defines the trigger options
  74318. * @param children defines the list of aggregated animations to run
  74319. * @param condition defines the trigger related conditions
  74320. */
  74321. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  74322. /** @hidden */
  74323. _prepare(): void;
  74324. /**
  74325. * Execute the action and executes all the aggregated actions.
  74326. */
  74327. execute(evt: ActionEvent): void;
  74328. /**
  74329. * Serializes the actions and its related information.
  74330. * @param parent defines the object to serialize in
  74331. * @returns the serialized object
  74332. */
  74333. serialize(parent: any): any;
  74334. }
  74335. /**
  74336. * This defines an action responsible to run code (external event) once triggered.
  74337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74338. */
  74339. export class ExecuteCodeAction extends Action {
  74340. /**
  74341. * The callback function to run.
  74342. */
  74343. func: (evt: ActionEvent) => void;
  74344. /**
  74345. * Instantiate the action
  74346. * @param triggerOptions defines the trigger options
  74347. * @param func defines the callback function to run
  74348. * @param condition defines the trigger related conditions
  74349. */
  74350. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  74351. /**
  74352. * Execute the action and run the attached code.
  74353. */
  74354. execute(evt: ActionEvent): void;
  74355. }
  74356. /**
  74357. * This defines an action responsible to set the parent property of the target once triggered.
  74358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74359. */
  74360. export class SetParentAction extends Action {
  74361. private _parent;
  74362. private _target;
  74363. /**
  74364. * Instantiate the action
  74365. * @param triggerOptions defines the trigger options
  74366. * @param target defines the target containing the parent property
  74367. * @param parent defines from where the animation should start (animation frame)
  74368. * @param condition defines the trigger related conditions
  74369. */
  74370. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  74371. /** @hidden */
  74372. _prepare(): void;
  74373. /**
  74374. * Execute the action and set the parent property.
  74375. */
  74376. execute(): void;
  74377. /**
  74378. * Serializes the actions and its related information.
  74379. * @param parent defines the object to serialize in
  74380. * @returns the serialized object
  74381. */
  74382. serialize(parent: any): any;
  74383. }
  74384. }
  74385. declare module BABYLON {
  74386. /**
  74387. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  74388. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  74389. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  74390. */
  74391. export class ActionManager extends AbstractActionManager {
  74392. /**
  74393. * Nothing
  74394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74395. */
  74396. static readonly NothingTrigger: number;
  74397. /**
  74398. * On pick
  74399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74400. */
  74401. static readonly OnPickTrigger: number;
  74402. /**
  74403. * On left pick
  74404. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74405. */
  74406. static readonly OnLeftPickTrigger: number;
  74407. /**
  74408. * On right pick
  74409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74410. */
  74411. static readonly OnRightPickTrigger: number;
  74412. /**
  74413. * On center pick
  74414. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74415. */
  74416. static readonly OnCenterPickTrigger: number;
  74417. /**
  74418. * On pick down
  74419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74420. */
  74421. static readonly OnPickDownTrigger: number;
  74422. /**
  74423. * On double pick
  74424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74425. */
  74426. static readonly OnDoublePickTrigger: number;
  74427. /**
  74428. * On pick up
  74429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74430. */
  74431. static readonly OnPickUpTrigger: number;
  74432. /**
  74433. * On pick out.
  74434. * This trigger will only be raised if you also declared a OnPickDown
  74435. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74436. */
  74437. static readonly OnPickOutTrigger: number;
  74438. /**
  74439. * On long press
  74440. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74441. */
  74442. static readonly OnLongPressTrigger: number;
  74443. /**
  74444. * On pointer over
  74445. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74446. */
  74447. static readonly OnPointerOverTrigger: number;
  74448. /**
  74449. * On pointer out
  74450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74451. */
  74452. static readonly OnPointerOutTrigger: number;
  74453. /**
  74454. * On every frame
  74455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74456. */
  74457. static readonly OnEveryFrameTrigger: number;
  74458. /**
  74459. * On intersection enter
  74460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74461. */
  74462. static readonly OnIntersectionEnterTrigger: number;
  74463. /**
  74464. * On intersection exit
  74465. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74466. */
  74467. static readonly OnIntersectionExitTrigger: number;
  74468. /**
  74469. * On key down
  74470. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74471. */
  74472. static readonly OnKeyDownTrigger: number;
  74473. /**
  74474. * On key up
  74475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74476. */
  74477. static readonly OnKeyUpTrigger: number;
  74478. private _scene;
  74479. /**
  74480. * Creates a new action manager
  74481. * @param scene defines the hosting scene
  74482. */
  74483. constructor(scene: Scene);
  74484. /**
  74485. * Releases all associated resources
  74486. */
  74487. dispose(): void;
  74488. /**
  74489. * Gets hosting scene
  74490. * @returns the hosting scene
  74491. */
  74492. getScene(): Scene;
  74493. /**
  74494. * Does this action manager handles actions of any of the given triggers
  74495. * @param triggers defines the triggers to be tested
  74496. * @return a boolean indicating whether one (or more) of the triggers is handled
  74497. */
  74498. hasSpecificTriggers(triggers: number[]): boolean;
  74499. /**
  74500. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  74501. * speed.
  74502. * @param triggerA defines the trigger to be tested
  74503. * @param triggerB defines the trigger to be tested
  74504. * @return a boolean indicating whether one (or more) of the triggers is handled
  74505. */
  74506. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  74507. /**
  74508. * Does this action manager handles actions of a given trigger
  74509. * @param trigger defines the trigger to be tested
  74510. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  74511. * @return whether the trigger is handled
  74512. */
  74513. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  74514. /**
  74515. * Does this action manager has pointer triggers
  74516. */
  74517. readonly hasPointerTriggers: boolean;
  74518. /**
  74519. * Does this action manager has pick triggers
  74520. */
  74521. readonly hasPickTriggers: boolean;
  74522. /**
  74523. * Registers an action to this action manager
  74524. * @param action defines the action to be registered
  74525. * @return the action amended (prepared) after registration
  74526. */
  74527. registerAction(action: IAction): Nullable<IAction>;
  74528. /**
  74529. * Unregisters an action to this action manager
  74530. * @param action defines the action to be unregistered
  74531. * @return a boolean indicating whether the action has been unregistered
  74532. */
  74533. unregisterAction(action: IAction): Boolean;
  74534. /**
  74535. * Process a specific trigger
  74536. * @param trigger defines the trigger to process
  74537. * @param evt defines the event details to be processed
  74538. */
  74539. processTrigger(trigger: number, evt?: IActionEvent): void;
  74540. /** @hidden */
  74541. _getEffectiveTarget(target: any, propertyPath: string): any;
  74542. /** @hidden */
  74543. _getProperty(propertyPath: string): string;
  74544. /**
  74545. * Serialize this manager to a JSON object
  74546. * @param name defines the property name to store this manager
  74547. * @returns a JSON representation of this manager
  74548. */
  74549. serialize(name: string): any;
  74550. /**
  74551. * Creates a new ActionManager from a JSON data
  74552. * @param parsedActions defines the JSON data to read from
  74553. * @param object defines the hosting mesh
  74554. * @param scene defines the hosting scene
  74555. */
  74556. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  74557. /**
  74558. * Get a trigger name by index
  74559. * @param trigger defines the trigger index
  74560. * @returns a trigger name
  74561. */
  74562. static GetTriggerName(trigger: number): string;
  74563. }
  74564. }
  74565. declare module BABYLON {
  74566. /**
  74567. * Class representing a ray with position and direction
  74568. */
  74569. export class Ray {
  74570. /** origin point */
  74571. origin: Vector3;
  74572. /** direction */
  74573. direction: Vector3;
  74574. /** length of the ray */
  74575. length: number;
  74576. private static readonly TmpVector3;
  74577. private _tmpRay;
  74578. /**
  74579. * Creates a new ray
  74580. * @param origin origin point
  74581. * @param direction direction
  74582. * @param length length of the ray
  74583. */
  74584. constructor(
  74585. /** origin point */
  74586. origin: Vector3,
  74587. /** direction */
  74588. direction: Vector3,
  74589. /** length of the ray */
  74590. length?: number);
  74591. /**
  74592. * Checks if the ray intersects a box
  74593. * @param minimum bound of the box
  74594. * @param maximum bound of the box
  74595. * @param intersectionTreshold extra extend to be added to the box in all direction
  74596. * @returns if the box was hit
  74597. */
  74598. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  74599. /**
  74600. * Checks if the ray intersects a box
  74601. * @param box the bounding box to check
  74602. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  74603. * @returns if the box was hit
  74604. */
  74605. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  74606. /**
  74607. * If the ray hits a sphere
  74608. * @param sphere the bounding sphere to check
  74609. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  74610. * @returns true if it hits the sphere
  74611. */
  74612. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  74613. /**
  74614. * If the ray hits a triange
  74615. * @param vertex0 triangle vertex
  74616. * @param vertex1 triangle vertex
  74617. * @param vertex2 triangle vertex
  74618. * @returns intersection information if hit
  74619. */
  74620. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  74621. /**
  74622. * Checks if ray intersects a plane
  74623. * @param plane the plane to check
  74624. * @returns the distance away it was hit
  74625. */
  74626. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  74627. /**
  74628. * Calculate the intercept of a ray on a given axis
  74629. * @param axis to check 'x' | 'y' | 'z'
  74630. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  74631. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  74632. */
  74633. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  74634. /**
  74635. * Checks if ray intersects a mesh
  74636. * @param mesh the mesh to check
  74637. * @param fastCheck if only the bounding box should checked
  74638. * @returns picking info of the intersecton
  74639. */
  74640. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  74641. /**
  74642. * Checks if ray intersects a mesh
  74643. * @param meshes the meshes to check
  74644. * @param fastCheck if only the bounding box should checked
  74645. * @param results array to store result in
  74646. * @returns Array of picking infos
  74647. */
  74648. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  74649. private _comparePickingInfo;
  74650. private static smallnum;
  74651. private static rayl;
  74652. /**
  74653. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  74654. * @param sega the first point of the segment to test the intersection against
  74655. * @param segb the second point of the segment to test the intersection against
  74656. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  74657. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  74658. */
  74659. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  74660. /**
  74661. * Update the ray from viewport position
  74662. * @param x position
  74663. * @param y y position
  74664. * @param viewportWidth viewport width
  74665. * @param viewportHeight viewport height
  74666. * @param world world matrix
  74667. * @param view view matrix
  74668. * @param projection projection matrix
  74669. * @returns this ray updated
  74670. */
  74671. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74672. /**
  74673. * Creates a ray with origin and direction of 0,0,0
  74674. * @returns the new ray
  74675. */
  74676. static Zero(): Ray;
  74677. /**
  74678. * Creates a new ray from screen space and viewport
  74679. * @param x position
  74680. * @param y y position
  74681. * @param viewportWidth viewport width
  74682. * @param viewportHeight viewport height
  74683. * @param world world matrix
  74684. * @param view view matrix
  74685. * @param projection projection matrix
  74686. * @returns new ray
  74687. */
  74688. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  74689. /**
  74690. * 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
  74691. * transformed to the given world matrix.
  74692. * @param origin The origin point
  74693. * @param end The end point
  74694. * @param world a matrix to transform the ray to. Default is the identity matrix.
  74695. * @returns the new ray
  74696. */
  74697. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  74698. /**
  74699. * Transforms a ray by a matrix
  74700. * @param ray ray to transform
  74701. * @param matrix matrix to apply
  74702. * @returns the resulting new ray
  74703. */
  74704. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  74705. /**
  74706. * Transforms a ray by a matrix
  74707. * @param ray ray to transform
  74708. * @param matrix matrix to apply
  74709. * @param result ray to store result in
  74710. */
  74711. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  74712. /**
  74713. * Unproject a ray from screen space to object space
  74714. * @param sourceX defines the screen space x coordinate to use
  74715. * @param sourceY defines the screen space y coordinate to use
  74716. * @param viewportWidth defines the current width of the viewport
  74717. * @param viewportHeight defines the current height of the viewport
  74718. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  74719. * @param view defines the view matrix to use
  74720. * @param projection defines the projection matrix to use
  74721. */
  74722. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  74723. }
  74724. /**
  74725. * Type used to define predicate used to select faces when a mesh intersection is detected
  74726. */
  74727. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  74728. interface Scene {
  74729. /** @hidden */
  74730. _tempPickingRay: Nullable<Ray>;
  74731. /** @hidden */
  74732. _cachedRayForTransform: Ray;
  74733. /** @hidden */
  74734. _pickWithRayInverseMatrix: Matrix;
  74735. /** @hidden */
  74736. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  74737. /** @hidden */
  74738. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * Groups all the scene component constants in one place to ease maintenance.
  74744. * @hidden
  74745. */
  74746. export class SceneComponentConstants {
  74747. static readonly NAME_EFFECTLAYER: string;
  74748. static readonly NAME_LAYER: string;
  74749. static readonly NAME_LENSFLARESYSTEM: string;
  74750. static readonly NAME_BOUNDINGBOXRENDERER: string;
  74751. static readonly NAME_PARTICLESYSTEM: string;
  74752. static readonly NAME_GAMEPAD: string;
  74753. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  74754. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  74755. static readonly NAME_DEPTHRENDERER: string;
  74756. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  74757. static readonly NAME_SPRITE: string;
  74758. static readonly NAME_OUTLINERENDERER: string;
  74759. static readonly NAME_PROCEDURALTEXTURE: string;
  74760. static readonly NAME_SHADOWGENERATOR: string;
  74761. static readonly NAME_OCTREE: string;
  74762. static readonly NAME_PHYSICSENGINE: string;
  74763. static readonly NAME_AUDIO: string;
  74764. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  74765. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74766. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  74767. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  74768. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  74769. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  74770. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  74771. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  74772. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  74773. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  74774. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  74775. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  74776. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  74777. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  74778. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  74779. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  74780. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  74781. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  74782. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  74783. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  74784. static readonly STEP_AFTERRENDER_AUDIO: number;
  74785. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  74786. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  74787. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  74788. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  74789. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  74790. static readonly STEP_POINTERMOVE_SPRITE: number;
  74791. static readonly STEP_POINTERDOWN_SPRITE: number;
  74792. static readonly STEP_POINTERUP_SPRITE: number;
  74793. }
  74794. /**
  74795. * This represents a scene component.
  74796. *
  74797. * This is used to decouple the dependency the scene is having on the different workloads like
  74798. * layers, post processes...
  74799. */
  74800. export interface ISceneComponent {
  74801. /**
  74802. * The name of the component. Each component must have a unique name.
  74803. */
  74804. name: string;
  74805. /**
  74806. * The scene the component belongs to.
  74807. */
  74808. scene: Scene;
  74809. /**
  74810. * Register the component to one instance of a scene.
  74811. */
  74812. register(): void;
  74813. /**
  74814. * Rebuilds the elements related to this component in case of
  74815. * context lost for instance.
  74816. */
  74817. rebuild(): void;
  74818. /**
  74819. * Disposes the component and the associated ressources.
  74820. */
  74821. dispose(): void;
  74822. }
  74823. /**
  74824. * This represents a SERIALIZABLE scene component.
  74825. *
  74826. * This extends Scene Component to add Serialization methods on top.
  74827. */
  74828. export interface ISceneSerializableComponent extends ISceneComponent {
  74829. /**
  74830. * Adds all the elements from the container to the scene
  74831. * @param container the container holding the elements
  74832. */
  74833. addFromContainer(container: AbstractScene): void;
  74834. /**
  74835. * Removes all the elements in the container from the scene
  74836. * @param container contains the elements to remove
  74837. * @param dispose if the removed element should be disposed (default: false)
  74838. */
  74839. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  74840. /**
  74841. * Serializes the component data to the specified json object
  74842. * @param serializationObject The object to serialize to
  74843. */
  74844. serialize(serializationObject: any): void;
  74845. }
  74846. /**
  74847. * Strong typing of a Mesh related stage step action
  74848. */
  74849. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  74850. /**
  74851. * Strong typing of a Evaluate Sub Mesh related stage step action
  74852. */
  74853. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  74854. /**
  74855. * Strong typing of a Active Mesh related stage step action
  74856. */
  74857. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  74858. /**
  74859. * Strong typing of a Camera related stage step action
  74860. */
  74861. export type CameraStageAction = (camera: Camera) => void;
  74862. /**
  74863. * Strong typing of a Camera Frame buffer related stage step action
  74864. */
  74865. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  74866. /**
  74867. * Strong typing of a Render Target related stage step action
  74868. */
  74869. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  74870. /**
  74871. * Strong typing of a RenderingGroup related stage step action
  74872. */
  74873. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  74874. /**
  74875. * Strong typing of a Mesh Render related stage step action
  74876. */
  74877. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  74878. /**
  74879. * Strong typing of a simple stage step action
  74880. */
  74881. export type SimpleStageAction = () => void;
  74882. /**
  74883. * Strong typing of a render target action.
  74884. */
  74885. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  74886. /**
  74887. * Strong typing of a pointer move action.
  74888. */
  74889. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  74890. /**
  74891. * Strong typing of a pointer up/down action.
  74892. */
  74893. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  74894. /**
  74895. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  74896. * @hidden
  74897. */
  74898. export class Stage<T extends Function> extends Array<{
  74899. index: number;
  74900. component: ISceneComponent;
  74901. action: T;
  74902. }> {
  74903. /**
  74904. * Hide ctor from the rest of the world.
  74905. * @param items The items to add.
  74906. */
  74907. private constructor();
  74908. /**
  74909. * Creates a new Stage.
  74910. * @returns A new instance of a Stage
  74911. */
  74912. static Create<T extends Function>(): Stage<T>;
  74913. /**
  74914. * Registers a step in an ordered way in the targeted stage.
  74915. * @param index Defines the position to register the step in
  74916. * @param component Defines the component attached to the step
  74917. * @param action Defines the action to launch during the step
  74918. */
  74919. registerStep(index: number, component: ISceneComponent, action: T): void;
  74920. /**
  74921. * Clears all the steps from the stage.
  74922. */
  74923. clear(): void;
  74924. }
  74925. }
  74926. declare module BABYLON {
  74927. interface Scene {
  74928. /** @hidden */
  74929. _pointerOverSprite: Nullable<Sprite>;
  74930. /** @hidden */
  74931. _pickedDownSprite: Nullable<Sprite>;
  74932. /** @hidden */
  74933. _tempSpritePickingRay: Nullable<Ray>;
  74934. /**
  74935. * All of the sprite managers added to this scene
  74936. * @see http://doc.babylonjs.com/babylon101/sprites
  74937. */
  74938. spriteManagers: Array<ISpriteManager>;
  74939. /**
  74940. * An event triggered when sprites rendering is about to start
  74941. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74942. */
  74943. onBeforeSpritesRenderingObservable: Observable<Scene>;
  74944. /**
  74945. * An event triggered when sprites rendering is done
  74946. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  74947. */
  74948. onAfterSpritesRenderingObservable: Observable<Scene>;
  74949. /** @hidden */
  74950. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74951. /** Launch a ray to try to pick a sprite in the scene
  74952. * @param x position on screen
  74953. * @param y position on screen
  74954. * @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
  74955. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74956. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  74957. * @returns a PickingInfo
  74958. */
  74959. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74960. /** Use the given ray to pick a sprite in the scene
  74961. * @param ray The ray (in world space) to use to pick meshes
  74962. * @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
  74963. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  74964. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  74965. * @returns a PickingInfo
  74966. */
  74967. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  74968. /**
  74969. * Force the sprite under the pointer
  74970. * @param sprite defines the sprite to use
  74971. */
  74972. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  74973. /**
  74974. * Gets the sprite under the pointer
  74975. * @returns a Sprite or null if no sprite is under the pointer
  74976. */
  74977. getPointerOverSprite(): Nullable<Sprite>;
  74978. }
  74979. /**
  74980. * Defines the sprite scene component responsible to manage sprites
  74981. * in a given scene.
  74982. */
  74983. export class SpriteSceneComponent implements ISceneComponent {
  74984. /**
  74985. * The component name helpfull to identify the component in the list of scene components.
  74986. */
  74987. readonly name: string;
  74988. /**
  74989. * The scene the component belongs to.
  74990. */
  74991. scene: Scene;
  74992. /** @hidden */
  74993. private _spritePredicate;
  74994. /**
  74995. * Creates a new instance of the component for the given scene
  74996. * @param scene Defines the scene to register the component in
  74997. */
  74998. constructor(scene: Scene);
  74999. /**
  75000. * Registers the component in a given scene
  75001. */
  75002. register(): void;
  75003. /**
  75004. * Rebuilds the elements related to this component in case of
  75005. * context lost for instance.
  75006. */
  75007. rebuild(): void;
  75008. /**
  75009. * Disposes the component and the associated ressources.
  75010. */
  75011. dispose(): void;
  75012. private _pickSpriteButKeepRay;
  75013. private _pointerMove;
  75014. private _pointerDown;
  75015. private _pointerUp;
  75016. }
  75017. }
  75018. declare module BABYLON {
  75019. /** @hidden */
  75020. export var fogFragmentDeclaration: {
  75021. name: string;
  75022. shader: string;
  75023. };
  75024. }
  75025. declare module BABYLON {
  75026. /** @hidden */
  75027. export var fogFragment: {
  75028. name: string;
  75029. shader: string;
  75030. };
  75031. }
  75032. declare module BABYLON {
  75033. /** @hidden */
  75034. export var spritesPixelShader: {
  75035. name: string;
  75036. shader: string;
  75037. };
  75038. }
  75039. declare module BABYLON {
  75040. /** @hidden */
  75041. export var fogVertexDeclaration: {
  75042. name: string;
  75043. shader: string;
  75044. };
  75045. }
  75046. declare module BABYLON {
  75047. /** @hidden */
  75048. export var spritesVertexShader: {
  75049. name: string;
  75050. shader: string;
  75051. };
  75052. }
  75053. declare module BABYLON {
  75054. /**
  75055. * Defines the minimum interface to fullfil in order to be a sprite manager.
  75056. */
  75057. export interface ISpriteManager extends IDisposable {
  75058. /**
  75059. * Restricts the camera to viewing objects with the same layerMask.
  75060. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  75061. */
  75062. layerMask: number;
  75063. /**
  75064. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  75065. */
  75066. isPickable: boolean;
  75067. /**
  75068. * Specifies the rendering group id for this mesh (0 by default)
  75069. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  75070. */
  75071. renderingGroupId: number;
  75072. /**
  75073. * Defines the list of sprites managed by the manager.
  75074. */
  75075. sprites: Array<Sprite>;
  75076. /**
  75077. * Tests the intersection of a sprite with a specific ray.
  75078. * @param ray The ray we are sending to test the collision
  75079. * @param camera The camera space we are sending rays in
  75080. * @param predicate A predicate allowing excluding sprites from the list of object to test
  75081. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  75082. * @returns picking info or null.
  75083. */
  75084. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75085. /**
  75086. * Renders the list of sprites on screen.
  75087. */
  75088. render(): void;
  75089. }
  75090. /**
  75091. * Class used to manage multiple sprites on the same spritesheet
  75092. * @see http://doc.babylonjs.com/babylon101/sprites
  75093. */
  75094. export class SpriteManager implements ISpriteManager {
  75095. /** defines the manager's name */
  75096. name: string;
  75097. /** Gets the list of sprites */
  75098. sprites: Sprite[];
  75099. /** Gets or sets the rendering group id (0 by default) */
  75100. renderingGroupId: number;
  75101. /** Gets or sets camera layer mask */
  75102. layerMask: number;
  75103. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  75104. fogEnabled: boolean;
  75105. /** Gets or sets a boolean indicating if the sprites are pickable */
  75106. isPickable: boolean;
  75107. /** Defines the default width of a cell in the spritesheet */
  75108. cellWidth: number;
  75109. /** Defines the default height of a cell in the spritesheet */
  75110. cellHeight: number;
  75111. /**
  75112. * An event triggered when the manager is disposed.
  75113. */
  75114. onDisposeObservable: Observable<SpriteManager>;
  75115. private _onDisposeObserver;
  75116. /**
  75117. * Callback called when the manager is disposed
  75118. */
  75119. onDispose: () => void;
  75120. private _capacity;
  75121. private _spriteTexture;
  75122. private _epsilon;
  75123. private _scene;
  75124. private _vertexData;
  75125. private _buffer;
  75126. private _vertexBuffers;
  75127. private _indexBuffer;
  75128. private _effectBase;
  75129. private _effectFog;
  75130. /**
  75131. * Gets or sets the spritesheet texture
  75132. */
  75133. texture: Texture;
  75134. /**
  75135. * Creates a new sprite manager
  75136. * @param name defines the manager's name
  75137. * @param imgUrl defines the sprite sheet url
  75138. * @param capacity defines the maximum allowed number of sprites
  75139. * @param cellSize defines the size of a sprite cell
  75140. * @param scene defines the hosting scene
  75141. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75142. * @param samplingMode defines the smapling mode to use with spritesheet
  75143. */
  75144. constructor(
  75145. /** defines the manager's name */
  75146. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  75147. private _appendSpriteVertex;
  75148. /**
  75149. * Intersects the sprites with a ray
  75150. * @param ray defines the ray to intersect with
  75151. * @param camera defines the current active camera
  75152. * @param predicate defines a predicate used to select candidate sprites
  75153. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  75154. * @returns null if no hit or a PickingInfo
  75155. */
  75156. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  75157. /**
  75158. * Render all child sprites
  75159. */
  75160. render(): void;
  75161. /**
  75162. * Release associated resources
  75163. */
  75164. dispose(): void;
  75165. }
  75166. }
  75167. declare module BABYLON {
  75168. /**
  75169. * Class used to represent a sprite
  75170. * @see http://doc.babylonjs.com/babylon101/sprites
  75171. */
  75172. export class Sprite {
  75173. /** defines the name */
  75174. name: string;
  75175. /** Gets or sets the current world position */
  75176. position: Vector3;
  75177. /** Gets or sets the main color */
  75178. color: Color4;
  75179. /** Gets or sets the width */
  75180. width: number;
  75181. /** Gets or sets the height */
  75182. height: number;
  75183. /** Gets or sets rotation angle */
  75184. angle: number;
  75185. /** Gets or sets the cell index in the sprite sheet */
  75186. cellIndex: number;
  75187. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  75188. invertU: number;
  75189. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  75190. invertV: number;
  75191. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  75192. disposeWhenFinishedAnimating: boolean;
  75193. /** Gets the list of attached animations */
  75194. animations: Animation[];
  75195. /** Gets or sets a boolean indicating if the sprite can be picked */
  75196. isPickable: boolean;
  75197. /**
  75198. * Gets or sets the associated action manager
  75199. */
  75200. actionManager: Nullable<ActionManager>;
  75201. private _animationStarted;
  75202. private _loopAnimation;
  75203. private _fromIndex;
  75204. private _toIndex;
  75205. private _delay;
  75206. private _direction;
  75207. private _manager;
  75208. private _time;
  75209. private _onAnimationEnd;
  75210. /**
  75211. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  75212. */
  75213. isVisible: boolean;
  75214. /**
  75215. * Gets or sets the sprite size
  75216. */
  75217. size: number;
  75218. /**
  75219. * Creates a new Sprite
  75220. * @param name defines the name
  75221. * @param manager defines the manager
  75222. */
  75223. constructor(
  75224. /** defines the name */
  75225. name: string, manager: ISpriteManager);
  75226. /**
  75227. * Starts an animation
  75228. * @param from defines the initial key
  75229. * @param to defines the end key
  75230. * @param loop defines if the animation must loop
  75231. * @param delay defines the start delay (in ms)
  75232. * @param onAnimationEnd defines a callback to call when animation ends
  75233. */
  75234. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  75235. /** Stops current animation (if any) */
  75236. stopAnimation(): void;
  75237. /** @hidden */
  75238. _animate(deltaTime: number): void;
  75239. /** Release associated resources */
  75240. dispose(): void;
  75241. }
  75242. }
  75243. declare module BABYLON {
  75244. /**
  75245. * Information about the result of picking within a scene
  75246. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  75247. */
  75248. export class PickingInfo {
  75249. /** @hidden */
  75250. _pickingUnavailable: boolean;
  75251. /**
  75252. * If the pick collided with an object
  75253. */
  75254. hit: boolean;
  75255. /**
  75256. * Distance away where the pick collided
  75257. */
  75258. distance: number;
  75259. /**
  75260. * The location of pick collision
  75261. */
  75262. pickedPoint: Nullable<Vector3>;
  75263. /**
  75264. * The mesh corresponding the the pick collision
  75265. */
  75266. pickedMesh: Nullable<AbstractMesh>;
  75267. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  75268. bu: number;
  75269. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  75270. bv: number;
  75271. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  75272. faceId: number;
  75273. /** Id of the the submesh that was picked */
  75274. subMeshId: number;
  75275. /** If a sprite was picked, this will be the sprite the pick collided with */
  75276. pickedSprite: Nullable<Sprite>;
  75277. /**
  75278. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  75279. */
  75280. originMesh: Nullable<AbstractMesh>;
  75281. /**
  75282. * The ray that was used to perform the picking.
  75283. */
  75284. ray: Nullable<Ray>;
  75285. /**
  75286. * Gets the normal correspodning to the face the pick collided with
  75287. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  75288. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  75289. * @returns The normal correspodning to the face the pick collided with
  75290. */
  75291. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  75292. /**
  75293. * Gets the texture coordinates of where the pick occured
  75294. * @returns the vector containing the coordnates of the texture
  75295. */
  75296. getTextureCoordinates(): Nullable<Vector2>;
  75297. }
  75298. }
  75299. declare module BABYLON {
  75300. /**
  75301. * Gather the list of pointer event types as constants.
  75302. */
  75303. export class PointerEventTypes {
  75304. /**
  75305. * 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.
  75306. */
  75307. static readonly POINTERDOWN: number;
  75308. /**
  75309. * The pointerup event is fired when a pointer is no longer active.
  75310. */
  75311. static readonly POINTERUP: number;
  75312. /**
  75313. * The pointermove event is fired when a pointer changes coordinates.
  75314. */
  75315. static readonly POINTERMOVE: number;
  75316. /**
  75317. * The pointerwheel event is fired when a mouse wheel has been rotated.
  75318. */
  75319. static readonly POINTERWHEEL: number;
  75320. /**
  75321. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  75322. */
  75323. static readonly POINTERPICK: number;
  75324. /**
  75325. * The pointertap event is fired when a the object has been touched and released without drag.
  75326. */
  75327. static readonly POINTERTAP: number;
  75328. /**
  75329. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  75330. */
  75331. static readonly POINTERDOUBLETAP: number;
  75332. }
  75333. /**
  75334. * Base class of pointer info types.
  75335. */
  75336. export class PointerInfoBase {
  75337. /**
  75338. * Defines the type of event (PointerEventTypes)
  75339. */
  75340. type: number;
  75341. /**
  75342. * Defines the related dom event
  75343. */
  75344. event: PointerEvent | MouseWheelEvent;
  75345. /**
  75346. * Instantiates the base class of pointers info.
  75347. * @param type Defines the type of event (PointerEventTypes)
  75348. * @param event Defines the related dom event
  75349. */
  75350. constructor(
  75351. /**
  75352. * Defines the type of event (PointerEventTypes)
  75353. */
  75354. type: number,
  75355. /**
  75356. * Defines the related dom event
  75357. */
  75358. event: PointerEvent | MouseWheelEvent);
  75359. }
  75360. /**
  75361. * This class is used to store pointer related info for the onPrePointerObservable event.
  75362. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  75363. */
  75364. export class PointerInfoPre extends PointerInfoBase {
  75365. /**
  75366. * Ray from a pointer if availible (eg. 6dof controller)
  75367. */
  75368. ray: Nullable<Ray>;
  75369. /**
  75370. * Defines the local position of the pointer on the canvas.
  75371. */
  75372. localPosition: Vector2;
  75373. /**
  75374. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  75375. */
  75376. skipOnPointerObservable: boolean;
  75377. /**
  75378. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  75379. * @param type Defines the type of event (PointerEventTypes)
  75380. * @param event Defines the related dom event
  75381. * @param localX Defines the local x coordinates of the pointer when the event occured
  75382. * @param localY Defines the local y coordinates of the pointer when the event occured
  75383. */
  75384. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  75385. }
  75386. /**
  75387. * This type contains all the data related to a pointer event in Babylon.js.
  75388. * 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.
  75389. */
  75390. export class PointerInfo extends PointerInfoBase {
  75391. /**
  75392. * Defines the picking info associated to the info (if any)\
  75393. */
  75394. pickInfo: Nullable<PickingInfo>;
  75395. /**
  75396. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  75397. * @param type Defines the type of event (PointerEventTypes)
  75398. * @param event Defines the related dom event
  75399. * @param pickInfo Defines the picking info associated to the info (if any)\
  75400. */
  75401. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  75402. /**
  75403. * Defines the picking info associated to the info (if any)\
  75404. */
  75405. pickInfo: Nullable<PickingInfo>);
  75406. }
  75407. /**
  75408. * Data relating to a touch event on the screen.
  75409. */
  75410. export interface PointerTouch {
  75411. /**
  75412. * X coordinate of touch.
  75413. */
  75414. x: number;
  75415. /**
  75416. * Y coordinate of touch.
  75417. */
  75418. y: number;
  75419. /**
  75420. * Id of touch. Unique for each finger.
  75421. */
  75422. pointerId: number;
  75423. /**
  75424. * Event type passed from DOM.
  75425. */
  75426. type: any;
  75427. }
  75428. }
  75429. declare module BABYLON {
  75430. /**
  75431. * Manage the mouse inputs to control the movement of a free camera.
  75432. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75433. */
  75434. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  75435. /**
  75436. * Define if touch is enabled in the mouse input
  75437. */
  75438. touchEnabled: boolean;
  75439. /**
  75440. * Defines the camera the input is attached to.
  75441. */
  75442. camera: FreeCamera;
  75443. /**
  75444. * Defines the buttons associated with the input to handle camera move.
  75445. */
  75446. buttons: number[];
  75447. /**
  75448. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  75449. */
  75450. angularSensibility: number;
  75451. private _pointerInput;
  75452. private _onMouseMove;
  75453. private _observer;
  75454. private previousPosition;
  75455. /**
  75456. * Observable for when a pointer move event occurs containing the move offset
  75457. */
  75458. onPointerMovedObservable: Observable<{
  75459. offsetX: number;
  75460. offsetY: number;
  75461. }>;
  75462. /**
  75463. * @hidden
  75464. * If the camera should be rotated automatically based on pointer movement
  75465. */
  75466. _allowCameraRotation: boolean;
  75467. /**
  75468. * Manage the mouse inputs to control the movement of a free camera.
  75469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75470. * @param touchEnabled Defines if touch is enabled or not
  75471. */
  75472. constructor(
  75473. /**
  75474. * Define if touch is enabled in the mouse input
  75475. */
  75476. touchEnabled?: boolean);
  75477. /**
  75478. * Attach the input controls to a specific dom element to get the input from.
  75479. * @param element Defines the element the controls should be listened from
  75480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75481. */
  75482. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75483. /**
  75484. * Called on JS contextmenu event.
  75485. * Override this method to provide functionality.
  75486. */
  75487. protected onContextMenu(evt: PointerEvent): void;
  75488. /**
  75489. * Detach the current controls from the specified dom element.
  75490. * @param element Defines the element to stop listening the inputs from
  75491. */
  75492. detachControl(element: Nullable<HTMLElement>): void;
  75493. /**
  75494. * Gets the class name of the current intput.
  75495. * @returns the class name
  75496. */
  75497. getClassName(): string;
  75498. /**
  75499. * Get the friendly name associated with the input class.
  75500. * @returns the input friendly name
  75501. */
  75502. getSimpleName(): string;
  75503. }
  75504. }
  75505. declare module BABYLON {
  75506. /**
  75507. * Manage the touch inputs to control the movement of a free camera.
  75508. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75509. */
  75510. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  75511. /**
  75512. * Defines the camera the input is attached to.
  75513. */
  75514. camera: FreeCamera;
  75515. /**
  75516. * Defines the touch sensibility for rotation.
  75517. * The higher the faster.
  75518. */
  75519. touchAngularSensibility: number;
  75520. /**
  75521. * Defines the touch sensibility for move.
  75522. * The higher the faster.
  75523. */
  75524. touchMoveSensibility: number;
  75525. private _offsetX;
  75526. private _offsetY;
  75527. private _pointerPressed;
  75528. private _pointerInput;
  75529. private _observer;
  75530. private _onLostFocus;
  75531. /**
  75532. * Attach the input controls to a specific dom element to get the input from.
  75533. * @param element Defines the element the controls should be listened from
  75534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75535. */
  75536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75537. /**
  75538. * Detach the current controls from the specified dom element.
  75539. * @param element Defines the element to stop listening the inputs from
  75540. */
  75541. detachControl(element: Nullable<HTMLElement>): void;
  75542. /**
  75543. * Update the current camera state depending on the inputs that have been used this frame.
  75544. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75545. */
  75546. checkInputs(): void;
  75547. /**
  75548. * Gets the class name of the current intput.
  75549. * @returns the class name
  75550. */
  75551. getClassName(): string;
  75552. /**
  75553. * Get the friendly name associated with the input class.
  75554. * @returns the input friendly name
  75555. */
  75556. getSimpleName(): string;
  75557. }
  75558. }
  75559. declare module BABYLON {
  75560. /**
  75561. * Default Inputs manager for the FreeCamera.
  75562. * It groups all the default supported inputs for ease of use.
  75563. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75564. */
  75565. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  75566. /**
  75567. * @hidden
  75568. */
  75569. _mouseInput: Nullable<FreeCameraMouseInput>;
  75570. /**
  75571. * Instantiates a new FreeCameraInputsManager.
  75572. * @param camera Defines the camera the inputs belong to
  75573. */
  75574. constructor(camera: FreeCamera);
  75575. /**
  75576. * Add keyboard input support to the input manager.
  75577. * @returns the current input manager
  75578. */
  75579. addKeyboard(): FreeCameraInputsManager;
  75580. /**
  75581. * Add mouse input support to the input manager.
  75582. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  75583. * @returns the current input manager
  75584. */
  75585. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  75586. /**
  75587. * Removes the mouse input support from the manager
  75588. * @returns the current input manager
  75589. */
  75590. removeMouse(): FreeCameraInputsManager;
  75591. /**
  75592. * Add touch input support to the input manager.
  75593. * @returns the current input manager
  75594. */
  75595. addTouch(): FreeCameraInputsManager;
  75596. /**
  75597. * Remove all attached input methods from a camera
  75598. */
  75599. clear(): void;
  75600. }
  75601. }
  75602. declare module BABYLON {
  75603. /**
  75604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75605. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  75606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75607. */
  75608. export class FreeCamera extends TargetCamera {
  75609. /**
  75610. * Define the collision ellipsoid of the camera.
  75611. * This is helpful to simulate a camera body like the player body around the camera
  75612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  75613. */
  75614. ellipsoid: Vector3;
  75615. /**
  75616. * Define an offset for the position of the ellipsoid around the camera.
  75617. * This can be helpful to determine the center of the body near the gravity center of the body
  75618. * instead of its head.
  75619. */
  75620. ellipsoidOffset: Vector3;
  75621. /**
  75622. * Enable or disable collisions of the camera with the rest of the scene objects.
  75623. */
  75624. checkCollisions: boolean;
  75625. /**
  75626. * Enable or disable gravity on the camera.
  75627. */
  75628. applyGravity: boolean;
  75629. /**
  75630. * Define the input manager associated to the camera.
  75631. */
  75632. inputs: FreeCameraInputsManager;
  75633. /**
  75634. * Gets the input sensibility for a mouse input. (default is 2000.0)
  75635. * Higher values reduce sensitivity.
  75636. */
  75637. /**
  75638. * Sets the input sensibility for a mouse input. (default is 2000.0)
  75639. * Higher values reduce sensitivity.
  75640. */
  75641. angularSensibility: number;
  75642. /**
  75643. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75644. */
  75645. keysUp: number[];
  75646. /**
  75647. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75648. */
  75649. keysDown: number[];
  75650. /**
  75651. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75652. */
  75653. keysLeft: number[];
  75654. /**
  75655. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75656. */
  75657. keysRight: number[];
  75658. /**
  75659. * Event raised when the camera collide with a mesh in the scene.
  75660. */
  75661. onCollide: (collidedMesh: AbstractMesh) => void;
  75662. private _collider;
  75663. private _needMoveForGravity;
  75664. private _oldPosition;
  75665. private _diffPosition;
  75666. private _newPosition;
  75667. /** @hidden */
  75668. _localDirection: Vector3;
  75669. /** @hidden */
  75670. _transformedDirection: Vector3;
  75671. /**
  75672. * Instantiates a Free Camera.
  75673. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  75674. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  75675. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  75676. * @param name Define the name of the camera in the scene
  75677. * @param position Define the start position of the camera in the scene
  75678. * @param scene Define the scene the camera belongs to
  75679. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75680. */
  75681. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75682. /**
  75683. * Attached controls to the current camera.
  75684. * @param element Defines the element the controls should be listened from
  75685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75686. */
  75687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75688. /**
  75689. * Detach the current controls from the camera.
  75690. * The camera will stop reacting to inputs.
  75691. * @param element Defines the element to stop listening the inputs from
  75692. */
  75693. detachControl(element: HTMLElement): void;
  75694. private _collisionMask;
  75695. /**
  75696. * Define a collision mask to limit the list of object the camera can collide with
  75697. */
  75698. collisionMask: number;
  75699. /** @hidden */
  75700. _collideWithWorld(displacement: Vector3): void;
  75701. private _onCollisionPositionChange;
  75702. /** @hidden */
  75703. _checkInputs(): void;
  75704. /** @hidden */
  75705. _decideIfNeedsToMove(): boolean;
  75706. /** @hidden */
  75707. _updatePosition(): void;
  75708. /**
  75709. * Destroy the camera and release the current resources hold by it.
  75710. */
  75711. dispose(): void;
  75712. /**
  75713. * Gets the current object class name.
  75714. * @return the class name
  75715. */
  75716. getClassName(): string;
  75717. }
  75718. }
  75719. declare module BABYLON {
  75720. /**
  75721. * Represents a gamepad control stick position
  75722. */
  75723. export class StickValues {
  75724. /**
  75725. * The x component of the control stick
  75726. */
  75727. x: number;
  75728. /**
  75729. * The y component of the control stick
  75730. */
  75731. y: number;
  75732. /**
  75733. * Initializes the gamepad x and y control stick values
  75734. * @param x The x component of the gamepad control stick value
  75735. * @param y The y component of the gamepad control stick value
  75736. */
  75737. constructor(
  75738. /**
  75739. * The x component of the control stick
  75740. */
  75741. x: number,
  75742. /**
  75743. * The y component of the control stick
  75744. */
  75745. y: number);
  75746. }
  75747. /**
  75748. * An interface which manages callbacks for gamepad button changes
  75749. */
  75750. export interface GamepadButtonChanges {
  75751. /**
  75752. * Called when a gamepad has been changed
  75753. */
  75754. changed: boolean;
  75755. /**
  75756. * Called when a gamepad press event has been triggered
  75757. */
  75758. pressChanged: boolean;
  75759. /**
  75760. * Called when a touch event has been triggered
  75761. */
  75762. touchChanged: boolean;
  75763. /**
  75764. * Called when a value has changed
  75765. */
  75766. valueChanged: boolean;
  75767. }
  75768. /**
  75769. * Represents a gamepad
  75770. */
  75771. export class Gamepad {
  75772. /**
  75773. * The id of the gamepad
  75774. */
  75775. id: string;
  75776. /**
  75777. * The index of the gamepad
  75778. */
  75779. index: number;
  75780. /**
  75781. * The browser gamepad
  75782. */
  75783. browserGamepad: any;
  75784. /**
  75785. * Specifies what type of gamepad this represents
  75786. */
  75787. type: number;
  75788. private _leftStick;
  75789. private _rightStick;
  75790. /** @hidden */
  75791. _isConnected: boolean;
  75792. private _leftStickAxisX;
  75793. private _leftStickAxisY;
  75794. private _rightStickAxisX;
  75795. private _rightStickAxisY;
  75796. /**
  75797. * Triggered when the left control stick has been changed
  75798. */
  75799. private _onleftstickchanged;
  75800. /**
  75801. * Triggered when the right control stick has been changed
  75802. */
  75803. private _onrightstickchanged;
  75804. /**
  75805. * Represents a gamepad controller
  75806. */
  75807. static GAMEPAD: number;
  75808. /**
  75809. * Represents a generic controller
  75810. */
  75811. static GENERIC: number;
  75812. /**
  75813. * Represents an XBox controller
  75814. */
  75815. static XBOX: number;
  75816. /**
  75817. * Represents a pose-enabled controller
  75818. */
  75819. static POSE_ENABLED: number;
  75820. /**
  75821. * Specifies whether the left control stick should be Y-inverted
  75822. */
  75823. protected _invertLeftStickY: boolean;
  75824. /**
  75825. * Specifies if the gamepad has been connected
  75826. */
  75827. readonly isConnected: boolean;
  75828. /**
  75829. * Initializes the gamepad
  75830. * @param id The id of the gamepad
  75831. * @param index The index of the gamepad
  75832. * @param browserGamepad The browser gamepad
  75833. * @param leftStickX The x component of the left joystick
  75834. * @param leftStickY The y component of the left joystick
  75835. * @param rightStickX The x component of the right joystick
  75836. * @param rightStickY The y component of the right joystick
  75837. */
  75838. constructor(
  75839. /**
  75840. * The id of the gamepad
  75841. */
  75842. id: string,
  75843. /**
  75844. * The index of the gamepad
  75845. */
  75846. index: number,
  75847. /**
  75848. * The browser gamepad
  75849. */
  75850. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  75851. /**
  75852. * Callback triggered when the left joystick has changed
  75853. * @param callback
  75854. */
  75855. onleftstickchanged(callback: (values: StickValues) => void): void;
  75856. /**
  75857. * Callback triggered when the right joystick has changed
  75858. * @param callback
  75859. */
  75860. onrightstickchanged(callback: (values: StickValues) => void): void;
  75861. /**
  75862. * Gets the left joystick
  75863. */
  75864. /**
  75865. * Sets the left joystick values
  75866. */
  75867. leftStick: StickValues;
  75868. /**
  75869. * Gets the right joystick
  75870. */
  75871. /**
  75872. * Sets the right joystick value
  75873. */
  75874. rightStick: StickValues;
  75875. /**
  75876. * Updates the gamepad joystick positions
  75877. */
  75878. update(): void;
  75879. /**
  75880. * Disposes the gamepad
  75881. */
  75882. dispose(): void;
  75883. }
  75884. /**
  75885. * Represents a generic gamepad
  75886. */
  75887. export class GenericPad extends Gamepad {
  75888. private _buttons;
  75889. private _onbuttondown;
  75890. private _onbuttonup;
  75891. /**
  75892. * Observable triggered when a button has been pressed
  75893. */
  75894. onButtonDownObservable: Observable<number>;
  75895. /**
  75896. * Observable triggered when a button has been released
  75897. */
  75898. onButtonUpObservable: Observable<number>;
  75899. /**
  75900. * Callback triggered when a button has been pressed
  75901. * @param callback Called when a button has been pressed
  75902. */
  75903. onbuttondown(callback: (buttonPressed: number) => void): void;
  75904. /**
  75905. * Callback triggered when a button has been released
  75906. * @param callback Called when a button has been released
  75907. */
  75908. onbuttonup(callback: (buttonReleased: number) => void): void;
  75909. /**
  75910. * Initializes the generic gamepad
  75911. * @param id The id of the generic gamepad
  75912. * @param index The index of the generic gamepad
  75913. * @param browserGamepad The browser gamepad
  75914. */
  75915. constructor(id: string, index: number, browserGamepad: any);
  75916. private _setButtonValue;
  75917. /**
  75918. * Updates the generic gamepad
  75919. */
  75920. update(): void;
  75921. /**
  75922. * Disposes the generic gamepad
  75923. */
  75924. dispose(): void;
  75925. }
  75926. }
  75927. declare module BABYLON {
  75928. interface Engine {
  75929. /**
  75930. * Creates a raw texture
  75931. * @param data defines the data to store in the texture
  75932. * @param width defines the width of the texture
  75933. * @param height defines the height of the texture
  75934. * @param format defines the format of the data
  75935. * @param generateMipMaps defines if the engine should generate the mip levels
  75936. * @param invertY defines if data must be stored with Y axis inverted
  75937. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75938. * @param compression defines the compression used (null by default)
  75939. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75940. * @returns the raw texture inside an InternalTexture
  75941. */
  75942. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  75943. /**
  75944. * Update a raw texture
  75945. * @param texture defines the texture to update
  75946. * @param data defines the data to store in the texture
  75947. * @param format defines the format of the data
  75948. * @param invertY defines if data must be stored with Y axis inverted
  75949. */
  75950. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  75951. /**
  75952. * Update a raw texture
  75953. * @param texture defines the texture to update
  75954. * @param data defines the data to store in the texture
  75955. * @param format defines the format of the data
  75956. * @param invertY defines if data must be stored with Y axis inverted
  75957. * @param compression defines the compression used (null by default)
  75958. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75959. */
  75960. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  75961. /**
  75962. * Creates a new raw cube texture
  75963. * @param data defines the array of data to use to create each face
  75964. * @param size defines the size of the textures
  75965. * @param format defines the format of the data
  75966. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  75967. * @param generateMipMaps defines if the engine should generate the mip levels
  75968. * @param invertY defines if data must be stored with Y axis inverted
  75969. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  75970. * @param compression defines the compression used (null by default)
  75971. * @returns the cube texture as an InternalTexture
  75972. */
  75973. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  75974. /**
  75975. * Update a raw cube texture
  75976. * @param texture defines the texture to udpdate
  75977. * @param data defines the data to store
  75978. * @param format defines the data format
  75979. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75980. * @param invertY defines if data must be stored with Y axis inverted
  75981. */
  75982. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  75983. /**
  75984. * Update a raw cube texture
  75985. * @param texture defines the texture to udpdate
  75986. * @param data defines the data to store
  75987. * @param format defines the data format
  75988. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75989. * @param invertY defines if data must be stored with Y axis inverted
  75990. * @param compression defines the compression used (null by default)
  75991. */
  75992. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  75993. /**
  75994. * Update a raw cube texture
  75995. * @param texture defines the texture to udpdate
  75996. * @param data defines the data to store
  75997. * @param format defines the data format
  75998. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75999. * @param invertY defines if data must be stored with Y axis inverted
  76000. * @param compression defines the compression used (null by default)
  76001. * @param level defines which level of the texture to update
  76002. */
  76003. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  76004. /**
  76005. * Creates a new raw cube texture from a specified url
  76006. * @param url defines the url where the data is located
  76007. * @param scene defines the current scene
  76008. * @param size defines the size of the textures
  76009. * @param format defines the format of the data
  76010. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76011. * @param noMipmap defines if the engine should avoid generating the mip levels
  76012. * @param callback defines a callback used to extract texture data from loaded data
  76013. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76014. * @param onLoad defines a callback called when texture is loaded
  76015. * @param onError defines a callback called if there is an error
  76016. * @returns the cube texture as an InternalTexture
  76017. */
  76018. 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;
  76019. /**
  76020. * Creates a new raw cube texture from a specified url
  76021. * @param url defines the url where the data is located
  76022. * @param scene defines the current scene
  76023. * @param size defines the size of the textures
  76024. * @param format defines the format of the data
  76025. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  76026. * @param noMipmap defines if the engine should avoid generating the mip levels
  76027. * @param callback defines a callback used to extract texture data from loaded data
  76028. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  76029. * @param onLoad defines a callback called when texture is loaded
  76030. * @param onError defines a callback called if there is an error
  76031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76032. * @param invertY defines if data must be stored with Y axis inverted
  76033. * @returns the cube texture as an InternalTexture
  76034. */
  76035. 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;
  76036. /**
  76037. * Creates a new raw 3D texture
  76038. * @param data defines the data used to create the texture
  76039. * @param width defines the width of the texture
  76040. * @param height defines the height of the texture
  76041. * @param depth defines the depth of the texture
  76042. * @param format defines the format of the texture
  76043. * @param generateMipMaps defines if the engine must generate mip levels
  76044. * @param invertY defines if data must be stored with Y axis inverted
  76045. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  76046. * @param compression defines the compressed used (can be null)
  76047. * @param textureType defines the compressed used (can be null)
  76048. * @returns a new raw 3D texture (stored in an InternalTexture)
  76049. */
  76050. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  76051. /**
  76052. * Update a raw 3D texture
  76053. * @param texture defines the texture to update
  76054. * @param data defines the data to store
  76055. * @param format defines the data format
  76056. * @param invertY defines if data must be stored with Y axis inverted
  76057. */
  76058. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  76059. /**
  76060. * Update a raw 3D texture
  76061. * @param texture defines the texture to update
  76062. * @param data defines the data to store
  76063. * @param format defines the data format
  76064. * @param invertY defines if data must be stored with Y axis inverted
  76065. * @param compression defines the used compression (can be null)
  76066. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  76067. */
  76068. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  76069. }
  76070. }
  76071. declare module BABYLON {
  76072. /**
  76073. * Raw texture can help creating a texture directly from an array of data.
  76074. * This can be super useful if you either get the data from an uncompressed source or
  76075. * if you wish to create your texture pixel by pixel.
  76076. */
  76077. export class RawTexture extends Texture {
  76078. /**
  76079. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76080. */
  76081. format: number;
  76082. private _engine;
  76083. /**
  76084. * Instantiates a new RawTexture.
  76085. * Raw texture can help creating a texture directly from an array of data.
  76086. * This can be super useful if you either get the data from an uncompressed source or
  76087. * if you wish to create your texture pixel by pixel.
  76088. * @param data define the array of data to use to create the texture
  76089. * @param width define the width of the texture
  76090. * @param height define the height of the texture
  76091. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76092. * @param scene define the scene the texture belongs to
  76093. * @param generateMipMaps define whether mip maps should be generated or not
  76094. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76095. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76096. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76097. */
  76098. constructor(data: ArrayBufferView, width: number, height: number,
  76099. /**
  76100. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  76101. */
  76102. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  76103. /**
  76104. * Updates the texture underlying data.
  76105. * @param data Define the new data of the texture
  76106. */
  76107. update(data: ArrayBufferView): void;
  76108. /**
  76109. * Creates a luminance texture from some data.
  76110. * @param data Define the texture data
  76111. * @param width Define the width of the texture
  76112. * @param height Define the height of the texture
  76113. * @param scene Define the scene the texture belongs to
  76114. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76115. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76116. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76117. * @returns the luminance texture
  76118. */
  76119. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76120. /**
  76121. * Creates a luminance alpha texture from some data.
  76122. * @param data Define the texture data
  76123. * @param width Define the width of the texture
  76124. * @param height Define the height of the texture
  76125. * @param scene Define the scene the texture belongs to
  76126. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76127. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76128. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76129. * @returns the luminance alpha texture
  76130. */
  76131. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76132. /**
  76133. * Creates an alpha texture from some data.
  76134. * @param data Define the texture data
  76135. * @param width Define the width of the texture
  76136. * @param height Define the height of the texture
  76137. * @param scene Define the scene the texture belongs to
  76138. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76139. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76140. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76141. * @returns the alpha texture
  76142. */
  76143. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  76144. /**
  76145. * Creates a RGB texture from some data.
  76146. * @param data Define the texture data
  76147. * @param width Define the width of the texture
  76148. * @param height Define the height of the texture
  76149. * @param scene Define the scene the texture belongs to
  76150. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76151. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76152. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76153. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76154. * @returns the RGB alpha texture
  76155. */
  76156. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76157. /**
  76158. * Creates a RGBA texture from some data.
  76159. * @param data Define the texture data
  76160. * @param width Define the width of the texture
  76161. * @param height Define the height of the texture
  76162. * @param scene Define the scene the texture belongs to
  76163. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76164. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76165. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76166. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76167. * @returns the RGBA texture
  76168. */
  76169. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76170. /**
  76171. * Creates a R texture from some data.
  76172. * @param data Define the texture data
  76173. * @param width Define the width of the texture
  76174. * @param height Define the height of the texture
  76175. * @param scene Define the scene the texture belongs to
  76176. * @param generateMipMaps Define whether or not to create mip maps for the texture
  76177. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  76178. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  76179. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  76180. * @returns the R texture
  76181. */
  76182. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  76183. }
  76184. }
  76185. declare module BABYLON {
  76186. /**
  76187. * Interface for the size containing width and height
  76188. */
  76189. export interface ISize {
  76190. /**
  76191. * Width
  76192. */
  76193. width: number;
  76194. /**
  76195. * Heighht
  76196. */
  76197. height: number;
  76198. }
  76199. /**
  76200. * Size containing widht and height
  76201. */
  76202. export class Size implements ISize {
  76203. /**
  76204. * Width
  76205. */
  76206. width: number;
  76207. /**
  76208. * Height
  76209. */
  76210. height: number;
  76211. /**
  76212. * Creates a Size object from the given width and height (floats).
  76213. * @param width width of the new size
  76214. * @param height height of the new size
  76215. */
  76216. constructor(width: number, height: number);
  76217. /**
  76218. * Returns a string with the Size width and height
  76219. * @returns a string with the Size width and height
  76220. */
  76221. toString(): string;
  76222. /**
  76223. * "Size"
  76224. * @returns the string "Size"
  76225. */
  76226. getClassName(): string;
  76227. /**
  76228. * Returns the Size hash code.
  76229. * @returns a hash code for a unique width and height
  76230. */
  76231. getHashCode(): number;
  76232. /**
  76233. * Updates the current size from the given one.
  76234. * @param src the given size
  76235. */
  76236. copyFrom(src: Size): void;
  76237. /**
  76238. * Updates in place the current Size from the given floats.
  76239. * @param width width of the new size
  76240. * @param height height of the new size
  76241. * @returns the updated Size.
  76242. */
  76243. copyFromFloats(width: number, height: number): Size;
  76244. /**
  76245. * Updates in place the current Size from the given floats.
  76246. * @param width width to set
  76247. * @param height height to set
  76248. * @returns the updated Size.
  76249. */
  76250. set(width: number, height: number): Size;
  76251. /**
  76252. * Multiplies the width and height by numbers
  76253. * @param w factor to multiple the width by
  76254. * @param h factor to multiple the height by
  76255. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  76256. */
  76257. multiplyByFloats(w: number, h: number): Size;
  76258. /**
  76259. * Clones the size
  76260. * @returns a new Size copied from the given one.
  76261. */
  76262. clone(): Size;
  76263. /**
  76264. * True if the current Size and the given one width and height are strictly equal.
  76265. * @param other the other size to compare against
  76266. * @returns True if the current Size and the given one width and height are strictly equal.
  76267. */
  76268. equals(other: Size): boolean;
  76269. /**
  76270. * The surface of the Size : width * height (float).
  76271. */
  76272. readonly surface: number;
  76273. /**
  76274. * Create a new size of zero
  76275. * @returns a new Size set to (0.0, 0.0)
  76276. */
  76277. static Zero(): Size;
  76278. /**
  76279. * Sums the width and height of two sizes
  76280. * @param otherSize size to add to this size
  76281. * @returns a new Size set as the addition result of the current Size and the given one.
  76282. */
  76283. add(otherSize: Size): Size;
  76284. /**
  76285. * Subtracts the width and height of two
  76286. * @param otherSize size to subtract to this size
  76287. * @returns a new Size set as the subtraction result of the given one from the current Size.
  76288. */
  76289. subtract(otherSize: Size): Size;
  76290. /**
  76291. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  76292. * @param start starting size to lerp between
  76293. * @param end end size to lerp between
  76294. * @param amount amount to lerp between the start and end values
  76295. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  76296. */
  76297. static Lerp(start: Size, end: Size, amount: number): Size;
  76298. }
  76299. }
  76300. declare module BABYLON {
  76301. /**
  76302. * Defines a runtime animation
  76303. */
  76304. export class RuntimeAnimation {
  76305. private _events;
  76306. /**
  76307. * The current frame of the runtime animation
  76308. */
  76309. private _currentFrame;
  76310. /**
  76311. * The animation used by the runtime animation
  76312. */
  76313. private _animation;
  76314. /**
  76315. * The target of the runtime animation
  76316. */
  76317. private _target;
  76318. /**
  76319. * The initiating animatable
  76320. */
  76321. private _host;
  76322. /**
  76323. * The original value of the runtime animation
  76324. */
  76325. private _originalValue;
  76326. /**
  76327. * The original blend value of the runtime animation
  76328. */
  76329. private _originalBlendValue;
  76330. /**
  76331. * The offsets cache of the runtime animation
  76332. */
  76333. private _offsetsCache;
  76334. /**
  76335. * The high limits cache of the runtime animation
  76336. */
  76337. private _highLimitsCache;
  76338. /**
  76339. * Specifies if the runtime animation has been stopped
  76340. */
  76341. private _stopped;
  76342. /**
  76343. * The blending factor of the runtime animation
  76344. */
  76345. private _blendingFactor;
  76346. /**
  76347. * The BabylonJS scene
  76348. */
  76349. private _scene;
  76350. /**
  76351. * The current value of the runtime animation
  76352. */
  76353. private _currentValue;
  76354. /** @hidden */
  76355. _animationState: _IAnimationState;
  76356. /**
  76357. * The active target of the runtime animation
  76358. */
  76359. private _activeTargets;
  76360. private _currentActiveTarget;
  76361. private _directTarget;
  76362. /**
  76363. * The target path of the runtime animation
  76364. */
  76365. private _targetPath;
  76366. /**
  76367. * The weight of the runtime animation
  76368. */
  76369. private _weight;
  76370. /**
  76371. * The ratio offset of the runtime animation
  76372. */
  76373. private _ratioOffset;
  76374. /**
  76375. * The previous delay of the runtime animation
  76376. */
  76377. private _previousDelay;
  76378. /**
  76379. * The previous ratio of the runtime animation
  76380. */
  76381. private _previousRatio;
  76382. private _enableBlending;
  76383. private _keys;
  76384. private _minFrame;
  76385. private _maxFrame;
  76386. private _minValue;
  76387. private _maxValue;
  76388. private _targetIsArray;
  76389. /**
  76390. * Gets the current frame of the runtime animation
  76391. */
  76392. readonly currentFrame: number;
  76393. /**
  76394. * Gets the weight of the runtime animation
  76395. */
  76396. readonly weight: number;
  76397. /**
  76398. * Gets the current value of the runtime animation
  76399. */
  76400. readonly currentValue: any;
  76401. /**
  76402. * Gets the target path of the runtime animation
  76403. */
  76404. readonly targetPath: string;
  76405. /**
  76406. * Gets the actual target of the runtime animation
  76407. */
  76408. readonly target: any;
  76409. /** @hidden */
  76410. _onLoop: () => void;
  76411. /**
  76412. * Create a new RuntimeAnimation object
  76413. * @param target defines the target of the animation
  76414. * @param animation defines the source animation object
  76415. * @param scene defines the hosting scene
  76416. * @param host defines the initiating Animatable
  76417. */
  76418. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  76419. private _preparePath;
  76420. /**
  76421. * Gets the animation from the runtime animation
  76422. */
  76423. readonly animation: Animation;
  76424. /**
  76425. * Resets the runtime animation to the beginning
  76426. * @param restoreOriginal defines whether to restore the target property to the original value
  76427. */
  76428. reset(restoreOriginal?: boolean): void;
  76429. /**
  76430. * Specifies if the runtime animation is stopped
  76431. * @returns Boolean specifying if the runtime animation is stopped
  76432. */
  76433. isStopped(): boolean;
  76434. /**
  76435. * Disposes of the runtime animation
  76436. */
  76437. dispose(): void;
  76438. /**
  76439. * Apply the interpolated value to the target
  76440. * @param currentValue defines the value computed by the animation
  76441. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  76442. */
  76443. setValue(currentValue: any, weight: number): void;
  76444. private _getOriginalValues;
  76445. private _setValue;
  76446. /**
  76447. * Gets the loop pmode of the runtime animation
  76448. * @returns Loop Mode
  76449. */
  76450. private _getCorrectLoopMode;
  76451. /**
  76452. * Move the current animation to a given frame
  76453. * @param frame defines the frame to move to
  76454. */
  76455. goToFrame(frame: number): void;
  76456. /**
  76457. * @hidden Internal use only
  76458. */
  76459. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  76460. /**
  76461. * Execute the current animation
  76462. * @param delay defines the delay to add to the current frame
  76463. * @param from defines the lower bound of the animation range
  76464. * @param to defines the upper bound of the animation range
  76465. * @param loop defines if the current animation must loop
  76466. * @param speedRatio defines the current speed ratio
  76467. * @param weight defines the weight of the animation (default is -1 so no weight)
  76468. * @param onLoop optional callback called when animation loops
  76469. * @returns a boolean indicating if the animation is running
  76470. */
  76471. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  76472. }
  76473. }
  76474. declare module BABYLON {
  76475. /**
  76476. * Class used to store an actual running animation
  76477. */
  76478. export class Animatable {
  76479. /** defines the target object */
  76480. target: any;
  76481. /** defines the starting frame number (default is 0) */
  76482. fromFrame: number;
  76483. /** defines the ending frame number (default is 100) */
  76484. toFrame: number;
  76485. /** defines if the animation must loop (default is false) */
  76486. loopAnimation: boolean;
  76487. /** defines a callback to call when animation ends if it is not looping */
  76488. onAnimationEnd?: (() => void) | null | undefined;
  76489. /** defines a callback to call when animation loops */
  76490. onAnimationLoop?: (() => void) | null | undefined;
  76491. private _localDelayOffset;
  76492. private _pausedDelay;
  76493. private _runtimeAnimations;
  76494. private _paused;
  76495. private _scene;
  76496. private _speedRatio;
  76497. private _weight;
  76498. private _syncRoot;
  76499. /**
  76500. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  76501. * This will only apply for non looping animation (default is true)
  76502. */
  76503. disposeOnEnd: boolean;
  76504. /**
  76505. * Gets a boolean indicating if the animation has started
  76506. */
  76507. animationStarted: boolean;
  76508. /**
  76509. * Observer raised when the animation ends
  76510. */
  76511. onAnimationEndObservable: Observable<Animatable>;
  76512. /**
  76513. * Observer raised when the animation loops
  76514. */
  76515. onAnimationLoopObservable: Observable<Animatable>;
  76516. /**
  76517. * Gets the root Animatable used to synchronize and normalize animations
  76518. */
  76519. readonly syncRoot: Nullable<Animatable>;
  76520. /**
  76521. * Gets the current frame of the first RuntimeAnimation
  76522. * Used to synchronize Animatables
  76523. */
  76524. readonly masterFrame: number;
  76525. /**
  76526. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  76527. */
  76528. weight: number;
  76529. /**
  76530. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  76531. */
  76532. speedRatio: number;
  76533. /**
  76534. * Creates a new Animatable
  76535. * @param scene defines the hosting scene
  76536. * @param target defines the target object
  76537. * @param fromFrame defines the starting frame number (default is 0)
  76538. * @param toFrame defines the ending frame number (default is 100)
  76539. * @param loopAnimation defines if the animation must loop (default is false)
  76540. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  76541. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  76542. * @param animations defines a group of animation to add to the new Animatable
  76543. * @param onAnimationLoop defines a callback to call when animation loops
  76544. */
  76545. constructor(scene: Scene,
  76546. /** defines the target object */
  76547. target: any,
  76548. /** defines the starting frame number (default is 0) */
  76549. fromFrame?: number,
  76550. /** defines the ending frame number (default is 100) */
  76551. toFrame?: number,
  76552. /** defines if the animation must loop (default is false) */
  76553. loopAnimation?: boolean, speedRatio?: number,
  76554. /** defines a callback to call when animation ends if it is not looping */
  76555. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  76556. /** defines a callback to call when animation loops */
  76557. onAnimationLoop?: (() => void) | null | undefined);
  76558. /**
  76559. * Synchronize and normalize current Animatable with a source Animatable
  76560. * This is useful when using animation weights and when animations are not of the same length
  76561. * @param root defines the root Animatable to synchronize with
  76562. * @returns the current Animatable
  76563. */
  76564. syncWith(root: Animatable): Animatable;
  76565. /**
  76566. * Gets the list of runtime animations
  76567. * @returns an array of RuntimeAnimation
  76568. */
  76569. getAnimations(): RuntimeAnimation[];
  76570. /**
  76571. * Adds more animations to the current animatable
  76572. * @param target defines the target of the animations
  76573. * @param animations defines the new animations to add
  76574. */
  76575. appendAnimations(target: any, animations: Animation[]): void;
  76576. /**
  76577. * Gets the source animation for a specific property
  76578. * @param property defines the propertyu to look for
  76579. * @returns null or the source animation for the given property
  76580. */
  76581. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  76582. /**
  76583. * Gets the runtime animation for a specific property
  76584. * @param property defines the propertyu to look for
  76585. * @returns null or the runtime animation for the given property
  76586. */
  76587. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  76588. /**
  76589. * Resets the animatable to its original state
  76590. */
  76591. reset(): void;
  76592. /**
  76593. * Allows the animatable to blend with current running animations
  76594. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76595. * @param blendingSpeed defines the blending speed to use
  76596. */
  76597. enableBlending(blendingSpeed: number): void;
  76598. /**
  76599. * Disable animation blending
  76600. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76601. */
  76602. disableBlending(): void;
  76603. /**
  76604. * Jump directly to a given frame
  76605. * @param frame defines the frame to jump to
  76606. */
  76607. goToFrame(frame: number): void;
  76608. /**
  76609. * Pause the animation
  76610. */
  76611. pause(): void;
  76612. /**
  76613. * Restart the animation
  76614. */
  76615. restart(): void;
  76616. private _raiseOnAnimationEnd;
  76617. /**
  76618. * Stop and delete the current animation
  76619. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  76620. * @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)
  76621. */
  76622. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  76623. /**
  76624. * Wait asynchronously for the animation to end
  76625. * @returns a promise which will be fullfilled when the animation ends
  76626. */
  76627. waitAsync(): Promise<Animatable>;
  76628. /** @hidden */
  76629. _animate(delay: number): boolean;
  76630. }
  76631. interface Scene {
  76632. /** @hidden */
  76633. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  76634. /** @hidden */
  76635. _processLateAnimationBindingsForMatrices(holder: {
  76636. totalWeight: number;
  76637. animations: RuntimeAnimation[];
  76638. originalValue: Matrix;
  76639. }): any;
  76640. /** @hidden */
  76641. _processLateAnimationBindingsForQuaternions(holder: {
  76642. totalWeight: number;
  76643. animations: RuntimeAnimation[];
  76644. originalValue: Quaternion;
  76645. }, refQuaternion: Quaternion): Quaternion;
  76646. /** @hidden */
  76647. _processLateAnimationBindings(): void;
  76648. /**
  76649. * Will start the animation sequence of a given target
  76650. * @param target defines the target
  76651. * @param from defines from which frame should animation start
  76652. * @param to defines until which frame should animation run.
  76653. * @param weight defines the weight to apply to the animation (1.0 by default)
  76654. * @param loop defines if the animation loops
  76655. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76656. * @param onAnimationEnd defines the function to be executed when the animation ends
  76657. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76658. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76659. * @param onAnimationLoop defines the callback to call when an animation loops
  76660. * @returns the animatable object created for this animation
  76661. */
  76662. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76663. /**
  76664. * Will start the animation sequence of a given target
  76665. * @param target defines the target
  76666. * @param from defines from which frame should animation start
  76667. * @param to defines until which frame should animation run.
  76668. * @param loop defines if the animation loops
  76669. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76670. * @param onAnimationEnd defines the function to be executed when the animation ends
  76671. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76672. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76673. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  76674. * @param onAnimationLoop defines the callback to call when an animation loops
  76675. * @returns the animatable object created for this animation
  76676. */
  76677. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  76678. /**
  76679. * Will start the animation sequence of a given target and its hierarchy
  76680. * @param target defines the target
  76681. * @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.
  76682. * @param from defines from which frame should animation start
  76683. * @param to defines until which frame should animation run.
  76684. * @param loop defines if the animation loops
  76685. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  76686. * @param onAnimationEnd defines the function to be executed when the animation ends
  76687. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  76688. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  76689. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  76690. * @param onAnimationLoop defines the callback to call when an animation loops
  76691. * @returns the list of created animatables
  76692. */
  76693. 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[];
  76694. /**
  76695. * Begin a new animation on a given node
  76696. * @param target defines the target where the animation will take place
  76697. * @param animations defines the list of animations to start
  76698. * @param from defines the initial value
  76699. * @param to defines the final value
  76700. * @param loop defines if you want animation to loop (off by default)
  76701. * @param speedRatio defines the speed ratio to apply to all animations
  76702. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76703. * @param onAnimationLoop defines the callback to call when an animation loops
  76704. * @returns the list of created animatables
  76705. */
  76706. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  76707. /**
  76708. * Begin a new animation on a given node and its hierarchy
  76709. * @param target defines the root node where the animation will take place
  76710. * @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.
  76711. * @param animations defines the list of animations to start
  76712. * @param from defines the initial value
  76713. * @param to defines the final value
  76714. * @param loop defines if you want animation to loop (off by default)
  76715. * @param speedRatio defines the speed ratio to apply to all animations
  76716. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  76717. * @param onAnimationLoop defines the callback to call when an animation loops
  76718. * @returns the list of animatables created for all nodes
  76719. */
  76720. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  76721. /**
  76722. * Gets the animatable associated with a specific target
  76723. * @param target defines the target of the animatable
  76724. * @returns the required animatable if found
  76725. */
  76726. getAnimatableByTarget(target: any): Nullable<Animatable>;
  76727. /**
  76728. * Gets all animatables associated with a given target
  76729. * @param target defines the target to look animatables for
  76730. * @returns an array of Animatables
  76731. */
  76732. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  76733. /**
  76734. * Stops and removes all animations that have been applied to the scene
  76735. */
  76736. stopAllAnimations(): void;
  76737. }
  76738. interface Bone {
  76739. /**
  76740. * Copy an animation range from another bone
  76741. * @param source defines the source bone
  76742. * @param rangeName defines the range name to copy
  76743. * @param frameOffset defines the frame offset
  76744. * @param rescaleAsRequired defines if rescaling must be applied if required
  76745. * @param skelDimensionsRatio defines the scaling ratio
  76746. * @returns true if operation was successful
  76747. */
  76748. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  76749. }
  76750. }
  76751. declare module BABYLON {
  76752. /**
  76753. * Class used to override all child animations of a given target
  76754. */
  76755. export class AnimationPropertiesOverride {
  76756. /**
  76757. * Gets or sets a value indicating if animation blending must be used
  76758. */
  76759. enableBlending: boolean;
  76760. /**
  76761. * Gets or sets the blending speed to use when enableBlending is true
  76762. */
  76763. blendingSpeed: number;
  76764. /**
  76765. * Gets or sets the default loop mode to use
  76766. */
  76767. loopMode: number;
  76768. }
  76769. }
  76770. declare module BABYLON {
  76771. /**
  76772. * Class used to handle skinning animations
  76773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  76774. */
  76775. export class Skeleton implements IAnimatable {
  76776. /** defines the skeleton name */
  76777. name: string;
  76778. /** defines the skeleton Id */
  76779. id: string;
  76780. /**
  76781. * Defines the list of child bones
  76782. */
  76783. bones: Bone[];
  76784. /**
  76785. * Defines an estimate of the dimension of the skeleton at rest
  76786. */
  76787. dimensionsAtRest: Vector3;
  76788. /**
  76789. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  76790. */
  76791. needInitialSkinMatrix: boolean;
  76792. /**
  76793. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  76794. */
  76795. overrideMesh: Nullable<AbstractMesh>;
  76796. /**
  76797. * Gets the list of animations attached to this skeleton
  76798. */
  76799. animations: Array<Animation>;
  76800. private _scene;
  76801. private _isDirty;
  76802. private _transformMatrices;
  76803. private _transformMatrixTexture;
  76804. private _meshesWithPoseMatrix;
  76805. private _animatables;
  76806. private _identity;
  76807. private _synchronizedWithMesh;
  76808. private _ranges;
  76809. private _lastAbsoluteTransformsUpdateId;
  76810. private _canUseTextureForBones;
  76811. private _uniqueId;
  76812. /** @hidden */
  76813. _numBonesWithLinkedTransformNode: number;
  76814. /** @hidden */
  76815. _hasWaitingData: Nullable<boolean>;
  76816. /**
  76817. * Specifies if the skeleton should be serialized
  76818. */
  76819. doNotSerialize: boolean;
  76820. private _useTextureToStoreBoneMatrices;
  76821. /**
  76822. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  76823. * Please note that this option is not available if the hardware does not support it
  76824. */
  76825. useTextureToStoreBoneMatrices: boolean;
  76826. private _animationPropertiesOverride;
  76827. /**
  76828. * Gets or sets the animation properties override
  76829. */
  76830. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  76831. /**
  76832. * List of inspectable custom properties (used by the Inspector)
  76833. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  76834. */
  76835. inspectableCustomProperties: IInspectable[];
  76836. /**
  76837. * An observable triggered before computing the skeleton's matrices
  76838. */
  76839. onBeforeComputeObservable: Observable<Skeleton>;
  76840. /**
  76841. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  76842. */
  76843. readonly isUsingTextureForMatrices: boolean;
  76844. /**
  76845. * Gets the unique ID of this skeleton
  76846. */
  76847. readonly uniqueId: number;
  76848. /**
  76849. * Creates a new skeleton
  76850. * @param name defines the skeleton name
  76851. * @param id defines the skeleton Id
  76852. * @param scene defines the hosting scene
  76853. */
  76854. constructor(
  76855. /** defines the skeleton name */
  76856. name: string,
  76857. /** defines the skeleton Id */
  76858. id: string, scene: Scene);
  76859. /**
  76860. * Gets the current object class name.
  76861. * @return the class name
  76862. */
  76863. getClassName(): string;
  76864. /**
  76865. * Returns an array containing the root bones
  76866. * @returns an array containing the root bones
  76867. */
  76868. getChildren(): Array<Bone>;
  76869. /**
  76870. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  76871. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76872. * @returns a Float32Array containing matrices data
  76873. */
  76874. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  76875. /**
  76876. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  76877. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  76878. * @returns a raw texture containing the data
  76879. */
  76880. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  76881. /**
  76882. * Gets the current hosting scene
  76883. * @returns a scene object
  76884. */
  76885. getScene(): Scene;
  76886. /**
  76887. * Gets a string representing the current skeleton data
  76888. * @param fullDetails defines a boolean indicating if we want a verbose version
  76889. * @returns a string representing the current skeleton data
  76890. */
  76891. toString(fullDetails?: boolean): string;
  76892. /**
  76893. * Get bone's index searching by name
  76894. * @param name defines bone's name to search for
  76895. * @return the indice of the bone. Returns -1 if not found
  76896. */
  76897. getBoneIndexByName(name: string): number;
  76898. /**
  76899. * Creater a new animation range
  76900. * @param name defines the name of the range
  76901. * @param from defines the start key
  76902. * @param to defines the end key
  76903. */
  76904. createAnimationRange(name: string, from: number, to: number): void;
  76905. /**
  76906. * Delete a specific animation range
  76907. * @param name defines the name of the range
  76908. * @param deleteFrames defines if frames must be removed as well
  76909. */
  76910. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  76911. /**
  76912. * Gets a specific animation range
  76913. * @param name defines the name of the range to look for
  76914. * @returns the requested animation range or null if not found
  76915. */
  76916. getAnimationRange(name: string): Nullable<AnimationRange>;
  76917. /**
  76918. * Gets the list of all animation ranges defined on this skeleton
  76919. * @returns an array
  76920. */
  76921. getAnimationRanges(): Nullable<AnimationRange>[];
  76922. /**
  76923. * Copy animation range from a source skeleton.
  76924. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  76925. * @param source defines the source skeleton
  76926. * @param name defines the name of the range to copy
  76927. * @param rescaleAsRequired defines if rescaling must be applied if required
  76928. * @returns true if operation was successful
  76929. */
  76930. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  76931. /**
  76932. * Forces the skeleton to go to rest pose
  76933. */
  76934. returnToRest(): void;
  76935. private _getHighestAnimationFrame;
  76936. /**
  76937. * Begin a specific animation range
  76938. * @param name defines the name of the range to start
  76939. * @param loop defines if looping must be turned on (false by default)
  76940. * @param speedRatio defines the speed ratio to apply (1 by default)
  76941. * @param onAnimationEnd defines a callback which will be called when animation will end
  76942. * @returns a new animatable
  76943. */
  76944. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  76945. /** @hidden */
  76946. _markAsDirty(): void;
  76947. /** @hidden */
  76948. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76949. /** @hidden */
  76950. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  76951. private _computeTransformMatrices;
  76952. /**
  76953. * Build all resources required to render a skeleton
  76954. */
  76955. prepare(): void;
  76956. /**
  76957. * Gets the list of animatables currently running for this skeleton
  76958. * @returns an array of animatables
  76959. */
  76960. getAnimatables(): IAnimatable[];
  76961. /**
  76962. * Clone the current skeleton
  76963. * @param name defines the name of the new skeleton
  76964. * @param id defines the id of the new skeleton
  76965. * @returns the new skeleton
  76966. */
  76967. clone(name: string, id: string): Skeleton;
  76968. /**
  76969. * Enable animation blending for this skeleton
  76970. * @param blendingSpeed defines the blending speed to apply
  76971. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  76972. */
  76973. enableBlending(blendingSpeed?: number): void;
  76974. /**
  76975. * Releases all resources associated with the current skeleton
  76976. */
  76977. dispose(): void;
  76978. /**
  76979. * Serialize the skeleton in a JSON object
  76980. * @returns a JSON object
  76981. */
  76982. serialize(): any;
  76983. /**
  76984. * Creates a new skeleton from serialized data
  76985. * @param parsedSkeleton defines the serialized data
  76986. * @param scene defines the hosting scene
  76987. * @returns a new skeleton
  76988. */
  76989. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  76990. /**
  76991. * Compute all node absolute transforms
  76992. * @param forceUpdate defines if computation must be done even if cache is up to date
  76993. */
  76994. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  76995. /**
  76996. * Gets the root pose matrix
  76997. * @returns a matrix
  76998. */
  76999. getPoseMatrix(): Nullable<Matrix>;
  77000. /**
  77001. * Sorts bones per internal index
  77002. */
  77003. sortBones(): void;
  77004. private _sortBones;
  77005. }
  77006. }
  77007. declare module BABYLON {
  77008. /**
  77009. * Class used to store bone information
  77010. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  77011. */
  77012. export class Bone extends Node {
  77013. /**
  77014. * defines the bone name
  77015. */
  77016. name: string;
  77017. private static _tmpVecs;
  77018. private static _tmpQuat;
  77019. private static _tmpMats;
  77020. /**
  77021. * Gets the list of child bones
  77022. */
  77023. children: Bone[];
  77024. /** Gets the animations associated with this bone */
  77025. animations: Animation[];
  77026. /**
  77027. * Gets or sets bone length
  77028. */
  77029. length: number;
  77030. /**
  77031. * @hidden Internal only
  77032. * Set this value to map this bone to a different index in the transform matrices
  77033. * Set this value to -1 to exclude the bone from the transform matrices
  77034. */
  77035. _index: Nullable<number>;
  77036. private _skeleton;
  77037. private _localMatrix;
  77038. private _restPose;
  77039. private _baseMatrix;
  77040. private _absoluteTransform;
  77041. private _invertedAbsoluteTransform;
  77042. private _parent;
  77043. private _scalingDeterminant;
  77044. private _worldTransform;
  77045. private _localScaling;
  77046. private _localRotation;
  77047. private _localPosition;
  77048. private _needToDecompose;
  77049. private _needToCompose;
  77050. /** @hidden */
  77051. _linkedTransformNode: Nullable<TransformNode>;
  77052. /** @hidden */
  77053. _waitingTransformNodeId: Nullable<string>;
  77054. /** @hidden */
  77055. /** @hidden */
  77056. _matrix: Matrix;
  77057. /**
  77058. * Create a new bone
  77059. * @param name defines the bone name
  77060. * @param skeleton defines the parent skeleton
  77061. * @param parentBone defines the parent (can be null if the bone is the root)
  77062. * @param localMatrix defines the local matrix
  77063. * @param restPose defines the rest pose matrix
  77064. * @param baseMatrix defines the base matrix
  77065. * @param index defines index of the bone in the hiearchy
  77066. */
  77067. constructor(
  77068. /**
  77069. * defines the bone name
  77070. */
  77071. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  77072. /**
  77073. * Gets the current object class name.
  77074. * @return the class name
  77075. */
  77076. getClassName(): string;
  77077. /**
  77078. * Gets the parent skeleton
  77079. * @returns a skeleton
  77080. */
  77081. getSkeleton(): Skeleton;
  77082. /**
  77083. * Gets parent bone
  77084. * @returns a bone or null if the bone is the root of the bone hierarchy
  77085. */
  77086. getParent(): Nullable<Bone>;
  77087. /**
  77088. * Returns an array containing the root bones
  77089. * @returns an array containing the root bones
  77090. */
  77091. getChildren(): Array<Bone>;
  77092. /**
  77093. * Sets the parent bone
  77094. * @param parent defines the parent (can be null if the bone is the root)
  77095. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77096. */
  77097. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  77098. /**
  77099. * Gets the local matrix
  77100. * @returns a matrix
  77101. */
  77102. getLocalMatrix(): Matrix;
  77103. /**
  77104. * Gets the base matrix (initial matrix which remains unchanged)
  77105. * @returns a matrix
  77106. */
  77107. getBaseMatrix(): Matrix;
  77108. /**
  77109. * Gets the rest pose matrix
  77110. * @returns a matrix
  77111. */
  77112. getRestPose(): Matrix;
  77113. /**
  77114. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  77115. */
  77116. getWorldMatrix(): Matrix;
  77117. /**
  77118. * Sets the local matrix to rest pose matrix
  77119. */
  77120. returnToRest(): void;
  77121. /**
  77122. * Gets the inverse of the absolute transform matrix.
  77123. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  77124. * @returns a matrix
  77125. */
  77126. getInvertedAbsoluteTransform(): Matrix;
  77127. /**
  77128. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  77129. * @returns a matrix
  77130. */
  77131. getAbsoluteTransform(): Matrix;
  77132. /**
  77133. * Links with the given transform node.
  77134. * The local matrix of this bone is copied from the transform node every frame.
  77135. * @param transformNode defines the transform node to link to
  77136. */
  77137. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  77138. /**
  77139. * Gets the node used to drive the bone's transformation
  77140. * @returns a transform node or null
  77141. */
  77142. getTransformNode(): Nullable<TransformNode>;
  77143. /** Gets or sets current position (in local space) */
  77144. position: Vector3;
  77145. /** Gets or sets current rotation (in local space) */
  77146. rotation: Vector3;
  77147. /** Gets or sets current rotation quaternion (in local space) */
  77148. rotationQuaternion: Quaternion;
  77149. /** Gets or sets current scaling (in local space) */
  77150. scaling: Vector3;
  77151. /**
  77152. * Gets the animation properties override
  77153. */
  77154. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  77155. private _decompose;
  77156. private _compose;
  77157. /**
  77158. * Update the base and local matrices
  77159. * @param matrix defines the new base or local matrix
  77160. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  77161. * @param updateLocalMatrix defines if the local matrix should be updated
  77162. */
  77163. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  77164. /** @hidden */
  77165. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  77166. /**
  77167. * Flag the bone as dirty (Forcing it to update everything)
  77168. */
  77169. markAsDirty(): void;
  77170. /** @hidden */
  77171. _markAsDirtyAndCompose(): void;
  77172. private _markAsDirtyAndDecompose;
  77173. /**
  77174. * Translate the bone in local or world space
  77175. * @param vec The amount to translate the bone
  77176. * @param space The space that the translation is in
  77177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77178. */
  77179. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77180. /**
  77181. * Set the postion of the bone in local or world space
  77182. * @param position The position to set the bone
  77183. * @param space The space that the position is in
  77184. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77185. */
  77186. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77187. /**
  77188. * Set the absolute position of the bone (world space)
  77189. * @param position The position to set the bone
  77190. * @param mesh The mesh that this bone is attached to
  77191. */
  77192. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  77193. /**
  77194. * Scale the bone on the x, y and z axes (in local space)
  77195. * @param x The amount to scale the bone on the x axis
  77196. * @param y The amount to scale the bone on the y axis
  77197. * @param z The amount to scale the bone on the z axis
  77198. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  77199. */
  77200. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  77201. /**
  77202. * Set the bone scaling in local space
  77203. * @param scale defines the scaling vector
  77204. */
  77205. setScale(scale: Vector3): void;
  77206. /**
  77207. * Gets the current scaling in local space
  77208. * @returns the current scaling vector
  77209. */
  77210. getScale(): Vector3;
  77211. /**
  77212. * Gets the current scaling in local space and stores it in a target vector
  77213. * @param result defines the target vector
  77214. */
  77215. getScaleToRef(result: Vector3): void;
  77216. /**
  77217. * Set the yaw, pitch, and roll of the bone in local or world space
  77218. * @param yaw The rotation of the bone on the y axis
  77219. * @param pitch The rotation of the bone on the x axis
  77220. * @param roll The rotation of the bone on the z axis
  77221. * @param space The space that the axes of rotation are in
  77222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77223. */
  77224. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  77225. /**
  77226. * Add a rotation to the bone on an axis in local or world space
  77227. * @param axis The axis to rotate the bone on
  77228. * @param amount The amount to rotate the bone
  77229. * @param space The space that the axis is in
  77230. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77231. */
  77232. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  77233. /**
  77234. * Set the rotation of the bone to a particular axis angle in local or world space
  77235. * @param axis The axis to rotate the bone on
  77236. * @param angle The angle that the bone should be rotated to
  77237. * @param space The space that the axis is in
  77238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77239. */
  77240. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  77241. /**
  77242. * Set the euler rotation of the bone in local of world space
  77243. * @param rotation The euler rotation that the bone should be set to
  77244. * @param space The space that the rotation is in
  77245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77246. */
  77247. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  77248. /**
  77249. * Set the quaternion rotation of the bone in local of world space
  77250. * @param quat The quaternion rotation that the bone should be set to
  77251. * @param space The space that the rotation is in
  77252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77253. */
  77254. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  77255. /**
  77256. * Set the rotation matrix of the bone in local of world space
  77257. * @param rotMat The rotation matrix that the bone should be set to
  77258. * @param space The space that the rotation is in
  77259. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77260. */
  77261. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  77262. private _rotateWithMatrix;
  77263. private _getNegativeRotationToRef;
  77264. /**
  77265. * Get the position of the bone in local or world space
  77266. * @param space The space that the returned position is in
  77267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77268. * @returns The position of the bone
  77269. */
  77270. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77271. /**
  77272. * Copy the position of the bone to a vector3 in local or world space
  77273. * @param space The space that the returned position is in
  77274. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77275. * @param result The vector3 to copy the position to
  77276. */
  77277. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  77278. /**
  77279. * Get the absolute position of the bone (world space)
  77280. * @param mesh The mesh that this bone is attached to
  77281. * @returns The absolute position of the bone
  77282. */
  77283. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  77284. /**
  77285. * Copy the absolute position of the bone (world space) to the result param
  77286. * @param mesh The mesh that this bone is attached to
  77287. * @param result The vector3 to copy the absolute position to
  77288. */
  77289. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  77290. /**
  77291. * Compute the absolute transforms of this bone and its children
  77292. */
  77293. computeAbsoluteTransforms(): void;
  77294. /**
  77295. * Get the world direction from an axis that is in the local space of the bone
  77296. * @param localAxis The local direction that is used to compute the world direction
  77297. * @param mesh The mesh that this bone is attached to
  77298. * @returns The world direction
  77299. */
  77300. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77301. /**
  77302. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  77303. * @param localAxis The local direction that is used to compute the world direction
  77304. * @param mesh The mesh that this bone is attached to
  77305. * @param result The vector3 that the world direction will be copied to
  77306. */
  77307. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77308. /**
  77309. * Get the euler rotation of the bone in local or world space
  77310. * @param space The space that the rotation should be in
  77311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77312. * @returns The euler rotation
  77313. */
  77314. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  77315. /**
  77316. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  77317. * @param space The space that the rotation should be in
  77318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77319. * @param result The vector3 that the rotation should be copied to
  77320. */
  77321. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77322. /**
  77323. * Get the quaternion rotation of the bone in either local or world space
  77324. * @param space The space that the rotation should be in
  77325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77326. * @returns The quaternion rotation
  77327. */
  77328. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  77329. /**
  77330. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  77331. * @param space The space that the rotation should be in
  77332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77333. * @param result The quaternion that the rotation should be copied to
  77334. */
  77335. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  77336. /**
  77337. * Get the rotation matrix of the bone in local or world space
  77338. * @param space The space that the rotation should be in
  77339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77340. * @returns The rotation matrix
  77341. */
  77342. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  77343. /**
  77344. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  77345. * @param space The space that the rotation should be in
  77346. * @param mesh The mesh that this bone is attached to. This is only used in world space
  77347. * @param result The quaternion that the rotation should be copied to
  77348. */
  77349. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  77350. /**
  77351. * Get the world position of a point that is in the local space of the bone
  77352. * @param position The local position
  77353. * @param mesh The mesh that this bone is attached to
  77354. * @returns The world position
  77355. */
  77356. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77357. /**
  77358. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  77359. * @param position The local position
  77360. * @param mesh The mesh that this bone is attached to
  77361. * @param result The vector3 that the world position should be copied to
  77362. */
  77363. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77364. /**
  77365. * Get the local position of a point that is in world space
  77366. * @param position The world position
  77367. * @param mesh The mesh that this bone is attached to
  77368. * @returns The local position
  77369. */
  77370. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  77371. /**
  77372. * Get the local position of a point that is in world space and copy it to the result param
  77373. * @param position The world position
  77374. * @param mesh The mesh that this bone is attached to
  77375. * @param result The vector3 that the local position should be copied to
  77376. */
  77377. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  77378. }
  77379. }
  77380. declare module BABYLON {
  77381. /**
  77382. * 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.
  77383. * @see https://doc.babylonjs.com/how_to/transformnode
  77384. */
  77385. export class TransformNode extends Node {
  77386. /**
  77387. * Object will not rotate to face the camera
  77388. */
  77389. static BILLBOARDMODE_NONE: number;
  77390. /**
  77391. * Object will rotate to face the camera but only on the x axis
  77392. */
  77393. static BILLBOARDMODE_X: number;
  77394. /**
  77395. * Object will rotate to face the camera but only on the y axis
  77396. */
  77397. static BILLBOARDMODE_Y: number;
  77398. /**
  77399. * Object will rotate to face the camera but only on the z axis
  77400. */
  77401. static BILLBOARDMODE_Z: number;
  77402. /**
  77403. * Object will rotate to face the camera
  77404. */
  77405. static BILLBOARDMODE_ALL: number;
  77406. private _forward;
  77407. private _forwardInverted;
  77408. private _up;
  77409. private _right;
  77410. private _rightInverted;
  77411. private _position;
  77412. private _rotation;
  77413. private _rotationQuaternion;
  77414. protected _scaling: Vector3;
  77415. protected _isDirty: boolean;
  77416. private _transformToBoneReferal;
  77417. private _billboardMode;
  77418. /**
  77419. * Gets or sets the billboard mode. Default is 0.
  77420. *
  77421. * | Value | Type | Description |
  77422. * | --- | --- | --- |
  77423. * | 0 | BILLBOARDMODE_NONE | |
  77424. * | 1 | BILLBOARDMODE_X | |
  77425. * | 2 | BILLBOARDMODE_Y | |
  77426. * | 4 | BILLBOARDMODE_Z | |
  77427. * | 7 | BILLBOARDMODE_ALL | |
  77428. *
  77429. */
  77430. billboardMode: number;
  77431. private _preserveParentRotationForBillboard;
  77432. /**
  77433. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  77434. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  77435. */
  77436. preserveParentRotationForBillboard: boolean;
  77437. /**
  77438. * 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
  77439. */
  77440. scalingDeterminant: number;
  77441. private _infiniteDistance;
  77442. /**
  77443. * Gets or sets the distance of the object to max, often used by skybox
  77444. */
  77445. infiniteDistance: boolean;
  77446. /**
  77447. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  77448. * By default the system will update normals to compensate
  77449. */
  77450. ignoreNonUniformScaling: boolean;
  77451. /**
  77452. * 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
  77453. */
  77454. reIntegrateRotationIntoRotationQuaternion: boolean;
  77455. /** @hidden */
  77456. _poseMatrix: Nullable<Matrix>;
  77457. /** @hidden */
  77458. _localMatrix: Matrix;
  77459. private _usePivotMatrix;
  77460. private _absolutePosition;
  77461. private _pivotMatrix;
  77462. private _pivotMatrixInverse;
  77463. protected _postMultiplyPivotMatrix: boolean;
  77464. protected _isWorldMatrixFrozen: boolean;
  77465. /** @hidden */
  77466. _indexInSceneTransformNodesArray: number;
  77467. /**
  77468. * An event triggered after the world matrix is updated
  77469. */
  77470. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  77471. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  77472. /**
  77473. * Gets a string identifying the name of the class
  77474. * @returns "TransformNode" string
  77475. */
  77476. getClassName(): string;
  77477. /**
  77478. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  77479. */
  77480. position: Vector3;
  77481. /**
  77482. * 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)).
  77483. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  77484. */
  77485. rotation: Vector3;
  77486. /**
  77487. * 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)).
  77488. */
  77489. scaling: Vector3;
  77490. /**
  77491. * 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).
  77492. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  77493. */
  77494. rotationQuaternion: Nullable<Quaternion>;
  77495. /**
  77496. * The forward direction of that transform in world space.
  77497. */
  77498. readonly forward: Vector3;
  77499. /**
  77500. * The up direction of that transform in world space.
  77501. */
  77502. readonly up: Vector3;
  77503. /**
  77504. * The right direction of that transform in world space.
  77505. */
  77506. readonly right: Vector3;
  77507. /**
  77508. * Copies the parameter passed Matrix into the mesh Pose matrix.
  77509. * @param matrix the matrix to copy the pose from
  77510. * @returns this TransformNode.
  77511. */
  77512. updatePoseMatrix(matrix: Matrix): TransformNode;
  77513. /**
  77514. * Returns the mesh Pose matrix.
  77515. * @returns the pose matrix
  77516. */
  77517. getPoseMatrix(): Matrix;
  77518. /** @hidden */
  77519. _isSynchronized(): boolean;
  77520. /** @hidden */
  77521. _initCache(): void;
  77522. /**
  77523. * Flag the transform node as dirty (Forcing it to update everything)
  77524. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  77525. * @returns this transform node
  77526. */
  77527. markAsDirty(property: string): TransformNode;
  77528. /**
  77529. * Returns the current mesh absolute position.
  77530. * Returns a Vector3.
  77531. */
  77532. readonly absolutePosition: Vector3;
  77533. /**
  77534. * Sets a new matrix to apply before all other transformation
  77535. * @param matrix defines the transform matrix
  77536. * @returns the current TransformNode
  77537. */
  77538. setPreTransformMatrix(matrix: Matrix): TransformNode;
  77539. /**
  77540. * Sets a new pivot matrix to the current node
  77541. * @param matrix defines the new pivot matrix to use
  77542. * @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
  77543. * @returns the current TransformNode
  77544. */
  77545. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  77546. /**
  77547. * Returns the mesh pivot matrix.
  77548. * Default : Identity.
  77549. * @returns the matrix
  77550. */
  77551. getPivotMatrix(): Matrix;
  77552. /**
  77553. * Prevents the World matrix to be computed any longer.
  77554. * @returns the TransformNode.
  77555. */
  77556. freezeWorldMatrix(): TransformNode;
  77557. /**
  77558. * Allows back the World matrix computation.
  77559. * @returns the TransformNode.
  77560. */
  77561. unfreezeWorldMatrix(): this;
  77562. /**
  77563. * True if the World matrix has been frozen.
  77564. */
  77565. readonly isWorldMatrixFrozen: boolean;
  77566. /**
  77567. * Retuns the mesh absolute position in the World.
  77568. * @returns a Vector3.
  77569. */
  77570. getAbsolutePosition(): Vector3;
  77571. /**
  77572. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  77573. * @param absolutePosition the absolute position to set
  77574. * @returns the TransformNode.
  77575. */
  77576. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  77577. /**
  77578. * Sets the mesh position in its local space.
  77579. * @param vector3 the position to set in localspace
  77580. * @returns the TransformNode.
  77581. */
  77582. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  77583. /**
  77584. * Returns the mesh position in the local space from the current World matrix values.
  77585. * @returns a new Vector3.
  77586. */
  77587. getPositionExpressedInLocalSpace(): Vector3;
  77588. /**
  77589. * Translates the mesh along the passed Vector3 in its local space.
  77590. * @param vector3 the distance to translate in localspace
  77591. * @returns the TransformNode.
  77592. */
  77593. locallyTranslate(vector3: Vector3): TransformNode;
  77594. private static _lookAtVectorCache;
  77595. /**
  77596. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  77597. * @param targetPoint the position (must be in same space as current mesh) to look at
  77598. * @param yawCor optional yaw (y-axis) correction in radians
  77599. * @param pitchCor optional pitch (x-axis) correction in radians
  77600. * @param rollCor optional roll (z-axis) correction in radians
  77601. * @param space the choosen space of the target
  77602. * @returns the TransformNode.
  77603. */
  77604. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  77605. /**
  77606. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77607. * This Vector3 is expressed in the World space.
  77608. * @param localAxis axis to rotate
  77609. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  77610. */
  77611. getDirection(localAxis: Vector3): Vector3;
  77612. /**
  77613. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  77614. * localAxis is expressed in the mesh local space.
  77615. * result is computed in the Wordl space from the mesh World matrix.
  77616. * @param localAxis axis to rotate
  77617. * @param result the resulting transformnode
  77618. * @returns this TransformNode.
  77619. */
  77620. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  77621. /**
  77622. * Sets this transform node rotation to the given local axis.
  77623. * @param localAxis the axis in local space
  77624. * @param yawCor optional yaw (y-axis) correction in radians
  77625. * @param pitchCor optional pitch (x-axis) correction in radians
  77626. * @param rollCor optional roll (z-axis) correction in radians
  77627. * @returns this TransformNode
  77628. */
  77629. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  77630. /**
  77631. * Sets a new pivot point to the current node
  77632. * @param point defines the new pivot point to use
  77633. * @param space defines if the point is in world or local space (local by default)
  77634. * @returns the current TransformNode
  77635. */
  77636. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  77637. /**
  77638. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  77639. * @returns the pivot point
  77640. */
  77641. getPivotPoint(): Vector3;
  77642. /**
  77643. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  77644. * @param result the vector3 to store the result
  77645. * @returns this TransformNode.
  77646. */
  77647. getPivotPointToRef(result: Vector3): TransformNode;
  77648. /**
  77649. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  77650. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  77651. */
  77652. getAbsolutePivotPoint(): Vector3;
  77653. /**
  77654. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  77655. * @param result vector3 to store the result
  77656. * @returns this TransformNode.
  77657. */
  77658. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  77659. /**
  77660. * Defines the passed node as the parent of the current node.
  77661. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  77662. * @see https://doc.babylonjs.com/how_to/parenting
  77663. * @param node the node ot set as the parent
  77664. * @returns this TransformNode.
  77665. */
  77666. setParent(node: Nullable<Node>): TransformNode;
  77667. private _nonUniformScaling;
  77668. /**
  77669. * True if the scaling property of this object is non uniform eg. (1,2,1)
  77670. */
  77671. readonly nonUniformScaling: boolean;
  77672. /** @hidden */
  77673. _updateNonUniformScalingState(value: boolean): boolean;
  77674. /**
  77675. * Attach the current TransformNode to another TransformNode associated with a bone
  77676. * @param bone Bone affecting the TransformNode
  77677. * @param affectedTransformNode TransformNode associated with the bone
  77678. * @returns this object
  77679. */
  77680. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  77681. /**
  77682. * Detach the transform node if its associated with a bone
  77683. * @returns this object
  77684. */
  77685. detachFromBone(): TransformNode;
  77686. private static _rotationAxisCache;
  77687. /**
  77688. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  77689. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77690. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77691. * The passed axis is also normalized.
  77692. * @param axis the axis to rotate around
  77693. * @param amount the amount to rotate in radians
  77694. * @param space Space to rotate in (Default: local)
  77695. * @returns the TransformNode.
  77696. */
  77697. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  77698. /**
  77699. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  77700. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  77701. * The passed axis is also normalized. .
  77702. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  77703. * @param point the point to rotate around
  77704. * @param axis the axis to rotate around
  77705. * @param amount the amount to rotate in radians
  77706. * @returns the TransformNode
  77707. */
  77708. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  77709. /**
  77710. * Translates the mesh along the axis vector for the passed distance in the given space.
  77711. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  77712. * @param axis the axis to translate in
  77713. * @param distance the distance to translate
  77714. * @param space Space to rotate in (Default: local)
  77715. * @returns the TransformNode.
  77716. */
  77717. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  77718. /**
  77719. * Adds a rotation step to the mesh current rotation.
  77720. * x, y, z are Euler angles expressed in radians.
  77721. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  77722. * This means this rotation is made in the mesh local space only.
  77723. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  77724. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  77725. * ```javascript
  77726. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  77727. * ```
  77728. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  77729. * 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.
  77730. * @param x Rotation to add
  77731. * @param y Rotation to add
  77732. * @param z Rotation to add
  77733. * @returns the TransformNode.
  77734. */
  77735. addRotation(x: number, y: number, z: number): TransformNode;
  77736. /**
  77737. * @hidden
  77738. */
  77739. protected _getEffectiveParent(): Nullable<Node>;
  77740. /**
  77741. * Computes the world matrix of the node
  77742. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  77743. * @returns the world matrix
  77744. */
  77745. computeWorldMatrix(force?: boolean): Matrix;
  77746. protected _afterComputeWorldMatrix(): void;
  77747. /**
  77748. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  77749. * @param func callback function to add
  77750. *
  77751. * @returns the TransformNode.
  77752. */
  77753. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77754. /**
  77755. * Removes a registered callback function.
  77756. * @param func callback function to remove
  77757. * @returns the TransformNode.
  77758. */
  77759. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  77760. /**
  77761. * Gets the position of the current mesh in camera space
  77762. * @param camera defines the camera to use
  77763. * @returns a position
  77764. */
  77765. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  77766. /**
  77767. * Returns the distance from the mesh to the active camera
  77768. * @param camera defines the camera to use
  77769. * @returns the distance
  77770. */
  77771. getDistanceToCamera(camera?: Nullable<Camera>): number;
  77772. /**
  77773. * Clone the current transform node
  77774. * @param name Name of the new clone
  77775. * @param newParent New parent for the clone
  77776. * @param doNotCloneChildren Do not clone children hierarchy
  77777. * @returns the new transform node
  77778. */
  77779. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  77780. /**
  77781. * Serializes the objects information.
  77782. * @param currentSerializationObject defines the object to serialize in
  77783. * @returns the serialized object
  77784. */
  77785. serialize(currentSerializationObject?: any): any;
  77786. /**
  77787. * Returns a new TransformNode object parsed from the source provided.
  77788. * @param parsedTransformNode is the source.
  77789. * @param scene the scne the object belongs to
  77790. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  77791. * @returns a new TransformNode object parsed from the source provided.
  77792. */
  77793. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  77794. /**
  77795. * Get all child-transformNodes of this node
  77796. * @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
  77797. * @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
  77798. * @returns an array of TransformNode
  77799. */
  77800. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  77801. /**
  77802. * Releases resources associated with this transform node.
  77803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77805. */
  77806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77807. /**
  77808. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  77809. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  77810. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  77811. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  77812. * @returns the current mesh
  77813. */
  77814. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  77815. }
  77816. }
  77817. declare module BABYLON {
  77818. /**
  77819. * Defines the types of pose enabled controllers that are supported
  77820. */
  77821. export enum PoseEnabledControllerType {
  77822. /**
  77823. * HTC Vive
  77824. */
  77825. VIVE = 0,
  77826. /**
  77827. * Oculus Rift
  77828. */
  77829. OCULUS = 1,
  77830. /**
  77831. * Windows mixed reality
  77832. */
  77833. WINDOWS = 2,
  77834. /**
  77835. * Samsung gear VR
  77836. */
  77837. GEAR_VR = 3,
  77838. /**
  77839. * Google Daydream
  77840. */
  77841. DAYDREAM = 4,
  77842. /**
  77843. * Generic
  77844. */
  77845. GENERIC = 5
  77846. }
  77847. /**
  77848. * Defines the MutableGamepadButton interface for the state of a gamepad button
  77849. */
  77850. export interface MutableGamepadButton {
  77851. /**
  77852. * Value of the button/trigger
  77853. */
  77854. value: number;
  77855. /**
  77856. * If the button/trigger is currently touched
  77857. */
  77858. touched: boolean;
  77859. /**
  77860. * If the button/trigger is currently pressed
  77861. */
  77862. pressed: boolean;
  77863. }
  77864. /**
  77865. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  77866. * @hidden
  77867. */
  77868. export interface ExtendedGamepadButton extends GamepadButton {
  77869. /**
  77870. * If the button/trigger is currently pressed
  77871. */
  77872. readonly pressed: boolean;
  77873. /**
  77874. * If the button/trigger is currently touched
  77875. */
  77876. readonly touched: boolean;
  77877. /**
  77878. * Value of the button/trigger
  77879. */
  77880. readonly value: number;
  77881. }
  77882. /** @hidden */
  77883. export interface _GamePadFactory {
  77884. /**
  77885. * Returns wether or not the current gamepad can be created for this type of controller.
  77886. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77887. * @returns true if it can be created, otherwise false
  77888. */
  77889. canCreate(gamepadInfo: any): boolean;
  77890. /**
  77891. * Creates a new instance of the Gamepad.
  77892. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  77893. * @returns the new gamepad instance
  77894. */
  77895. create(gamepadInfo: any): Gamepad;
  77896. }
  77897. /**
  77898. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77899. */
  77900. export class PoseEnabledControllerHelper {
  77901. /** @hidden */
  77902. static _ControllerFactories: _GamePadFactory[];
  77903. /** @hidden */
  77904. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  77905. /**
  77906. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  77907. * @param vrGamepad the gamepad to initialized
  77908. * @returns a vr controller of the type the gamepad identified as
  77909. */
  77910. static InitiateController(vrGamepad: any): Gamepad;
  77911. }
  77912. /**
  77913. * Defines the PoseEnabledController object that contains state of a vr capable controller
  77914. */
  77915. export class PoseEnabledController extends Gamepad implements PoseControlled {
  77916. /**
  77917. * If the controller is used in a webXR session
  77918. */
  77919. isXR: boolean;
  77920. private _deviceRoomPosition;
  77921. private _deviceRoomRotationQuaternion;
  77922. /**
  77923. * The device position in babylon space
  77924. */
  77925. devicePosition: Vector3;
  77926. /**
  77927. * The device rotation in babylon space
  77928. */
  77929. deviceRotationQuaternion: Quaternion;
  77930. /**
  77931. * The scale factor of the device in babylon space
  77932. */
  77933. deviceScaleFactor: number;
  77934. /**
  77935. * (Likely devicePosition should be used instead) The device position in its room space
  77936. */
  77937. position: Vector3;
  77938. /**
  77939. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  77940. */
  77941. rotationQuaternion: Quaternion;
  77942. /**
  77943. * The type of controller (Eg. Windows mixed reality)
  77944. */
  77945. controllerType: PoseEnabledControllerType;
  77946. protected _calculatedPosition: Vector3;
  77947. private _calculatedRotation;
  77948. /**
  77949. * The raw pose from the device
  77950. */
  77951. rawPose: DevicePose;
  77952. private _trackPosition;
  77953. private _maxRotationDistFromHeadset;
  77954. private _draggedRoomRotation;
  77955. /**
  77956. * @hidden
  77957. */
  77958. _disableTrackPosition(fixedPosition: Vector3): void;
  77959. /**
  77960. * Internal, the mesh attached to the controller
  77961. * @hidden
  77962. */
  77963. _mesh: Nullable<AbstractMesh>;
  77964. private _poseControlledCamera;
  77965. private _leftHandSystemQuaternion;
  77966. /**
  77967. * Internal, matrix used to convert room space to babylon space
  77968. * @hidden
  77969. */
  77970. _deviceToWorld: Matrix;
  77971. /**
  77972. * Node to be used when casting a ray from the controller
  77973. * @hidden
  77974. */
  77975. _pointingPoseNode: Nullable<TransformNode>;
  77976. /**
  77977. * Name of the child mesh that can be used to cast a ray from the controller
  77978. */
  77979. static readonly POINTING_POSE: string;
  77980. /**
  77981. * Creates a new PoseEnabledController from a gamepad
  77982. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  77983. */
  77984. constructor(browserGamepad: any);
  77985. private _workingMatrix;
  77986. /**
  77987. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  77988. */
  77989. update(): void;
  77990. /**
  77991. * Updates only the pose device and mesh without doing any button event checking
  77992. */
  77993. protected _updatePoseAndMesh(): void;
  77994. /**
  77995. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  77996. * @param poseData raw pose fromthe device
  77997. */
  77998. updateFromDevice(poseData: DevicePose): void;
  77999. /**
  78000. * @hidden
  78001. */
  78002. _meshAttachedObservable: Observable<AbstractMesh>;
  78003. /**
  78004. * Attaches a mesh to the controller
  78005. * @param mesh the mesh to be attached
  78006. */
  78007. attachToMesh(mesh: AbstractMesh): void;
  78008. /**
  78009. * Attaches the controllers mesh to a camera
  78010. * @param camera the camera the mesh should be attached to
  78011. */
  78012. attachToPoseControlledCamera(camera: TargetCamera): void;
  78013. /**
  78014. * Disposes of the controller
  78015. */
  78016. dispose(): void;
  78017. /**
  78018. * The mesh that is attached to the controller
  78019. */
  78020. readonly mesh: Nullable<AbstractMesh>;
  78021. /**
  78022. * Gets the ray of the controller in the direction the controller is pointing
  78023. * @param length the length the resulting ray should be
  78024. * @returns a ray in the direction the controller is pointing
  78025. */
  78026. getForwardRay(length?: number): Ray;
  78027. }
  78028. }
  78029. declare module BABYLON {
  78030. /**
  78031. * Defines the WebVRController object that represents controllers tracked in 3D space
  78032. */
  78033. export abstract class WebVRController extends PoseEnabledController {
  78034. /**
  78035. * Internal, the default controller model for the controller
  78036. */
  78037. protected _defaultModel: AbstractMesh;
  78038. /**
  78039. * Fired when the trigger state has changed
  78040. */
  78041. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  78042. /**
  78043. * Fired when the main button state has changed
  78044. */
  78045. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78046. /**
  78047. * Fired when the secondary button state has changed
  78048. */
  78049. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  78050. /**
  78051. * Fired when the pad state has changed
  78052. */
  78053. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  78054. /**
  78055. * Fired when controllers stick values have changed
  78056. */
  78057. onPadValuesChangedObservable: Observable<StickValues>;
  78058. /**
  78059. * Array of button availible on the controller
  78060. */
  78061. protected _buttons: Array<MutableGamepadButton>;
  78062. private _onButtonStateChange;
  78063. /**
  78064. * Fired when a controller button's state has changed
  78065. * @param callback the callback containing the button that was modified
  78066. */
  78067. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  78068. /**
  78069. * X and Y axis corresponding to the controllers joystick
  78070. */
  78071. pad: StickValues;
  78072. /**
  78073. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  78074. */
  78075. hand: string;
  78076. /**
  78077. * The default controller model for the controller
  78078. */
  78079. readonly defaultModel: AbstractMesh;
  78080. /**
  78081. * Creates a new WebVRController from a gamepad
  78082. * @param vrGamepad the gamepad that the WebVRController should be created from
  78083. */
  78084. constructor(vrGamepad: any);
  78085. /**
  78086. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  78087. */
  78088. update(): void;
  78089. /**
  78090. * Function to be called when a button is modified
  78091. */
  78092. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  78093. /**
  78094. * Loads a mesh and attaches it to the controller
  78095. * @param scene the scene the mesh should be added to
  78096. * @param meshLoaded callback for when the mesh has been loaded
  78097. */
  78098. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  78099. private _setButtonValue;
  78100. private _changes;
  78101. private _checkChanges;
  78102. /**
  78103. * Disposes of th webVRCOntroller
  78104. */
  78105. dispose(): void;
  78106. }
  78107. }
  78108. declare module BABYLON {
  78109. /**
  78110. * The HemisphericLight simulates the ambient environment light,
  78111. * so the passed direction is the light reflection direction, not the incoming direction.
  78112. */
  78113. export class HemisphericLight extends Light {
  78114. /**
  78115. * The groundColor is the light in the opposite direction to the one specified during creation.
  78116. * 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.
  78117. */
  78118. groundColor: Color3;
  78119. /**
  78120. * The light reflection direction, not the incoming direction.
  78121. */
  78122. direction: Vector3;
  78123. /**
  78124. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  78125. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  78126. * The HemisphericLight can't cast shadows.
  78127. * Documentation : https://doc.babylonjs.com/babylon101/lights
  78128. * @param name The friendly name of the light
  78129. * @param direction The direction of the light reflection
  78130. * @param scene The scene the light belongs to
  78131. */
  78132. constructor(name: string, direction: Vector3, scene: Scene);
  78133. protected _buildUniformLayout(): void;
  78134. /**
  78135. * Returns the string "HemisphericLight".
  78136. * @return The class name
  78137. */
  78138. getClassName(): string;
  78139. /**
  78140. * Sets the HemisphericLight direction towards the passed target (Vector3).
  78141. * Returns the updated direction.
  78142. * @param target The target the direction should point to
  78143. * @return The computed direction
  78144. */
  78145. setDirectionToTarget(target: Vector3): Vector3;
  78146. /**
  78147. * Returns the shadow generator associated to the light.
  78148. * @returns Always null for hemispheric lights because it does not support shadows.
  78149. */
  78150. getShadowGenerator(): Nullable<IShadowGenerator>;
  78151. /**
  78152. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  78153. * @param effect The effect to update
  78154. * @param lightIndex The index of the light in the effect to update
  78155. * @returns The hemispheric light
  78156. */
  78157. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  78158. /**
  78159. * Computes the world matrix of the node
  78160. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  78161. * @param useWasUpdatedFlag defines a reserved property
  78162. * @returns the world matrix
  78163. */
  78164. computeWorldMatrix(): Matrix;
  78165. /**
  78166. * Returns the integer 3.
  78167. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  78168. */
  78169. getTypeID(): number;
  78170. /**
  78171. * Prepares the list of defines specific to the light type.
  78172. * @param defines the list of defines
  78173. * @param lightIndex defines the index of the light for the effect
  78174. */
  78175. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  78176. }
  78177. }
  78178. declare module BABYLON {
  78179. /** @hidden */
  78180. export var vrMultiviewToSingleviewPixelShader: {
  78181. name: string;
  78182. shader: string;
  78183. };
  78184. }
  78185. declare module BABYLON {
  78186. /**
  78187. * Renders to multiple views with a single draw call
  78188. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  78189. */
  78190. export class MultiviewRenderTarget extends RenderTargetTexture {
  78191. /**
  78192. * Creates a multiview render target
  78193. * @param scene scene used with the render target
  78194. * @param size the size of the render target (used for each view)
  78195. */
  78196. constructor(scene: Scene, size?: number | {
  78197. width: number;
  78198. height: number;
  78199. } | {
  78200. ratio: number;
  78201. });
  78202. /**
  78203. * @hidden
  78204. * @param faceIndex the face index, if its a cube texture
  78205. */
  78206. _bindFrameBuffer(faceIndex?: number): void;
  78207. /**
  78208. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  78209. * @returns the view count
  78210. */
  78211. getViewCount(): number;
  78212. }
  78213. }
  78214. declare module BABYLON {
  78215. /**
  78216. * Reprasents a camera frustum
  78217. */
  78218. export class Frustum {
  78219. /**
  78220. * Gets the planes representing the frustum
  78221. * @param transform matrix to be applied to the returned planes
  78222. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  78223. */
  78224. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  78225. /**
  78226. * Gets the near frustum plane transformed by the transform matrix
  78227. * @param transform transformation matrix to be applied to the resulting frustum plane
  78228. * @param frustumPlane the resuling frustum plane
  78229. */
  78230. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78231. /**
  78232. * Gets the far frustum plane transformed by the transform matrix
  78233. * @param transform transformation matrix to be applied to the resulting frustum plane
  78234. * @param frustumPlane the resuling frustum plane
  78235. */
  78236. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78237. /**
  78238. * Gets the left frustum plane transformed by the transform matrix
  78239. * @param transform transformation matrix to be applied to the resulting frustum plane
  78240. * @param frustumPlane the resuling frustum plane
  78241. */
  78242. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78243. /**
  78244. * Gets the right frustum plane transformed by the transform matrix
  78245. * @param transform transformation matrix to be applied to the resulting frustum plane
  78246. * @param frustumPlane the resuling frustum plane
  78247. */
  78248. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78249. /**
  78250. * Gets the top frustum plane transformed by the transform matrix
  78251. * @param transform transformation matrix to be applied to the resulting frustum plane
  78252. * @param frustumPlane the resuling frustum plane
  78253. */
  78254. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78255. /**
  78256. * Gets the bottom frustum plane transformed by the transform matrix
  78257. * @param transform transformation matrix to be applied to the resulting frustum plane
  78258. * @param frustumPlane the resuling frustum plane
  78259. */
  78260. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  78261. /**
  78262. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  78263. * @param transform transformation matrix to be applied to the resulting frustum planes
  78264. * @param frustumPlanes the resuling frustum planes
  78265. */
  78266. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  78267. }
  78268. }
  78269. declare module BABYLON {
  78270. interface Engine {
  78271. /**
  78272. * Creates a new multiview render target
  78273. * @param width defines the width of the texture
  78274. * @param height defines the height of the texture
  78275. * @returns the created multiview texture
  78276. */
  78277. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  78278. /**
  78279. * Binds a multiview framebuffer to be drawn to
  78280. * @param multiviewTexture texture to bind
  78281. */
  78282. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  78283. }
  78284. interface Camera {
  78285. /**
  78286. * @hidden
  78287. * 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)
  78288. */
  78289. _useMultiviewToSingleView: boolean;
  78290. /**
  78291. * @hidden
  78292. * 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)
  78293. */
  78294. _multiviewTexture: Nullable<RenderTargetTexture>;
  78295. /**
  78296. * @hidden
  78297. * ensures the multiview texture of the camera exists and has the specified width/height
  78298. * @param width height to set on the multiview texture
  78299. * @param height width to set on the multiview texture
  78300. */
  78301. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  78302. }
  78303. interface Scene {
  78304. /** @hidden */
  78305. _transformMatrixR: Matrix;
  78306. /** @hidden */
  78307. _multiviewSceneUbo: Nullable<UniformBuffer>;
  78308. /** @hidden */
  78309. _createMultiviewUbo(): void;
  78310. /** @hidden */
  78311. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  78312. /** @hidden */
  78313. _renderMultiviewToSingleView(camera: Camera): void;
  78314. }
  78315. }
  78316. declare module BABYLON {
  78317. /**
  78318. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  78319. * This will not be used for webXR as it supports displaying texture arrays directly
  78320. */
  78321. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  78322. /**
  78323. * Initializes a VRMultiviewToSingleview
  78324. * @param name name of the post process
  78325. * @param camera camera to be applied to
  78326. * @param scaleFactor scaling factor to the size of the output texture
  78327. */
  78328. constructor(name: string, camera: Camera, scaleFactor: number);
  78329. }
  78330. }
  78331. declare module BABYLON {
  78332. interface Engine {
  78333. /** @hidden */
  78334. _vrDisplay: any;
  78335. /** @hidden */
  78336. _vrSupported: boolean;
  78337. /** @hidden */
  78338. _oldSize: Size;
  78339. /** @hidden */
  78340. _oldHardwareScaleFactor: number;
  78341. /** @hidden */
  78342. _vrExclusivePointerMode: boolean;
  78343. /** @hidden */
  78344. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  78345. /** @hidden */
  78346. _onVRDisplayPointerRestricted: () => void;
  78347. /** @hidden */
  78348. _onVRDisplayPointerUnrestricted: () => void;
  78349. /** @hidden */
  78350. _onVrDisplayConnect: Nullable<(display: any) => void>;
  78351. /** @hidden */
  78352. _onVrDisplayDisconnect: Nullable<() => void>;
  78353. /** @hidden */
  78354. _onVrDisplayPresentChange: Nullable<() => void>;
  78355. /**
  78356. * Observable signaled when VR display mode changes
  78357. */
  78358. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  78359. /**
  78360. * Observable signaled when VR request present is complete
  78361. */
  78362. onVRRequestPresentComplete: Observable<boolean>;
  78363. /**
  78364. * Observable signaled when VR request present starts
  78365. */
  78366. onVRRequestPresentStart: Observable<Engine>;
  78367. /**
  78368. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  78369. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  78370. */
  78371. isInVRExclusivePointerMode: boolean;
  78372. /**
  78373. * Gets a boolean indicating if a webVR device was detected
  78374. * @returns true if a webVR device was detected
  78375. */
  78376. isVRDevicePresent(): boolean;
  78377. /**
  78378. * Gets the current webVR device
  78379. * @returns the current webVR device (or null)
  78380. */
  78381. getVRDevice(): any;
  78382. /**
  78383. * Initializes a webVR display and starts listening to display change events
  78384. * The onVRDisplayChangedObservable will be notified upon these changes
  78385. * @returns A promise containing a VRDisplay and if vr is supported
  78386. */
  78387. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  78388. /** @hidden */
  78389. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  78390. /**
  78391. * Call this function to switch to webVR mode
  78392. * Will do nothing if webVR is not supported or if there is no webVR device
  78393. * @see http://doc.babylonjs.com/how_to/webvr_camera
  78394. */
  78395. enableVR(): void;
  78396. /** @hidden */
  78397. _onVRFullScreenTriggered(): void;
  78398. }
  78399. }
  78400. declare module BABYLON {
  78401. /**
  78402. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  78403. * IMPORTANT!! The data is right-hand data.
  78404. * @export
  78405. * @interface DevicePose
  78406. */
  78407. export interface DevicePose {
  78408. /**
  78409. * The position of the device, values in array are [x,y,z].
  78410. */
  78411. readonly position: Nullable<Float32Array>;
  78412. /**
  78413. * The linearVelocity of the device, values in array are [x,y,z].
  78414. */
  78415. readonly linearVelocity: Nullable<Float32Array>;
  78416. /**
  78417. * The linearAcceleration of the device, values in array are [x,y,z].
  78418. */
  78419. readonly linearAcceleration: Nullable<Float32Array>;
  78420. /**
  78421. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  78422. */
  78423. readonly orientation: Nullable<Float32Array>;
  78424. /**
  78425. * The angularVelocity of the device, values in array are [x,y,z].
  78426. */
  78427. readonly angularVelocity: Nullable<Float32Array>;
  78428. /**
  78429. * The angularAcceleration of the device, values in array are [x,y,z].
  78430. */
  78431. readonly angularAcceleration: Nullable<Float32Array>;
  78432. }
  78433. /**
  78434. * Interface representing a pose controlled object in Babylon.
  78435. * A pose controlled object has both regular pose values as well as pose values
  78436. * from an external device such as a VR head mounted display
  78437. */
  78438. export interface PoseControlled {
  78439. /**
  78440. * The position of the object in babylon space.
  78441. */
  78442. position: Vector3;
  78443. /**
  78444. * The rotation quaternion of the object in babylon space.
  78445. */
  78446. rotationQuaternion: Quaternion;
  78447. /**
  78448. * The position of the device in babylon space.
  78449. */
  78450. devicePosition?: Vector3;
  78451. /**
  78452. * The rotation quaternion of the device in babylon space.
  78453. */
  78454. deviceRotationQuaternion: Quaternion;
  78455. /**
  78456. * The raw pose coming from the device.
  78457. */
  78458. rawPose: Nullable<DevicePose>;
  78459. /**
  78460. * The scale of the device to be used when translating from device space to babylon space.
  78461. */
  78462. deviceScaleFactor: number;
  78463. /**
  78464. * Updates the poseControlled values based on the input device pose.
  78465. * @param poseData the pose data to update the object with
  78466. */
  78467. updateFromDevice(poseData: DevicePose): void;
  78468. }
  78469. /**
  78470. * Set of options to customize the webVRCamera
  78471. */
  78472. export interface WebVROptions {
  78473. /**
  78474. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  78475. */
  78476. trackPosition?: boolean;
  78477. /**
  78478. * Sets the scale of the vrDevice in babylon space. (default: 1)
  78479. */
  78480. positionScale?: number;
  78481. /**
  78482. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  78483. */
  78484. displayName?: string;
  78485. /**
  78486. * Should the native controller meshes be initialized. (default: true)
  78487. */
  78488. controllerMeshes?: boolean;
  78489. /**
  78490. * Creating a default HemiLight only on controllers. (default: true)
  78491. */
  78492. defaultLightingOnControllers?: boolean;
  78493. /**
  78494. * If you don't want to use the default VR button of the helper. (default: false)
  78495. */
  78496. useCustomVRButton?: boolean;
  78497. /**
  78498. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  78499. */
  78500. customVRButton?: HTMLButtonElement;
  78501. /**
  78502. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  78503. */
  78504. rayLength?: number;
  78505. /**
  78506. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  78507. */
  78508. defaultHeight?: number;
  78509. /**
  78510. * If multiview should be used if availible (default: false)
  78511. */
  78512. useMultiview?: boolean;
  78513. }
  78514. /**
  78515. * This represents a WebVR camera.
  78516. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  78517. * @example http://doc.babylonjs.com/how_to/webvr_camera
  78518. */
  78519. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  78520. private webVROptions;
  78521. /**
  78522. * @hidden
  78523. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  78524. */
  78525. _vrDevice: any;
  78526. /**
  78527. * The rawPose of the vrDevice.
  78528. */
  78529. rawPose: Nullable<DevicePose>;
  78530. private _onVREnabled;
  78531. private _specsVersion;
  78532. private _attached;
  78533. private _frameData;
  78534. protected _descendants: Array<Node>;
  78535. private _deviceRoomPosition;
  78536. /** @hidden */
  78537. _deviceRoomRotationQuaternion: Quaternion;
  78538. private _standingMatrix;
  78539. /**
  78540. * Represents device position in babylon space.
  78541. */
  78542. devicePosition: Vector3;
  78543. /**
  78544. * Represents device rotation in babylon space.
  78545. */
  78546. deviceRotationQuaternion: Quaternion;
  78547. /**
  78548. * The scale of the device to be used when translating from device space to babylon space.
  78549. */
  78550. deviceScaleFactor: number;
  78551. private _deviceToWorld;
  78552. private _worldToDevice;
  78553. /**
  78554. * References to the webVR controllers for the vrDevice.
  78555. */
  78556. controllers: Array<WebVRController>;
  78557. /**
  78558. * Emits an event when a controller is attached.
  78559. */
  78560. onControllersAttachedObservable: Observable<WebVRController[]>;
  78561. /**
  78562. * Emits an event when a controller's mesh has been loaded;
  78563. */
  78564. onControllerMeshLoadedObservable: Observable<WebVRController>;
  78565. /**
  78566. * Emits an event when the HMD's pose has been updated.
  78567. */
  78568. onPoseUpdatedFromDeviceObservable: Observable<any>;
  78569. private _poseSet;
  78570. /**
  78571. * If the rig cameras be used as parent instead of this camera.
  78572. */
  78573. rigParenting: boolean;
  78574. private _lightOnControllers;
  78575. private _defaultHeight?;
  78576. /**
  78577. * Instantiates a WebVRFreeCamera.
  78578. * @param name The name of the WebVRFreeCamera
  78579. * @param position The starting anchor position for the camera
  78580. * @param scene The scene the camera belongs to
  78581. * @param webVROptions a set of customizable options for the webVRCamera
  78582. */
  78583. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  78584. /**
  78585. * Gets the device distance from the ground in meters.
  78586. * @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.
  78587. */
  78588. deviceDistanceToRoomGround(): number;
  78589. /**
  78590. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78591. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  78592. */
  78593. useStandingMatrix(callback?: (bool: boolean) => void): void;
  78594. /**
  78595. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  78596. * @returns A promise with a boolean set to if the standing matrix is supported.
  78597. */
  78598. useStandingMatrixAsync(): Promise<boolean>;
  78599. /**
  78600. * Disposes the camera
  78601. */
  78602. dispose(): void;
  78603. /**
  78604. * Gets a vrController by name.
  78605. * @param name The name of the controller to retreive
  78606. * @returns the controller matching the name specified or null if not found
  78607. */
  78608. getControllerByName(name: string): Nullable<WebVRController>;
  78609. private _leftController;
  78610. /**
  78611. * The controller corresponding to the users left hand.
  78612. */
  78613. readonly leftController: Nullable<WebVRController>;
  78614. private _rightController;
  78615. /**
  78616. * The controller corresponding to the users right hand.
  78617. */
  78618. readonly rightController: Nullable<WebVRController>;
  78619. /**
  78620. * Casts a ray forward from the vrCamera's gaze.
  78621. * @param length Length of the ray (default: 100)
  78622. * @returns the ray corresponding to the gaze
  78623. */
  78624. getForwardRay(length?: number): Ray;
  78625. /**
  78626. * @hidden
  78627. * Updates the camera based on device's frame data
  78628. */
  78629. _checkInputs(): void;
  78630. /**
  78631. * Updates the poseControlled values based on the input device pose.
  78632. * @param poseData Pose coming from the device
  78633. */
  78634. updateFromDevice(poseData: DevicePose): void;
  78635. private _htmlElementAttached;
  78636. private _detachIfAttached;
  78637. /**
  78638. * WebVR's attach control will start broadcasting frames to the device.
  78639. * Note that in certain browsers (chrome for example) this function must be called
  78640. * within a user-interaction callback. Example:
  78641. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  78642. *
  78643. * @param element html element to attach the vrDevice to
  78644. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  78645. */
  78646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78647. /**
  78648. * Detaches the camera from the html element and disables VR
  78649. *
  78650. * @param element html element to detach from
  78651. */
  78652. detachControl(element: HTMLElement): void;
  78653. /**
  78654. * @returns the name of this class
  78655. */
  78656. getClassName(): string;
  78657. /**
  78658. * Calls resetPose on the vrDisplay
  78659. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  78660. */
  78661. resetToCurrentRotation(): void;
  78662. /**
  78663. * @hidden
  78664. * Updates the rig cameras (left and right eye)
  78665. */
  78666. _updateRigCameras(): void;
  78667. private _workingVector;
  78668. private _oneVector;
  78669. private _workingMatrix;
  78670. private updateCacheCalled;
  78671. private _correctPositionIfNotTrackPosition;
  78672. /**
  78673. * @hidden
  78674. * Updates the cached values of the camera
  78675. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  78676. */
  78677. _updateCache(ignoreParentClass?: boolean): void;
  78678. /**
  78679. * @hidden
  78680. * Get current device position in babylon world
  78681. */
  78682. _computeDevicePosition(): void;
  78683. /**
  78684. * Updates the current device position and rotation in the babylon world
  78685. */
  78686. update(): void;
  78687. /**
  78688. * @hidden
  78689. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  78690. * @returns an identity matrix
  78691. */
  78692. _getViewMatrix(): Matrix;
  78693. private _tmpMatrix;
  78694. /**
  78695. * This function is called by the two RIG cameras.
  78696. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  78697. * @hidden
  78698. */
  78699. _getWebVRViewMatrix(): Matrix;
  78700. /** @hidden */
  78701. _getWebVRProjectionMatrix(): Matrix;
  78702. private _onGamepadConnectedObserver;
  78703. private _onGamepadDisconnectedObserver;
  78704. private _updateCacheWhenTrackingDisabledObserver;
  78705. /**
  78706. * Initializes the controllers and their meshes
  78707. */
  78708. initControllers(): void;
  78709. }
  78710. }
  78711. declare module BABYLON {
  78712. /**
  78713. * Size options for a post process
  78714. */
  78715. export type PostProcessOptions = {
  78716. width: number;
  78717. height: number;
  78718. };
  78719. /**
  78720. * PostProcess can be used to apply a shader to a texture after it has been rendered
  78721. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  78722. */
  78723. export class PostProcess {
  78724. /** Name of the PostProcess. */
  78725. name: string;
  78726. /**
  78727. * Gets or sets the unique id of the post process
  78728. */
  78729. uniqueId: number;
  78730. /**
  78731. * Width of the texture to apply the post process on
  78732. */
  78733. width: number;
  78734. /**
  78735. * Height of the texture to apply the post process on
  78736. */
  78737. height: number;
  78738. /**
  78739. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  78740. * @hidden
  78741. */
  78742. _outputTexture: Nullable<InternalTexture>;
  78743. /**
  78744. * Sampling mode used by the shader
  78745. * See https://doc.babylonjs.com/classes/3.1/texture
  78746. */
  78747. renderTargetSamplingMode: number;
  78748. /**
  78749. * Clear color to use when screen clearing
  78750. */
  78751. clearColor: Color4;
  78752. /**
  78753. * If the buffer needs to be cleared before applying the post process. (default: true)
  78754. * Should be set to false if shader will overwrite all previous pixels.
  78755. */
  78756. autoClear: boolean;
  78757. /**
  78758. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  78759. */
  78760. alphaMode: number;
  78761. /**
  78762. * Sets the setAlphaBlendConstants of the babylon engine
  78763. */
  78764. alphaConstants: Color4;
  78765. /**
  78766. * Animations to be used for the post processing
  78767. */
  78768. animations: Animation[];
  78769. /**
  78770. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  78771. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  78772. */
  78773. enablePixelPerfectMode: boolean;
  78774. /**
  78775. * Force the postprocess to be applied without taking in account viewport
  78776. */
  78777. forceFullscreenViewport: boolean;
  78778. /**
  78779. * List of inspectable custom properties (used by the Inspector)
  78780. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78781. */
  78782. inspectableCustomProperties: IInspectable[];
  78783. /**
  78784. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  78785. *
  78786. * | Value | Type | Description |
  78787. * | ----- | ----------------------------------- | ----------- |
  78788. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  78789. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  78790. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  78791. *
  78792. */
  78793. scaleMode: number;
  78794. /**
  78795. * Force textures to be a power of two (default: false)
  78796. */
  78797. alwaysForcePOT: boolean;
  78798. private _samples;
  78799. /**
  78800. * Number of sample textures (default: 1)
  78801. */
  78802. samples: number;
  78803. /**
  78804. * Modify the scale of the post process to be the same as the viewport (default: false)
  78805. */
  78806. adaptScaleToCurrentViewport: boolean;
  78807. private _camera;
  78808. private _scene;
  78809. private _engine;
  78810. private _options;
  78811. private _reusable;
  78812. private _textureType;
  78813. /**
  78814. * Smart array of input and output textures for the post process.
  78815. * @hidden
  78816. */
  78817. _textures: SmartArray<InternalTexture>;
  78818. /**
  78819. * The index in _textures that corresponds to the output texture.
  78820. * @hidden
  78821. */
  78822. _currentRenderTextureInd: number;
  78823. private _effect;
  78824. private _samplers;
  78825. private _fragmentUrl;
  78826. private _vertexUrl;
  78827. private _parameters;
  78828. private _scaleRatio;
  78829. protected _indexParameters: any;
  78830. private _shareOutputWithPostProcess;
  78831. private _texelSize;
  78832. private _forcedOutputTexture;
  78833. /**
  78834. * Returns the fragment url or shader name used in the post process.
  78835. * @returns the fragment url or name in the shader store.
  78836. */
  78837. getEffectName(): string;
  78838. /**
  78839. * An event triggered when the postprocess is activated.
  78840. */
  78841. onActivateObservable: Observable<Camera>;
  78842. private _onActivateObserver;
  78843. /**
  78844. * A function that is added to the onActivateObservable
  78845. */
  78846. onActivate: Nullable<(camera: Camera) => void>;
  78847. /**
  78848. * An event triggered when the postprocess changes its size.
  78849. */
  78850. onSizeChangedObservable: Observable<PostProcess>;
  78851. private _onSizeChangedObserver;
  78852. /**
  78853. * A function that is added to the onSizeChangedObservable
  78854. */
  78855. onSizeChanged: (postProcess: PostProcess) => void;
  78856. /**
  78857. * An event triggered when the postprocess applies its effect.
  78858. */
  78859. onApplyObservable: Observable<Effect>;
  78860. private _onApplyObserver;
  78861. /**
  78862. * A function that is added to the onApplyObservable
  78863. */
  78864. onApply: (effect: Effect) => void;
  78865. /**
  78866. * An event triggered before rendering the postprocess
  78867. */
  78868. onBeforeRenderObservable: Observable<Effect>;
  78869. private _onBeforeRenderObserver;
  78870. /**
  78871. * A function that is added to the onBeforeRenderObservable
  78872. */
  78873. onBeforeRender: (effect: Effect) => void;
  78874. /**
  78875. * An event triggered after rendering the postprocess
  78876. */
  78877. onAfterRenderObservable: Observable<Effect>;
  78878. private _onAfterRenderObserver;
  78879. /**
  78880. * A function that is added to the onAfterRenderObservable
  78881. */
  78882. onAfterRender: (efect: Effect) => void;
  78883. /**
  78884. * 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
  78885. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  78886. */
  78887. inputTexture: InternalTexture;
  78888. /**
  78889. * Gets the camera which post process is applied to.
  78890. * @returns The camera the post process is applied to.
  78891. */
  78892. getCamera(): Camera;
  78893. /**
  78894. * Gets the texel size of the postprocess.
  78895. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  78896. */
  78897. readonly texelSize: Vector2;
  78898. /**
  78899. * Creates a new instance PostProcess
  78900. * @param name The name of the PostProcess.
  78901. * @param fragmentUrl The url of the fragment shader to be used.
  78902. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  78903. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  78904. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  78905. * @param camera The camera to apply the render pass to.
  78906. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  78907. * @param engine The engine which the post process will be applied. (default: current engine)
  78908. * @param reusable If the post process can be reused on the same frame. (default: false)
  78909. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  78910. * @param textureType Type of textures used when performing the post process. (default: 0)
  78911. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  78912. * @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
  78913. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  78914. */
  78915. constructor(
  78916. /** Name of the PostProcess. */
  78917. 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);
  78918. /**
  78919. * Gets a string idenfifying the name of the class
  78920. * @returns "PostProcess" string
  78921. */
  78922. getClassName(): string;
  78923. /**
  78924. * Gets the engine which this post process belongs to.
  78925. * @returns The engine the post process was enabled with.
  78926. */
  78927. getEngine(): Engine;
  78928. /**
  78929. * The effect that is created when initializing the post process.
  78930. * @returns The created effect corresponding the the postprocess.
  78931. */
  78932. getEffect(): Effect;
  78933. /**
  78934. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  78935. * @param postProcess The post process to share the output with.
  78936. * @returns This post process.
  78937. */
  78938. shareOutputWith(postProcess: PostProcess): PostProcess;
  78939. /**
  78940. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  78941. * This should be called if the post process that shares output with this post process is disabled/disposed.
  78942. */
  78943. useOwnOutput(): void;
  78944. /**
  78945. * Updates the effect with the current post process compile time values and recompiles the shader.
  78946. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  78947. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  78948. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  78949. * @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
  78950. * @param onCompiled Called when the shader has been compiled.
  78951. * @param onError Called if there is an error when compiling a shader.
  78952. */
  78953. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  78954. /**
  78955. * The post process is reusable if it can be used multiple times within one frame.
  78956. * @returns If the post process is reusable
  78957. */
  78958. isReusable(): boolean;
  78959. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  78960. markTextureDirty(): void;
  78961. /**
  78962. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  78963. * 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.
  78964. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  78965. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  78966. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  78967. * @returns The target texture that was bound to be written to.
  78968. */
  78969. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  78970. /**
  78971. * If the post process is supported.
  78972. */
  78973. readonly isSupported: boolean;
  78974. /**
  78975. * The aspect ratio of the output texture.
  78976. */
  78977. readonly aspectRatio: number;
  78978. /**
  78979. * Get a value indicating if the post-process is ready to be used
  78980. * @returns true if the post-process is ready (shader is compiled)
  78981. */
  78982. isReady(): boolean;
  78983. /**
  78984. * Binds all textures and uniforms to the shader, this will be run on every pass.
  78985. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  78986. */
  78987. apply(): Nullable<Effect>;
  78988. private _disposeTextures;
  78989. /**
  78990. * Disposes the post process.
  78991. * @param camera The camera to dispose the post process on.
  78992. */
  78993. dispose(camera?: Camera): void;
  78994. }
  78995. }
  78996. declare module BABYLON {
  78997. /** @hidden */
  78998. export var kernelBlurVaryingDeclaration: {
  78999. name: string;
  79000. shader: string;
  79001. };
  79002. }
  79003. declare module BABYLON {
  79004. /** @hidden */
  79005. export var kernelBlurFragment: {
  79006. name: string;
  79007. shader: string;
  79008. };
  79009. }
  79010. declare module BABYLON {
  79011. /** @hidden */
  79012. export var kernelBlurFragment2: {
  79013. name: string;
  79014. shader: string;
  79015. };
  79016. }
  79017. declare module BABYLON {
  79018. /** @hidden */
  79019. export var kernelBlurPixelShader: {
  79020. name: string;
  79021. shader: string;
  79022. };
  79023. }
  79024. declare module BABYLON {
  79025. /** @hidden */
  79026. export var kernelBlurVertex: {
  79027. name: string;
  79028. shader: string;
  79029. };
  79030. }
  79031. declare module BABYLON {
  79032. /** @hidden */
  79033. export var kernelBlurVertexShader: {
  79034. name: string;
  79035. shader: string;
  79036. };
  79037. }
  79038. declare module BABYLON {
  79039. /**
  79040. * The Blur Post Process which blurs an image based on a kernel and direction.
  79041. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  79042. */
  79043. export class BlurPostProcess extends PostProcess {
  79044. /** The direction in which to blur the image. */
  79045. direction: Vector2;
  79046. private blockCompilation;
  79047. protected _kernel: number;
  79048. protected _idealKernel: number;
  79049. protected _packedFloat: boolean;
  79050. private _staticDefines;
  79051. /**
  79052. * Sets the length in pixels of the blur sample region
  79053. */
  79054. /**
  79055. * Gets the length in pixels of the blur sample region
  79056. */
  79057. kernel: number;
  79058. /**
  79059. * Sets wether or not the blur needs to unpack/repack floats
  79060. */
  79061. /**
  79062. * Gets wether or not the blur is unpacking/repacking floats
  79063. */
  79064. packedFloat: boolean;
  79065. /**
  79066. * Creates a new instance BlurPostProcess
  79067. * @param name The name of the effect.
  79068. * @param direction The direction in which to blur the image.
  79069. * @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.
  79070. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  79071. * @param camera The camera to apply the render pass to.
  79072. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  79073. * @param engine The engine which the post process will be applied. (default: current engine)
  79074. * @param reusable If the post process can be reused on the same frame. (default: false)
  79075. * @param textureType Type of textures used when performing the post process. (default: 0)
  79076. * @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)
  79077. */
  79078. constructor(name: string,
  79079. /** The direction in which to blur the image. */
  79080. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  79081. /**
  79082. * Updates the effect with the current post process compile time values and recompiles the shader.
  79083. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  79084. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  79085. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  79086. * @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
  79087. * @param onCompiled Called when the shader has been compiled.
  79088. * @param onError Called if there is an error when compiling a shader.
  79089. */
  79090. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79091. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  79092. /**
  79093. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  79094. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  79095. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  79096. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  79097. * The gaps between physical kernels are compensated for in the weighting of the samples
  79098. * @param idealKernel Ideal blur kernel.
  79099. * @return Nearest best kernel.
  79100. */
  79101. protected _nearestBestKernel(idealKernel: number): number;
  79102. /**
  79103. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  79104. * @param x The point on the Gaussian distribution to sample.
  79105. * @return the value of the Gaussian function at x.
  79106. */
  79107. protected _gaussianWeight(x: number): number;
  79108. /**
  79109. * Generates a string that can be used as a floating point number in GLSL.
  79110. * @param x Value to print.
  79111. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  79112. * @return GLSL float string.
  79113. */
  79114. protected _glslFloat(x: number, decimalFigures?: number): string;
  79115. }
  79116. }
  79117. declare module BABYLON {
  79118. /**
  79119. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79120. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79121. * You can then easily use it as a reflectionTexture on a flat surface.
  79122. * In case the surface is not a plane, please consider relying on reflection probes.
  79123. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79124. */
  79125. export class MirrorTexture extends RenderTargetTexture {
  79126. private scene;
  79127. /**
  79128. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  79129. * 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.
  79130. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79131. */
  79132. mirrorPlane: Plane;
  79133. /**
  79134. * Define the blur ratio used to blur the reflection if needed.
  79135. */
  79136. blurRatio: number;
  79137. /**
  79138. * Define the adaptive blur kernel used to blur the reflection if needed.
  79139. * This will autocompute the closest best match for the `blurKernel`
  79140. */
  79141. adaptiveBlurKernel: number;
  79142. /**
  79143. * Define the blur kernel used to blur the reflection if needed.
  79144. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79145. */
  79146. blurKernel: number;
  79147. /**
  79148. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  79149. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79150. */
  79151. blurKernelX: number;
  79152. /**
  79153. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  79154. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  79155. */
  79156. blurKernelY: number;
  79157. private _autoComputeBlurKernel;
  79158. protected _onRatioRescale(): void;
  79159. private _updateGammaSpace;
  79160. private _imageProcessingConfigChangeObserver;
  79161. private _transformMatrix;
  79162. private _mirrorMatrix;
  79163. private _savedViewMatrix;
  79164. private _blurX;
  79165. private _blurY;
  79166. private _adaptiveBlurKernel;
  79167. private _blurKernelX;
  79168. private _blurKernelY;
  79169. private _blurRatio;
  79170. /**
  79171. * Instantiates a Mirror Texture.
  79172. * Mirror texture can be used to simulate the view from a mirror in a scene.
  79173. * It will dynamically be rendered every frame to adapt to the camera point of view.
  79174. * You can then easily use it as a reflectionTexture on a flat surface.
  79175. * In case the surface is not a plane, please consider relying on reflection probes.
  79176. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  79177. * @param name
  79178. * @param size
  79179. * @param scene
  79180. * @param generateMipMaps
  79181. * @param type
  79182. * @param samplingMode
  79183. * @param generateDepthBuffer
  79184. */
  79185. constructor(name: string, size: number | {
  79186. width: number;
  79187. height: number;
  79188. } | {
  79189. ratio: number;
  79190. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  79191. private _preparePostProcesses;
  79192. /**
  79193. * Clone the mirror texture.
  79194. * @returns the cloned texture
  79195. */
  79196. clone(): MirrorTexture;
  79197. /**
  79198. * Serialize the texture to a JSON representation you could use in Parse later on
  79199. * @returns the serialized JSON representation
  79200. */
  79201. serialize(): any;
  79202. /**
  79203. * Dispose the texture and release its associated resources.
  79204. */
  79205. dispose(): void;
  79206. }
  79207. }
  79208. declare module BABYLON {
  79209. /**
  79210. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79211. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79212. */
  79213. export class Texture extends BaseTexture {
  79214. /** @hidden */
  79215. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  79216. /** @hidden */
  79217. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  79218. /** @hidden */
  79219. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  79220. /** nearest is mag = nearest and min = nearest and mip = linear */
  79221. static readonly NEAREST_SAMPLINGMODE: number;
  79222. /** nearest is mag = nearest and min = nearest and mip = linear */
  79223. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  79224. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79225. static readonly BILINEAR_SAMPLINGMODE: number;
  79226. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79227. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  79228. /** Trilinear is mag = linear and min = linear and mip = linear */
  79229. static readonly TRILINEAR_SAMPLINGMODE: number;
  79230. /** Trilinear is mag = linear and min = linear and mip = linear */
  79231. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  79232. /** mag = nearest and min = nearest and mip = nearest */
  79233. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  79234. /** mag = nearest and min = linear and mip = nearest */
  79235. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  79236. /** mag = nearest and min = linear and mip = linear */
  79237. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  79238. /** mag = nearest and min = linear and mip = none */
  79239. static readonly NEAREST_LINEAR: number;
  79240. /** mag = nearest and min = nearest and mip = none */
  79241. static readonly NEAREST_NEAREST: number;
  79242. /** mag = linear and min = nearest and mip = nearest */
  79243. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  79244. /** mag = linear and min = nearest and mip = linear */
  79245. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  79246. /** mag = linear and min = linear and mip = none */
  79247. static readonly LINEAR_LINEAR: number;
  79248. /** mag = linear and min = nearest and mip = none */
  79249. static readonly LINEAR_NEAREST: number;
  79250. /** Explicit coordinates mode */
  79251. static readonly EXPLICIT_MODE: number;
  79252. /** Spherical coordinates mode */
  79253. static readonly SPHERICAL_MODE: number;
  79254. /** Planar coordinates mode */
  79255. static readonly PLANAR_MODE: number;
  79256. /** Cubic coordinates mode */
  79257. static readonly CUBIC_MODE: number;
  79258. /** Projection coordinates mode */
  79259. static readonly PROJECTION_MODE: number;
  79260. /** Inverse Cubic coordinates mode */
  79261. static readonly SKYBOX_MODE: number;
  79262. /** Inverse Cubic coordinates mode */
  79263. static readonly INVCUBIC_MODE: number;
  79264. /** Equirectangular coordinates mode */
  79265. static readonly EQUIRECTANGULAR_MODE: number;
  79266. /** Equirectangular Fixed coordinates mode */
  79267. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  79268. /** Equirectangular Fixed Mirrored coordinates mode */
  79269. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79270. /** Texture is not repeating outside of 0..1 UVs */
  79271. static readonly CLAMP_ADDRESSMODE: number;
  79272. /** Texture is repeating outside of 0..1 UVs */
  79273. static readonly WRAP_ADDRESSMODE: number;
  79274. /** Texture is repeating and mirrored */
  79275. static readonly MIRROR_ADDRESSMODE: number;
  79276. /**
  79277. * 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
  79278. */
  79279. static UseSerializedUrlIfAny: boolean;
  79280. /**
  79281. * Define the url of the texture.
  79282. */
  79283. url: Nullable<string>;
  79284. /**
  79285. * Define an offset on the texture to offset the u coordinates of the UVs
  79286. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79287. */
  79288. uOffset: number;
  79289. /**
  79290. * Define an offset on the texture to offset the v coordinates of the UVs
  79291. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  79292. */
  79293. vOffset: number;
  79294. /**
  79295. * Define an offset on the texture to scale the u coordinates of the UVs
  79296. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79297. */
  79298. uScale: number;
  79299. /**
  79300. * Define an offset on the texture to scale the v coordinates of the UVs
  79301. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  79302. */
  79303. vScale: number;
  79304. /**
  79305. * Define an offset on the texture to rotate around the u coordinates of the UVs
  79306. * @see http://doc.babylonjs.com/how_to/more_materials
  79307. */
  79308. uAng: number;
  79309. /**
  79310. * Define an offset on the texture to rotate around the v coordinates of the UVs
  79311. * @see http://doc.babylonjs.com/how_to/more_materials
  79312. */
  79313. vAng: number;
  79314. /**
  79315. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  79316. * @see http://doc.babylonjs.com/how_to/more_materials
  79317. */
  79318. wAng: number;
  79319. /**
  79320. * Defines the center of rotation (U)
  79321. */
  79322. uRotationCenter: number;
  79323. /**
  79324. * Defines the center of rotation (V)
  79325. */
  79326. vRotationCenter: number;
  79327. /**
  79328. * Defines the center of rotation (W)
  79329. */
  79330. wRotationCenter: number;
  79331. /**
  79332. * Are mip maps generated for this texture or not.
  79333. */
  79334. readonly noMipmap: boolean;
  79335. /**
  79336. * List of inspectable custom properties (used by the Inspector)
  79337. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79338. */
  79339. inspectableCustomProperties: Nullable<IInspectable[]>;
  79340. private _noMipmap;
  79341. /** @hidden */
  79342. _invertY: boolean;
  79343. private _rowGenerationMatrix;
  79344. private _cachedTextureMatrix;
  79345. private _projectionModeMatrix;
  79346. private _t0;
  79347. private _t1;
  79348. private _t2;
  79349. private _cachedUOffset;
  79350. private _cachedVOffset;
  79351. private _cachedUScale;
  79352. private _cachedVScale;
  79353. private _cachedUAng;
  79354. private _cachedVAng;
  79355. private _cachedWAng;
  79356. private _cachedProjectionMatrixId;
  79357. private _cachedCoordinatesMode;
  79358. /** @hidden */
  79359. protected _initialSamplingMode: number;
  79360. /** @hidden */
  79361. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  79362. private _deleteBuffer;
  79363. protected _format: Nullable<number>;
  79364. private _delayedOnLoad;
  79365. private _delayedOnError;
  79366. /**
  79367. * Observable triggered once the texture has been loaded.
  79368. */
  79369. onLoadObservable: Observable<Texture>;
  79370. protected _isBlocking: boolean;
  79371. /**
  79372. * Is the texture preventing material to render while loading.
  79373. * If false, a default texture will be used instead of the loading one during the preparation step.
  79374. */
  79375. isBlocking: boolean;
  79376. /**
  79377. * Get the current sampling mode associated with the texture.
  79378. */
  79379. readonly samplingMode: number;
  79380. /**
  79381. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  79382. */
  79383. readonly invertY: boolean;
  79384. /**
  79385. * Instantiates a new texture.
  79386. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  79387. * @see http://doc.babylonjs.com/babylon101/materials#texture
  79388. * @param url define the url of the picture to load as a texture
  79389. * @param scene define the scene or engine the texture will belong to
  79390. * @param noMipmap define if the texture will require mip maps or not
  79391. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79392. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79393. * @param onLoad define a callback triggered when the texture has been loaded
  79394. * @param onError define a callback triggered when an error occurred during the loading session
  79395. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79396. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79397. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79398. */
  79399. 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);
  79400. /**
  79401. * Update the url (and optional buffer) of this texture if url was null during construction.
  79402. * @param url the url of the texture
  79403. * @param buffer the buffer of the texture (defaults to null)
  79404. * @param onLoad callback called when the texture is loaded (defaults to null)
  79405. */
  79406. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  79407. /**
  79408. * Finish the loading sequence of a texture flagged as delayed load.
  79409. * @hidden
  79410. */
  79411. delayLoad(): void;
  79412. private _prepareRowForTextureGeneration;
  79413. /**
  79414. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  79415. * @returns the transform matrix of the texture.
  79416. */
  79417. getTextureMatrix(): Matrix;
  79418. /**
  79419. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  79420. * @returns The reflection texture transform
  79421. */
  79422. getReflectionTextureMatrix(): Matrix;
  79423. /**
  79424. * Clones the texture.
  79425. * @returns the cloned texture
  79426. */
  79427. clone(): Texture;
  79428. /**
  79429. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  79430. * @returns The JSON representation of the texture
  79431. */
  79432. serialize(): any;
  79433. /**
  79434. * Get the current class name of the texture useful for serialization or dynamic coding.
  79435. * @returns "Texture"
  79436. */
  79437. getClassName(): string;
  79438. /**
  79439. * Dispose the texture and release its associated resources.
  79440. */
  79441. dispose(): void;
  79442. /**
  79443. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  79444. * @param parsedTexture Define the JSON representation of the texture
  79445. * @param scene Define the scene the parsed texture should be instantiated in
  79446. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  79447. * @returns The parsed texture if successful
  79448. */
  79449. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  79450. /**
  79451. * Creates a texture from its base 64 representation.
  79452. * @param data Define the base64 payload without the data: prefix
  79453. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79454. * @param scene Define the scene the texture should belong to
  79455. * @param noMipmap Forces the texture to not create mip map information if true
  79456. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79457. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79458. * @param onLoad define a callback triggered when the texture has been loaded
  79459. * @param onError define a callback triggered when an error occurred during the loading session
  79460. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79461. * @returns the created texture
  79462. */
  79463. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  79464. /**
  79465. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  79466. * @param data Define the base64 payload without the data: prefix
  79467. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  79468. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  79469. * @param scene Define the scene the texture should belong to
  79470. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  79471. * @param noMipmap Forces the texture to not create mip map information if true
  79472. * @param invertY define if the texture needs to be inverted on the y axis during loading
  79473. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  79474. * @param onLoad define a callback triggered when the texture has been loaded
  79475. * @param onError define a callback triggered when an error occurred during the loading session
  79476. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  79477. * @returns the created texture
  79478. */
  79479. 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;
  79480. }
  79481. }
  79482. declare module BABYLON {
  79483. /**
  79484. * PostProcessManager is used to manage one or more post processes or post process pipelines
  79485. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  79486. */
  79487. export class PostProcessManager {
  79488. private _scene;
  79489. private _indexBuffer;
  79490. private _vertexBuffers;
  79491. /**
  79492. * Creates a new instance PostProcess
  79493. * @param scene The scene that the post process is associated with.
  79494. */
  79495. constructor(scene: Scene);
  79496. private _prepareBuffers;
  79497. private _buildIndexBuffer;
  79498. /**
  79499. * Rebuilds the vertex buffers of the manager.
  79500. * @hidden
  79501. */
  79502. _rebuild(): void;
  79503. /**
  79504. * Prepares a frame to be run through a post process.
  79505. * @param sourceTexture The input texture to the post procesess. (default: null)
  79506. * @param postProcesses An array of post processes to be run. (default: null)
  79507. * @returns True if the post processes were able to be run.
  79508. * @hidden
  79509. */
  79510. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  79511. /**
  79512. * Manually render a set of post processes to a texture.
  79513. * @param postProcesses An array of post processes to be run.
  79514. * @param targetTexture The target texture to render to.
  79515. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  79516. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  79517. * @param lodLevel defines which lod of the texture to render to
  79518. */
  79519. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  79520. /**
  79521. * Finalize the result of the output of the postprocesses.
  79522. * @param doNotPresent If true the result will not be displayed to the screen.
  79523. * @param targetTexture The target texture to render to.
  79524. * @param faceIndex The index of the face to bind the target texture to.
  79525. * @param postProcesses The array of post processes to render.
  79526. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  79527. * @hidden
  79528. */
  79529. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  79530. /**
  79531. * Disposes of the post process manager.
  79532. */
  79533. dispose(): void;
  79534. }
  79535. }
  79536. declare module BABYLON {
  79537. /** Interface used by value gradients (color, factor, ...) */
  79538. export interface IValueGradient {
  79539. /**
  79540. * Gets or sets the gradient value (between 0 and 1)
  79541. */
  79542. gradient: number;
  79543. }
  79544. /** Class used to store color4 gradient */
  79545. export class ColorGradient implements IValueGradient {
  79546. /**
  79547. * Gets or sets the gradient value (between 0 and 1)
  79548. */
  79549. gradient: number;
  79550. /**
  79551. * Gets or sets first associated color
  79552. */
  79553. color1: Color4;
  79554. /**
  79555. * Gets or sets second associated color
  79556. */
  79557. color2?: Color4;
  79558. /**
  79559. * Will get a color picked randomly between color1 and color2.
  79560. * If color2 is undefined then color1 will be used
  79561. * @param result defines the target Color4 to store the result in
  79562. */
  79563. getColorToRef(result: Color4): void;
  79564. }
  79565. /** Class used to store color 3 gradient */
  79566. export class Color3Gradient implements IValueGradient {
  79567. /**
  79568. * Gets or sets the gradient value (between 0 and 1)
  79569. */
  79570. gradient: number;
  79571. /**
  79572. * Gets or sets the associated color
  79573. */
  79574. color: Color3;
  79575. }
  79576. /** Class used to store factor gradient */
  79577. export class FactorGradient implements IValueGradient {
  79578. /**
  79579. * Gets or sets the gradient value (between 0 and 1)
  79580. */
  79581. gradient: number;
  79582. /**
  79583. * Gets or sets first associated factor
  79584. */
  79585. factor1: number;
  79586. /**
  79587. * Gets or sets second associated factor
  79588. */
  79589. factor2?: number;
  79590. /**
  79591. * Will get a number picked randomly between factor1 and factor2.
  79592. * If factor2 is undefined then factor1 will be used
  79593. * @returns the picked number
  79594. */
  79595. getFactor(): number;
  79596. }
  79597. /**
  79598. * Helper used to simplify some generic gradient tasks
  79599. */
  79600. export class GradientHelper {
  79601. /**
  79602. * Gets the current gradient from an array of IValueGradient
  79603. * @param ratio defines the current ratio to get
  79604. * @param gradients defines the array of IValueGradient
  79605. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  79606. */
  79607. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  79608. }
  79609. }
  79610. declare module BABYLON {
  79611. interface AbstractScene {
  79612. /**
  79613. * The list of procedural textures added to the scene
  79614. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79615. */
  79616. proceduralTextures: Array<ProceduralTexture>;
  79617. }
  79618. /**
  79619. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  79620. * in a given scene.
  79621. */
  79622. export class ProceduralTextureSceneComponent implements ISceneComponent {
  79623. /**
  79624. * The component name helpfull to identify the component in the list of scene components.
  79625. */
  79626. readonly name: string;
  79627. /**
  79628. * The scene the component belongs to.
  79629. */
  79630. scene: Scene;
  79631. /**
  79632. * Creates a new instance of the component for the given scene
  79633. * @param scene Defines the scene to register the component in
  79634. */
  79635. constructor(scene: Scene);
  79636. /**
  79637. * Registers the component in a given scene
  79638. */
  79639. register(): void;
  79640. /**
  79641. * Rebuilds the elements related to this component in case of
  79642. * context lost for instance.
  79643. */
  79644. rebuild(): void;
  79645. /**
  79646. * Disposes the component and the associated ressources.
  79647. */
  79648. dispose(): void;
  79649. private _beforeClear;
  79650. }
  79651. }
  79652. declare module BABYLON {
  79653. interface Engine {
  79654. /**
  79655. * Creates a new render target cube texture
  79656. * @param size defines the size of the texture
  79657. * @param options defines the options used to create the texture
  79658. * @returns a new render target cube texture stored in an InternalTexture
  79659. */
  79660. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  79661. }
  79662. }
  79663. declare module BABYLON {
  79664. /** @hidden */
  79665. export var proceduralVertexShader: {
  79666. name: string;
  79667. shader: string;
  79668. };
  79669. }
  79670. declare module BABYLON {
  79671. /**
  79672. * 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.
  79673. * This is the base class of any Procedural texture and contains most of the shareable code.
  79674. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79675. */
  79676. export class ProceduralTexture extends Texture {
  79677. isCube: boolean;
  79678. /**
  79679. * Define if the texture is enabled or not (disabled texture will not render)
  79680. */
  79681. isEnabled: boolean;
  79682. /**
  79683. * Define if the texture must be cleared before rendering (default is true)
  79684. */
  79685. autoClear: boolean;
  79686. /**
  79687. * Callback called when the texture is generated
  79688. */
  79689. onGenerated: () => void;
  79690. /**
  79691. * Event raised when the texture is generated
  79692. */
  79693. onGeneratedObservable: Observable<ProceduralTexture>;
  79694. /** @hidden */
  79695. _generateMipMaps: boolean;
  79696. /** @hidden **/
  79697. _effect: Effect;
  79698. /** @hidden */
  79699. _textures: {
  79700. [key: string]: Texture;
  79701. };
  79702. private _size;
  79703. private _currentRefreshId;
  79704. private _refreshRate;
  79705. private _vertexBuffers;
  79706. private _indexBuffer;
  79707. private _uniforms;
  79708. private _samplers;
  79709. private _fragment;
  79710. private _floats;
  79711. private _ints;
  79712. private _floatsArrays;
  79713. private _colors3;
  79714. private _colors4;
  79715. private _vectors2;
  79716. private _vectors3;
  79717. private _matrices;
  79718. private _fallbackTexture;
  79719. private _fallbackTextureUsed;
  79720. private _engine;
  79721. private _cachedDefines;
  79722. private _contentUpdateId;
  79723. private _contentData;
  79724. /**
  79725. * Instantiates a new procedural texture.
  79726. * 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.
  79727. * This is the base class of any Procedural texture and contains most of the shareable code.
  79728. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  79729. * @param name Define the name of the texture
  79730. * @param size Define the size of the texture to create
  79731. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  79732. * @param scene Define the scene the texture belongs to
  79733. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  79734. * @param generateMipMaps Define if the texture should creates mip maps or not
  79735. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  79736. */
  79737. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  79738. /**
  79739. * The effect that is created when initializing the post process.
  79740. * @returns The created effect corresponding the the postprocess.
  79741. */
  79742. getEffect(): Effect;
  79743. /**
  79744. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  79745. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  79746. */
  79747. getContent(): Nullable<ArrayBufferView>;
  79748. private _createIndexBuffer;
  79749. /** @hidden */
  79750. _rebuild(): void;
  79751. /**
  79752. * Resets the texture in order to recreate its associated resources.
  79753. * This can be called in case of context loss
  79754. */
  79755. reset(): void;
  79756. protected _getDefines(): string;
  79757. /**
  79758. * Is the texture ready to be used ? (rendered at least once)
  79759. * @returns true if ready, otherwise, false.
  79760. */
  79761. isReady(): boolean;
  79762. /**
  79763. * Resets the refresh counter of the texture and start bak from scratch.
  79764. * Could be useful to regenerate the texture if it is setup to render only once.
  79765. */
  79766. resetRefreshCounter(): void;
  79767. /**
  79768. * Set the fragment shader to use in order to render the texture.
  79769. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  79770. */
  79771. setFragment(fragment: any): void;
  79772. /**
  79773. * Define the refresh rate of the texture or the rendering frequency.
  79774. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79775. */
  79776. refreshRate: number;
  79777. /** @hidden */
  79778. _shouldRender(): boolean;
  79779. /**
  79780. * Get the size the texture is rendering at.
  79781. * @returns the size (texture is always squared)
  79782. */
  79783. getRenderSize(): number;
  79784. /**
  79785. * Resize the texture to new value.
  79786. * @param size Define the new size the texture should have
  79787. * @param generateMipMaps Define whether the new texture should create mip maps
  79788. */
  79789. resize(size: number, generateMipMaps: boolean): void;
  79790. private _checkUniform;
  79791. /**
  79792. * Set a texture in the shader program used to render.
  79793. * @param name Define the name of the uniform samplers as defined in the shader
  79794. * @param texture Define the texture to bind to this sampler
  79795. * @return the texture itself allowing "fluent" like uniform updates
  79796. */
  79797. setTexture(name: string, texture: Texture): ProceduralTexture;
  79798. /**
  79799. * Set a float in the shader.
  79800. * @param name Define the name of the uniform as defined in the shader
  79801. * @param value Define the value to give to the uniform
  79802. * @return the texture itself allowing "fluent" like uniform updates
  79803. */
  79804. setFloat(name: string, value: number): ProceduralTexture;
  79805. /**
  79806. * Set a int in the shader.
  79807. * @param name Define the name of the uniform as defined in the shader
  79808. * @param value Define the value to give to the uniform
  79809. * @return the texture itself allowing "fluent" like uniform updates
  79810. */
  79811. setInt(name: string, value: number): ProceduralTexture;
  79812. /**
  79813. * Set an array of floats in the shader.
  79814. * @param name Define the name of the uniform as defined in the shader
  79815. * @param value Define the value to give to the uniform
  79816. * @return the texture itself allowing "fluent" like uniform updates
  79817. */
  79818. setFloats(name: string, value: number[]): ProceduralTexture;
  79819. /**
  79820. * Set a vec3 in the shader from a Color3.
  79821. * @param name Define the name of the uniform as defined in the shader
  79822. * @param value Define the value to give to the uniform
  79823. * @return the texture itself allowing "fluent" like uniform updates
  79824. */
  79825. setColor3(name: string, value: Color3): ProceduralTexture;
  79826. /**
  79827. * Set a vec4 in the shader from a Color4.
  79828. * @param name Define the name of the uniform as defined in the shader
  79829. * @param value Define the value to give to the uniform
  79830. * @return the texture itself allowing "fluent" like uniform updates
  79831. */
  79832. setColor4(name: string, value: Color4): ProceduralTexture;
  79833. /**
  79834. * Set a vec2 in the shader from a Vector2.
  79835. * @param name Define the name of the uniform as defined in the shader
  79836. * @param value Define the value to give to the uniform
  79837. * @return the texture itself allowing "fluent" like uniform updates
  79838. */
  79839. setVector2(name: string, value: Vector2): ProceduralTexture;
  79840. /**
  79841. * Set a vec3 in the shader from a Vector3.
  79842. * @param name Define the name of the uniform as defined in the shader
  79843. * @param value Define the value to give to the uniform
  79844. * @return the texture itself allowing "fluent" like uniform updates
  79845. */
  79846. setVector3(name: string, value: Vector3): ProceduralTexture;
  79847. /**
  79848. * Set a mat4 in the shader from a MAtrix.
  79849. * @param name Define the name of the uniform as defined in the shader
  79850. * @param value Define the value to give to the uniform
  79851. * @return the texture itself allowing "fluent" like uniform updates
  79852. */
  79853. setMatrix(name: string, value: Matrix): ProceduralTexture;
  79854. /**
  79855. * Render the texture to its associated render target.
  79856. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  79857. */
  79858. render(useCameraPostProcess?: boolean): void;
  79859. /**
  79860. * Clone the texture.
  79861. * @returns the cloned texture
  79862. */
  79863. clone(): ProceduralTexture;
  79864. /**
  79865. * Dispose the texture and release its asoociated resources.
  79866. */
  79867. dispose(): void;
  79868. }
  79869. }
  79870. declare module BABYLON {
  79871. /**
  79872. * This represents the base class for particle system in Babylon.
  79873. * 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.
  79874. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  79875. * @example https://doc.babylonjs.com/babylon101/particles
  79876. */
  79877. export class BaseParticleSystem {
  79878. /**
  79879. * Source color is added to the destination color without alpha affecting the result
  79880. */
  79881. static BLENDMODE_ONEONE: number;
  79882. /**
  79883. * Blend current color and particle color using particle’s alpha
  79884. */
  79885. static BLENDMODE_STANDARD: number;
  79886. /**
  79887. * Add current color and particle color multiplied by particle’s alpha
  79888. */
  79889. static BLENDMODE_ADD: number;
  79890. /**
  79891. * Multiply current color with particle color
  79892. */
  79893. static BLENDMODE_MULTIPLY: number;
  79894. /**
  79895. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  79896. */
  79897. static BLENDMODE_MULTIPLYADD: number;
  79898. /**
  79899. * List of animations used by the particle system.
  79900. */
  79901. animations: Animation[];
  79902. /**
  79903. * The id of the Particle system.
  79904. */
  79905. id: string;
  79906. /**
  79907. * The friendly name of the Particle system.
  79908. */
  79909. name: string;
  79910. /**
  79911. * The rendering group used by the Particle system to chose when to render.
  79912. */
  79913. renderingGroupId: number;
  79914. /**
  79915. * The emitter represents the Mesh or position we are attaching the particle system to.
  79916. */
  79917. emitter: Nullable<AbstractMesh | Vector3>;
  79918. /**
  79919. * The maximum number of particles to emit per frame
  79920. */
  79921. emitRate: number;
  79922. /**
  79923. * If you want to launch only a few particles at once, that can be done, as well.
  79924. */
  79925. manualEmitCount: number;
  79926. /**
  79927. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  79928. */
  79929. updateSpeed: number;
  79930. /**
  79931. * The amount of time the particle system is running (depends of the overall update speed).
  79932. */
  79933. targetStopDuration: number;
  79934. /**
  79935. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  79936. */
  79937. disposeOnStop: boolean;
  79938. /**
  79939. * Minimum power of emitting particles.
  79940. */
  79941. minEmitPower: number;
  79942. /**
  79943. * Maximum power of emitting particles.
  79944. */
  79945. maxEmitPower: number;
  79946. /**
  79947. * Minimum life time of emitting particles.
  79948. */
  79949. minLifeTime: number;
  79950. /**
  79951. * Maximum life time of emitting particles.
  79952. */
  79953. maxLifeTime: number;
  79954. /**
  79955. * Minimum Size of emitting particles.
  79956. */
  79957. minSize: number;
  79958. /**
  79959. * Maximum Size of emitting particles.
  79960. */
  79961. maxSize: number;
  79962. /**
  79963. * Minimum scale of emitting particles on X axis.
  79964. */
  79965. minScaleX: number;
  79966. /**
  79967. * Maximum scale of emitting particles on X axis.
  79968. */
  79969. maxScaleX: number;
  79970. /**
  79971. * Minimum scale of emitting particles on Y axis.
  79972. */
  79973. minScaleY: number;
  79974. /**
  79975. * Maximum scale of emitting particles on Y axis.
  79976. */
  79977. maxScaleY: number;
  79978. /**
  79979. * Gets or sets the minimal initial rotation in radians.
  79980. */
  79981. minInitialRotation: number;
  79982. /**
  79983. * Gets or sets the maximal initial rotation in radians.
  79984. */
  79985. maxInitialRotation: number;
  79986. /**
  79987. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  79988. */
  79989. minAngularSpeed: number;
  79990. /**
  79991. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  79992. */
  79993. maxAngularSpeed: number;
  79994. /**
  79995. * The texture used to render each particle. (this can be a spritesheet)
  79996. */
  79997. particleTexture: Nullable<Texture>;
  79998. /**
  79999. * The layer mask we are rendering the particles through.
  80000. */
  80001. layerMask: number;
  80002. /**
  80003. * This can help using your own shader to render the particle system.
  80004. * The according effect will be created
  80005. */
  80006. customShader: any;
  80007. /**
  80008. * By default particle system starts as soon as they are created. This prevents the
  80009. * automatic start to happen and let you decide when to start emitting particles.
  80010. */
  80011. preventAutoStart: boolean;
  80012. private _noiseTexture;
  80013. /**
  80014. * Gets or sets a texture used to add random noise to particle positions
  80015. */
  80016. noiseTexture: Nullable<ProceduralTexture>;
  80017. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  80018. noiseStrength: Vector3;
  80019. /**
  80020. * Callback triggered when the particle animation is ending.
  80021. */
  80022. onAnimationEnd: Nullable<() => void>;
  80023. /**
  80024. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  80025. */
  80026. blendMode: number;
  80027. /**
  80028. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  80029. * to override the particles.
  80030. */
  80031. forceDepthWrite: boolean;
  80032. /** 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 */
  80033. preWarmCycles: number;
  80034. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  80035. preWarmStepOffset: number;
  80036. /**
  80037. * 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)
  80038. */
  80039. spriteCellChangeSpeed: number;
  80040. /**
  80041. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  80042. */
  80043. startSpriteCellID: number;
  80044. /**
  80045. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  80046. */
  80047. endSpriteCellID: number;
  80048. /**
  80049. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  80050. */
  80051. spriteCellWidth: number;
  80052. /**
  80053. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  80054. */
  80055. spriteCellHeight: number;
  80056. /**
  80057. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  80058. */
  80059. spriteRandomStartCell: boolean;
  80060. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  80061. translationPivot: Vector2;
  80062. /** @hidden */
  80063. protected _isAnimationSheetEnabled: boolean;
  80064. /**
  80065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  80066. */
  80067. beginAnimationOnStart: boolean;
  80068. /**
  80069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  80070. */
  80071. beginAnimationFrom: number;
  80072. /**
  80073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  80074. */
  80075. beginAnimationTo: number;
  80076. /**
  80077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  80078. */
  80079. beginAnimationLoop: boolean;
  80080. /**
  80081. * Gets or sets a world offset applied to all particles
  80082. */
  80083. worldOffset: Vector3;
  80084. /**
  80085. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  80086. */
  80087. isAnimationSheetEnabled: boolean;
  80088. /**
  80089. * Get hosting scene
  80090. * @returns the scene
  80091. */
  80092. getScene(): Scene;
  80093. /**
  80094. * You can use gravity if you want to give an orientation to your particles.
  80095. */
  80096. gravity: Vector3;
  80097. protected _colorGradients: Nullable<Array<ColorGradient>>;
  80098. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  80099. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  80100. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  80101. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  80102. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  80103. protected _dragGradients: Nullable<Array<FactorGradient>>;
  80104. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  80105. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  80106. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  80107. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  80108. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  80109. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  80110. /**
  80111. * Defines the delay in milliseconds before starting the system (0 by default)
  80112. */
  80113. startDelay: number;
  80114. /**
  80115. * Gets the current list of drag gradients.
  80116. * You must use addDragGradient and removeDragGradient to udpate this list
  80117. * @returns the list of drag gradients
  80118. */
  80119. getDragGradients(): Nullable<Array<FactorGradient>>;
  80120. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  80121. limitVelocityDamping: number;
  80122. /**
  80123. * Gets the current list of limit velocity gradients.
  80124. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  80125. * @returns the list of limit velocity gradients
  80126. */
  80127. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  80128. /**
  80129. * Gets the current list of color gradients.
  80130. * You must use addColorGradient and removeColorGradient to udpate this list
  80131. * @returns the list of color gradients
  80132. */
  80133. getColorGradients(): Nullable<Array<ColorGradient>>;
  80134. /**
  80135. * Gets the current list of size gradients.
  80136. * You must use addSizeGradient and removeSizeGradient to udpate this list
  80137. * @returns the list of size gradients
  80138. */
  80139. getSizeGradients(): Nullable<Array<FactorGradient>>;
  80140. /**
  80141. * Gets the current list of color remap gradients.
  80142. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  80143. * @returns the list of color remap gradients
  80144. */
  80145. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  80146. /**
  80147. * Gets the current list of alpha remap gradients.
  80148. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  80149. * @returns the list of alpha remap gradients
  80150. */
  80151. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  80152. /**
  80153. * Gets the current list of life time gradients.
  80154. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  80155. * @returns the list of life time gradients
  80156. */
  80157. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  80158. /**
  80159. * Gets the current list of angular speed gradients.
  80160. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  80161. * @returns the list of angular speed gradients
  80162. */
  80163. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  80164. /**
  80165. * Gets the current list of velocity gradients.
  80166. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  80167. * @returns the list of velocity gradients
  80168. */
  80169. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  80170. /**
  80171. * Gets the current list of start size gradients.
  80172. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  80173. * @returns the list of start size gradients
  80174. */
  80175. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  80176. /**
  80177. * Gets the current list of emit rate gradients.
  80178. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  80179. * @returns the list of emit rate gradients
  80180. */
  80181. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  80182. /**
  80183. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80184. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80185. */
  80186. direction1: Vector3;
  80187. /**
  80188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  80189. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80190. */
  80191. direction2: Vector3;
  80192. /**
  80193. * 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.
  80194. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80195. */
  80196. minEmitBox: Vector3;
  80197. /**
  80198. * 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.
  80199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  80200. */
  80201. maxEmitBox: Vector3;
  80202. /**
  80203. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80204. */
  80205. color1: Color4;
  80206. /**
  80207. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  80208. */
  80209. color2: Color4;
  80210. /**
  80211. * Color the particle will have at the end of its lifetime
  80212. */
  80213. colorDead: Color4;
  80214. /**
  80215. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  80216. */
  80217. textureMask: Color4;
  80218. /**
  80219. * The particle emitter type defines the emitter used by the particle system.
  80220. * It can be for example box, sphere, or cone...
  80221. */
  80222. particleEmitterType: IParticleEmitterType;
  80223. /** @hidden */
  80224. _isSubEmitter: boolean;
  80225. /**
  80226. * Gets or sets the billboard mode to use when isBillboardBased = true.
  80227. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  80228. */
  80229. billboardMode: number;
  80230. protected _isBillboardBased: boolean;
  80231. /**
  80232. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  80233. */
  80234. isBillboardBased: boolean;
  80235. /**
  80236. * The scene the particle system belongs to.
  80237. */
  80238. protected _scene: Scene;
  80239. /**
  80240. * Local cache of defines for image processing.
  80241. */
  80242. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  80243. /**
  80244. * Default configuration related to image processing available in the standard Material.
  80245. */
  80246. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  80247. /**
  80248. * Gets the image processing configuration used either in this material.
  80249. */
  80250. /**
  80251. * Sets the Default image processing configuration used either in the this material.
  80252. *
  80253. * If sets to null, the scene one is in use.
  80254. */
  80255. imageProcessingConfiguration: ImageProcessingConfiguration;
  80256. /**
  80257. * Attaches a new image processing configuration to the Standard Material.
  80258. * @param configuration
  80259. */
  80260. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  80261. /** @hidden */
  80262. protected _reset(): void;
  80263. /** @hidden */
  80264. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  80265. /**
  80266. * Instantiates a particle system.
  80267. * 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.
  80268. * @param name The name of the particle system
  80269. */
  80270. constructor(name: string);
  80271. /**
  80272. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  80273. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80274. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80275. * @returns the emitter
  80276. */
  80277. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  80278. /**
  80279. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  80280. * @param radius The radius of the hemisphere to emit from
  80281. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80282. * @returns the emitter
  80283. */
  80284. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  80285. /**
  80286. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  80287. * @param radius The radius of the sphere to emit from
  80288. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  80289. * @returns the emitter
  80290. */
  80291. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  80292. /**
  80293. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  80294. * @param radius The radius of the sphere to emit from
  80295. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  80296. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  80297. * @returns the emitter
  80298. */
  80299. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  80300. /**
  80301. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  80302. * @param radius The radius of the emission cylinder
  80303. * @param height The height of the emission cylinder
  80304. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  80305. * @param directionRandomizer How much to randomize the particle direction [0-1]
  80306. * @returns the emitter
  80307. */
  80308. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  80309. /**
  80310. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  80311. * @param radius The radius of the cylinder to emit from
  80312. * @param height The height of the emission cylinder
  80313. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  80314. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  80315. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  80316. * @returns the emitter
  80317. */
  80318. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  80319. /**
  80320. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  80321. * @param radius The radius of the cone to emit from
  80322. * @param angle The base angle of the cone
  80323. * @returns the emitter
  80324. */
  80325. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  80326. /**
  80327. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  80328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  80329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  80330. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80331. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  80332. * @returns the emitter
  80333. */
  80334. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  80335. }
  80336. }
  80337. declare module BABYLON {
  80338. /**
  80339. * Type of sub emitter
  80340. */
  80341. export enum SubEmitterType {
  80342. /**
  80343. * Attached to the particle over it's lifetime
  80344. */
  80345. ATTACHED = 0,
  80346. /**
  80347. * Created when the particle dies
  80348. */
  80349. END = 1
  80350. }
  80351. /**
  80352. * Sub emitter class used to emit particles from an existing particle
  80353. */
  80354. export class SubEmitter {
  80355. /**
  80356. * the particle system to be used by the sub emitter
  80357. */
  80358. particleSystem: ParticleSystem;
  80359. /**
  80360. * Type of the submitter (Default: END)
  80361. */
  80362. type: SubEmitterType;
  80363. /**
  80364. * 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)
  80365. * Note: This only is supported when using an emitter of type Mesh
  80366. */
  80367. inheritDirection: boolean;
  80368. /**
  80369. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  80370. */
  80371. inheritedVelocityAmount: number;
  80372. /**
  80373. * Creates a sub emitter
  80374. * @param particleSystem the particle system to be used by the sub emitter
  80375. */
  80376. constructor(
  80377. /**
  80378. * the particle system to be used by the sub emitter
  80379. */
  80380. particleSystem: ParticleSystem);
  80381. /**
  80382. * Clones the sub emitter
  80383. * @returns the cloned sub emitter
  80384. */
  80385. clone(): SubEmitter;
  80386. /**
  80387. * Serialize current object to a JSON object
  80388. * @returns the serialized object
  80389. */
  80390. serialize(): any;
  80391. /** @hidden */
  80392. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  80393. /**
  80394. * Creates a new SubEmitter from a serialized JSON version
  80395. * @param serializationObject defines the JSON object to read from
  80396. * @param scene defines the hosting scene
  80397. * @param rootUrl defines the rootUrl for data loading
  80398. * @returns a new SubEmitter
  80399. */
  80400. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  80401. /** Release associated resources */
  80402. dispose(): void;
  80403. }
  80404. }
  80405. declare module BABYLON {
  80406. /** @hidden */
  80407. export var clipPlaneFragmentDeclaration: {
  80408. name: string;
  80409. shader: string;
  80410. };
  80411. }
  80412. declare module BABYLON {
  80413. /** @hidden */
  80414. export var imageProcessingDeclaration: {
  80415. name: string;
  80416. shader: string;
  80417. };
  80418. }
  80419. declare module BABYLON {
  80420. /** @hidden */
  80421. export var imageProcessingFunctions: {
  80422. name: string;
  80423. shader: string;
  80424. };
  80425. }
  80426. declare module BABYLON {
  80427. /** @hidden */
  80428. export var clipPlaneFragment: {
  80429. name: string;
  80430. shader: string;
  80431. };
  80432. }
  80433. declare module BABYLON {
  80434. /** @hidden */
  80435. export var particlesPixelShader: {
  80436. name: string;
  80437. shader: string;
  80438. };
  80439. }
  80440. declare module BABYLON {
  80441. /** @hidden */
  80442. export var clipPlaneVertexDeclaration: {
  80443. name: string;
  80444. shader: string;
  80445. };
  80446. }
  80447. declare module BABYLON {
  80448. /** @hidden */
  80449. export var clipPlaneVertex: {
  80450. name: string;
  80451. shader: string;
  80452. };
  80453. }
  80454. declare module BABYLON {
  80455. /** @hidden */
  80456. export var particlesVertexShader: {
  80457. name: string;
  80458. shader: string;
  80459. };
  80460. }
  80461. declare module BABYLON {
  80462. /**
  80463. * This represents a particle system in Babylon.
  80464. * 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.
  80465. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  80466. * @example https://doc.babylonjs.com/babylon101/particles
  80467. */
  80468. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  80469. /**
  80470. * Billboard mode will only apply to Y axis
  80471. */
  80472. static readonly BILLBOARDMODE_Y: number;
  80473. /**
  80474. * Billboard mode will apply to all axes
  80475. */
  80476. static readonly BILLBOARDMODE_ALL: number;
  80477. /**
  80478. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  80479. */
  80480. static readonly BILLBOARDMODE_STRETCHED: number;
  80481. /**
  80482. * This function can be defined to provide custom update for active particles.
  80483. * This function will be called instead of regular update (age, position, color, etc.).
  80484. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  80485. */
  80486. updateFunction: (particles: Particle[]) => void;
  80487. private _emitterWorldMatrix;
  80488. /**
  80489. * This function can be defined to specify initial direction for every new particle.
  80490. * It by default use the emitterType defined function
  80491. */
  80492. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  80493. /**
  80494. * This function can be defined to specify initial position for every new particle.
  80495. * It by default use the emitterType defined function
  80496. */
  80497. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  80498. /**
  80499. * @hidden
  80500. */
  80501. _inheritedVelocityOffset: Vector3;
  80502. /**
  80503. * An event triggered when the system is disposed
  80504. */
  80505. onDisposeObservable: Observable<ParticleSystem>;
  80506. private _onDisposeObserver;
  80507. /**
  80508. * Sets a callback that will be triggered when the system is disposed
  80509. */
  80510. onDispose: () => void;
  80511. private _particles;
  80512. private _epsilon;
  80513. private _capacity;
  80514. private _stockParticles;
  80515. private _newPartsExcess;
  80516. private _vertexData;
  80517. private _vertexBuffer;
  80518. private _vertexBuffers;
  80519. private _spriteBuffer;
  80520. private _indexBuffer;
  80521. private _effect;
  80522. private _customEffect;
  80523. private _cachedDefines;
  80524. private _scaledColorStep;
  80525. private _colorDiff;
  80526. private _scaledDirection;
  80527. private _scaledGravity;
  80528. private _currentRenderId;
  80529. private _alive;
  80530. private _useInstancing;
  80531. private _started;
  80532. private _stopped;
  80533. private _actualFrame;
  80534. private _scaledUpdateSpeed;
  80535. private _vertexBufferSize;
  80536. /** @hidden */
  80537. _currentEmitRateGradient: Nullable<FactorGradient>;
  80538. /** @hidden */
  80539. _currentEmitRate1: number;
  80540. /** @hidden */
  80541. _currentEmitRate2: number;
  80542. /** @hidden */
  80543. _currentStartSizeGradient: Nullable<FactorGradient>;
  80544. /** @hidden */
  80545. _currentStartSize1: number;
  80546. /** @hidden */
  80547. _currentStartSize2: number;
  80548. private readonly _rawTextureWidth;
  80549. private _rampGradientsTexture;
  80550. private _useRampGradients;
  80551. /** Gets or sets a boolean indicating that ramp gradients must be used
  80552. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  80553. */
  80554. useRampGradients: boolean;
  80555. /**
  80556. * 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.
  80557. * 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: [])
  80558. */
  80559. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  80560. private _subEmitters;
  80561. /**
  80562. * @hidden
  80563. * If the particle systems emitter should be disposed when the particle system is disposed
  80564. */
  80565. _disposeEmitterOnDispose: boolean;
  80566. /**
  80567. * The current active Sub-systems, this property is used by the root particle system only.
  80568. */
  80569. activeSubSystems: Array<ParticleSystem>;
  80570. private _rootParticleSystem;
  80571. /**
  80572. * Gets the current list of active particles
  80573. */
  80574. readonly particles: Particle[];
  80575. /**
  80576. * Returns the string "ParticleSystem"
  80577. * @returns a string containing the class name
  80578. */
  80579. getClassName(): string;
  80580. /**
  80581. * Instantiates a particle system.
  80582. * 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.
  80583. * @param name The name of the particle system
  80584. * @param capacity The max number of particles alive at the same time
  80585. * @param scene The scene the particle system belongs to
  80586. * @param customEffect a custom effect used to change the way particles are rendered by default
  80587. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  80588. * @param epsilon Offset used to render the particles
  80589. */
  80590. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  80591. private _addFactorGradient;
  80592. private _removeFactorGradient;
  80593. /**
  80594. * Adds a new life time gradient
  80595. * @param gradient defines the gradient to use (between 0 and 1)
  80596. * @param factor defines the life time factor to affect to the specified gradient
  80597. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80598. * @returns the current particle system
  80599. */
  80600. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80601. /**
  80602. * Remove a specific life time gradient
  80603. * @param gradient defines the gradient to remove
  80604. * @returns the current particle system
  80605. */
  80606. removeLifeTimeGradient(gradient: number): IParticleSystem;
  80607. /**
  80608. * Adds a new size gradient
  80609. * @param gradient defines the gradient to use (between 0 and 1)
  80610. * @param factor defines the size factor to affect to the specified gradient
  80611. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80612. * @returns the current particle system
  80613. */
  80614. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80615. /**
  80616. * Remove a specific size gradient
  80617. * @param gradient defines the gradient to remove
  80618. * @returns the current particle system
  80619. */
  80620. removeSizeGradient(gradient: number): IParticleSystem;
  80621. /**
  80622. * Adds a new color remap gradient
  80623. * @param gradient defines the gradient to use (between 0 and 1)
  80624. * @param min defines the color remap minimal range
  80625. * @param max defines the color remap maximal range
  80626. * @returns the current particle system
  80627. */
  80628. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80629. /**
  80630. * Remove a specific color remap gradient
  80631. * @param gradient defines the gradient to remove
  80632. * @returns the current particle system
  80633. */
  80634. removeColorRemapGradient(gradient: number): IParticleSystem;
  80635. /**
  80636. * Adds a new alpha remap gradient
  80637. * @param gradient defines the gradient to use (between 0 and 1)
  80638. * @param min defines the alpha remap minimal range
  80639. * @param max defines the alpha remap maximal range
  80640. * @returns the current particle system
  80641. */
  80642. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  80643. /**
  80644. * Remove a specific alpha remap gradient
  80645. * @param gradient defines the gradient to remove
  80646. * @returns the current particle system
  80647. */
  80648. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  80649. /**
  80650. * Adds a new angular speed gradient
  80651. * @param gradient defines the gradient to use (between 0 and 1)
  80652. * @param factor defines the angular speed to affect to the specified gradient
  80653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80654. * @returns the current particle system
  80655. */
  80656. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80657. /**
  80658. * Remove a specific angular speed gradient
  80659. * @param gradient defines the gradient to remove
  80660. * @returns the current particle system
  80661. */
  80662. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  80663. /**
  80664. * Adds a new velocity gradient
  80665. * @param gradient defines the gradient to use (between 0 and 1)
  80666. * @param factor defines the velocity to affect to the specified gradient
  80667. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80668. * @returns the current particle system
  80669. */
  80670. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80671. /**
  80672. * Remove a specific velocity gradient
  80673. * @param gradient defines the gradient to remove
  80674. * @returns the current particle system
  80675. */
  80676. removeVelocityGradient(gradient: number): IParticleSystem;
  80677. /**
  80678. * Adds a new limit velocity gradient
  80679. * @param gradient defines the gradient to use (between 0 and 1)
  80680. * @param factor defines the limit velocity value to affect to the specified gradient
  80681. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80682. * @returns the current particle system
  80683. */
  80684. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80685. /**
  80686. * Remove a specific limit velocity gradient
  80687. * @param gradient defines the gradient to remove
  80688. * @returns the current particle system
  80689. */
  80690. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  80691. /**
  80692. * Adds a new drag gradient
  80693. * @param gradient defines the gradient to use (between 0 and 1)
  80694. * @param factor defines the drag value to affect to the specified gradient
  80695. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80696. * @returns the current particle system
  80697. */
  80698. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80699. /**
  80700. * Remove a specific drag gradient
  80701. * @param gradient defines the gradient to remove
  80702. * @returns the current particle system
  80703. */
  80704. removeDragGradient(gradient: number): IParticleSystem;
  80705. /**
  80706. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  80707. * @param gradient defines the gradient to use (between 0 and 1)
  80708. * @param factor defines the emit rate value to affect to the specified gradient
  80709. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80710. * @returns the current particle system
  80711. */
  80712. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80713. /**
  80714. * Remove a specific emit rate gradient
  80715. * @param gradient defines the gradient to remove
  80716. * @returns the current particle system
  80717. */
  80718. removeEmitRateGradient(gradient: number): IParticleSystem;
  80719. /**
  80720. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  80721. * @param gradient defines the gradient to use (between 0 and 1)
  80722. * @param factor defines the start size value to affect to the specified gradient
  80723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  80724. * @returns the current particle system
  80725. */
  80726. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  80727. /**
  80728. * Remove a specific start size gradient
  80729. * @param gradient defines the gradient to remove
  80730. * @returns the current particle system
  80731. */
  80732. removeStartSizeGradient(gradient: number): IParticleSystem;
  80733. private _createRampGradientTexture;
  80734. /**
  80735. * Gets the current list of ramp gradients.
  80736. * You must use addRampGradient and removeRampGradient to udpate this list
  80737. * @returns the list of ramp gradients
  80738. */
  80739. getRampGradients(): Nullable<Array<Color3Gradient>>;
  80740. /**
  80741. * Adds a new ramp gradient used to remap particle colors
  80742. * @param gradient defines the gradient to use (between 0 and 1)
  80743. * @param color defines the color to affect to the specified gradient
  80744. * @returns the current particle system
  80745. */
  80746. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  80747. /**
  80748. * Remove a specific ramp gradient
  80749. * @param gradient defines the gradient to remove
  80750. * @returns the current particle system
  80751. */
  80752. removeRampGradient(gradient: number): ParticleSystem;
  80753. /**
  80754. * Adds a new color gradient
  80755. * @param gradient defines the gradient to use (between 0 and 1)
  80756. * @param color1 defines the color to affect to the specified gradient
  80757. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  80758. * @returns this particle system
  80759. */
  80760. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  80761. /**
  80762. * Remove a specific color gradient
  80763. * @param gradient defines the gradient to remove
  80764. * @returns this particle system
  80765. */
  80766. removeColorGradient(gradient: number): IParticleSystem;
  80767. private _fetchR;
  80768. protected _reset(): void;
  80769. private _resetEffect;
  80770. private _createVertexBuffers;
  80771. private _createIndexBuffer;
  80772. /**
  80773. * Gets the maximum number of particles active at the same time.
  80774. * @returns The max number of active particles.
  80775. */
  80776. getCapacity(): number;
  80777. /**
  80778. * Gets whether there are still active particles in the system.
  80779. * @returns True if it is alive, otherwise false.
  80780. */
  80781. isAlive(): boolean;
  80782. /**
  80783. * Gets if the system has been started. (Note: this will still be true after stop is called)
  80784. * @returns True if it has been started, otherwise false.
  80785. */
  80786. isStarted(): boolean;
  80787. private _prepareSubEmitterInternalArray;
  80788. /**
  80789. * Starts the particle system and begins to emit
  80790. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  80791. */
  80792. start(delay?: number): void;
  80793. /**
  80794. * Stops the particle system.
  80795. * @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.
  80796. */
  80797. stop(stopSubEmitters?: boolean): void;
  80798. /**
  80799. * Remove all active particles
  80800. */
  80801. reset(): void;
  80802. /**
  80803. * @hidden (for internal use only)
  80804. */
  80805. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  80806. /**
  80807. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  80808. * Its lifetime will start back at 0.
  80809. */
  80810. recycleParticle: (particle: Particle) => void;
  80811. private _stopSubEmitters;
  80812. private _createParticle;
  80813. private _removeFromRoot;
  80814. private _emitFromParticle;
  80815. private _update;
  80816. /** @hidden */
  80817. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  80818. /** @hidden */
  80819. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  80820. /** @hidden */
  80821. private _getEffect;
  80822. /**
  80823. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  80824. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  80825. */
  80826. animate(preWarmOnly?: boolean): void;
  80827. private _appendParticleVertices;
  80828. /**
  80829. * Rebuilds the particle system.
  80830. */
  80831. rebuild(): void;
  80832. /**
  80833. * Is this system ready to be used/rendered
  80834. * @return true if the system is ready
  80835. */
  80836. isReady(): boolean;
  80837. private _render;
  80838. /**
  80839. * Renders the particle system in its current state.
  80840. * @returns the current number of particles
  80841. */
  80842. render(): number;
  80843. /**
  80844. * Disposes the particle system and free the associated resources
  80845. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  80846. */
  80847. dispose(disposeTexture?: boolean): void;
  80848. /**
  80849. * Clones the particle system.
  80850. * @param name The name of the cloned object
  80851. * @param newEmitter The new emitter to use
  80852. * @returns the cloned particle system
  80853. */
  80854. clone(name: string, newEmitter: any): ParticleSystem;
  80855. /**
  80856. * Serializes the particle system to a JSON object.
  80857. * @returns the JSON object
  80858. */
  80859. serialize(): any;
  80860. /** @hidden */
  80861. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  80862. /** @hidden */
  80863. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  80864. /**
  80865. * Parses a JSON object to create a particle system.
  80866. * @param parsedParticleSystem The JSON object to parse
  80867. * @param scene The scene to create the particle system in
  80868. * @param rootUrl The root url to use to load external dependencies like texture
  80869. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  80870. * @returns the Parsed particle system
  80871. */
  80872. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  80873. }
  80874. }
  80875. declare module BABYLON {
  80876. /**
  80877. * A particle represents one of the element emitted by a particle system.
  80878. * This is mainly define by its coordinates, direction, velocity and age.
  80879. */
  80880. export class Particle {
  80881. /**
  80882. * The particle system the particle belongs to.
  80883. */
  80884. particleSystem: ParticleSystem;
  80885. private static _Count;
  80886. /**
  80887. * Unique ID of the particle
  80888. */
  80889. id: number;
  80890. /**
  80891. * The world position of the particle in the scene.
  80892. */
  80893. position: Vector3;
  80894. /**
  80895. * The world direction of the particle in the scene.
  80896. */
  80897. direction: Vector3;
  80898. /**
  80899. * The color of the particle.
  80900. */
  80901. color: Color4;
  80902. /**
  80903. * The color change of the particle per step.
  80904. */
  80905. colorStep: Color4;
  80906. /**
  80907. * Defines how long will the life of the particle be.
  80908. */
  80909. lifeTime: number;
  80910. /**
  80911. * The current age of the particle.
  80912. */
  80913. age: number;
  80914. /**
  80915. * The current size of the particle.
  80916. */
  80917. size: number;
  80918. /**
  80919. * The current scale of the particle.
  80920. */
  80921. scale: Vector2;
  80922. /**
  80923. * The current angle of the particle.
  80924. */
  80925. angle: number;
  80926. /**
  80927. * Defines how fast is the angle changing.
  80928. */
  80929. angularSpeed: number;
  80930. /**
  80931. * Defines the cell index used by the particle to be rendered from a sprite.
  80932. */
  80933. cellIndex: number;
  80934. /**
  80935. * The information required to support color remapping
  80936. */
  80937. remapData: Vector4;
  80938. /** @hidden */
  80939. _randomCellOffset?: number;
  80940. /** @hidden */
  80941. _initialDirection: Nullable<Vector3>;
  80942. /** @hidden */
  80943. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  80944. /** @hidden */
  80945. _initialStartSpriteCellID: number;
  80946. /** @hidden */
  80947. _initialEndSpriteCellID: number;
  80948. /** @hidden */
  80949. _currentColorGradient: Nullable<ColorGradient>;
  80950. /** @hidden */
  80951. _currentColor1: Color4;
  80952. /** @hidden */
  80953. _currentColor2: Color4;
  80954. /** @hidden */
  80955. _currentSizeGradient: Nullable<FactorGradient>;
  80956. /** @hidden */
  80957. _currentSize1: number;
  80958. /** @hidden */
  80959. _currentSize2: number;
  80960. /** @hidden */
  80961. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  80962. /** @hidden */
  80963. _currentAngularSpeed1: number;
  80964. /** @hidden */
  80965. _currentAngularSpeed2: number;
  80966. /** @hidden */
  80967. _currentVelocityGradient: Nullable<FactorGradient>;
  80968. /** @hidden */
  80969. _currentVelocity1: number;
  80970. /** @hidden */
  80971. _currentVelocity2: number;
  80972. /** @hidden */
  80973. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  80974. /** @hidden */
  80975. _currentLimitVelocity1: number;
  80976. /** @hidden */
  80977. _currentLimitVelocity2: number;
  80978. /** @hidden */
  80979. _currentDragGradient: Nullable<FactorGradient>;
  80980. /** @hidden */
  80981. _currentDrag1: number;
  80982. /** @hidden */
  80983. _currentDrag2: number;
  80984. /** @hidden */
  80985. _randomNoiseCoordinates1: Vector3;
  80986. /** @hidden */
  80987. _randomNoiseCoordinates2: Vector3;
  80988. /**
  80989. * Creates a new instance Particle
  80990. * @param particleSystem the particle system the particle belongs to
  80991. */
  80992. constructor(
  80993. /**
  80994. * The particle system the particle belongs to.
  80995. */
  80996. particleSystem: ParticleSystem);
  80997. private updateCellInfoFromSystem;
  80998. /**
  80999. * Defines how the sprite cell index is updated for the particle
  81000. */
  81001. updateCellIndex(): void;
  81002. /** @hidden */
  81003. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  81004. /** @hidden */
  81005. _inheritParticleInfoToSubEmitters(): void;
  81006. /** @hidden */
  81007. _reset(): void;
  81008. /**
  81009. * Copy the properties of particle to another one.
  81010. * @param other the particle to copy the information to.
  81011. */
  81012. copyTo(other: Particle): void;
  81013. }
  81014. }
  81015. declare module BABYLON {
  81016. /**
  81017. * Particle emitter represents a volume emitting particles.
  81018. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  81019. */
  81020. export interface IParticleEmitterType {
  81021. /**
  81022. * Called by the particle System when the direction is computed for the created particle.
  81023. * @param worldMatrix is the world matrix of the particle system
  81024. * @param directionToUpdate is the direction vector to update with the result
  81025. * @param particle is the particle we are computed the direction for
  81026. */
  81027. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81028. /**
  81029. * Called by the particle System when the position is computed for the created particle.
  81030. * @param worldMatrix is the world matrix of the particle system
  81031. * @param positionToUpdate is the position vector to update with the result
  81032. * @param particle is the particle we are computed the position for
  81033. */
  81034. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81035. /**
  81036. * Clones the current emitter and returns a copy of it
  81037. * @returns the new emitter
  81038. */
  81039. clone(): IParticleEmitterType;
  81040. /**
  81041. * Called by the GPUParticleSystem to setup the update shader
  81042. * @param effect defines the update shader
  81043. */
  81044. applyToShader(effect: Effect): void;
  81045. /**
  81046. * Returns a string to use to update the GPU particles update shader
  81047. * @returns the effect defines string
  81048. */
  81049. getEffectDefines(): string;
  81050. /**
  81051. * Returns a string representing the class name
  81052. * @returns a string containing the class name
  81053. */
  81054. getClassName(): string;
  81055. /**
  81056. * Serializes the particle system to a JSON object.
  81057. * @returns the JSON object
  81058. */
  81059. serialize(): any;
  81060. /**
  81061. * Parse properties from a JSON object
  81062. * @param serializationObject defines the JSON object
  81063. */
  81064. parse(serializationObject: any): void;
  81065. }
  81066. }
  81067. declare module BABYLON {
  81068. /**
  81069. * Particle emitter emitting particles from the inside of a box.
  81070. * It emits the particles randomly between 2 given directions.
  81071. */
  81072. export class BoxParticleEmitter implements IParticleEmitterType {
  81073. /**
  81074. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81075. */
  81076. direction1: Vector3;
  81077. /**
  81078. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81079. */
  81080. direction2: Vector3;
  81081. /**
  81082. * 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.
  81083. */
  81084. minEmitBox: Vector3;
  81085. /**
  81086. * 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.
  81087. */
  81088. maxEmitBox: Vector3;
  81089. /**
  81090. * Creates a new instance BoxParticleEmitter
  81091. */
  81092. constructor();
  81093. /**
  81094. * Called by the particle System when the direction is computed for the created particle.
  81095. * @param worldMatrix is the world matrix of the particle system
  81096. * @param directionToUpdate is the direction vector to update with the result
  81097. * @param particle is the particle we are computed the direction for
  81098. */
  81099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81100. /**
  81101. * Called by the particle System when the position is computed for the created particle.
  81102. * @param worldMatrix is the world matrix of the particle system
  81103. * @param positionToUpdate is the position vector to update with the result
  81104. * @param particle is the particle we are computed the position for
  81105. */
  81106. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81107. /**
  81108. * Clones the current emitter and returns a copy of it
  81109. * @returns the new emitter
  81110. */
  81111. clone(): BoxParticleEmitter;
  81112. /**
  81113. * Called by the GPUParticleSystem to setup the update shader
  81114. * @param effect defines the update shader
  81115. */
  81116. applyToShader(effect: Effect): void;
  81117. /**
  81118. * Returns a string to use to update the GPU particles update shader
  81119. * @returns a string containng the defines string
  81120. */
  81121. getEffectDefines(): string;
  81122. /**
  81123. * Returns the string "BoxParticleEmitter"
  81124. * @returns a string containing the class name
  81125. */
  81126. getClassName(): string;
  81127. /**
  81128. * Serializes the particle system to a JSON object.
  81129. * @returns the JSON object
  81130. */
  81131. serialize(): any;
  81132. /**
  81133. * Parse properties from a JSON object
  81134. * @param serializationObject defines the JSON object
  81135. */
  81136. parse(serializationObject: any): void;
  81137. }
  81138. }
  81139. declare module BABYLON {
  81140. /**
  81141. * Particle emitter emitting particles from the inside of a cone.
  81142. * It emits the particles alongside the cone volume from the base to the particle.
  81143. * The emission direction might be randomized.
  81144. */
  81145. export class ConeParticleEmitter implements IParticleEmitterType {
  81146. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81147. directionRandomizer: number;
  81148. private _radius;
  81149. private _angle;
  81150. private _height;
  81151. /**
  81152. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  81153. */
  81154. radiusRange: number;
  81155. /**
  81156. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  81157. */
  81158. heightRange: number;
  81159. /**
  81160. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  81161. */
  81162. emitFromSpawnPointOnly: boolean;
  81163. /**
  81164. * Gets or sets the radius of the emission cone
  81165. */
  81166. radius: number;
  81167. /**
  81168. * Gets or sets the angle of the emission cone
  81169. */
  81170. angle: number;
  81171. private _buildHeight;
  81172. /**
  81173. * Creates a new instance ConeParticleEmitter
  81174. * @param radius the radius of the emission cone (1 by default)
  81175. * @param angle the cone base angle (PI by default)
  81176. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  81177. */
  81178. constructor(radius?: number, angle?: number,
  81179. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  81180. directionRandomizer?: number);
  81181. /**
  81182. * Called by the particle System when the direction is computed for the created particle.
  81183. * @param worldMatrix is the world matrix of the particle system
  81184. * @param directionToUpdate is the direction vector to update with the result
  81185. * @param particle is the particle we are computed the direction for
  81186. */
  81187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81188. /**
  81189. * Called by the particle System when the position is computed for the created particle.
  81190. * @param worldMatrix is the world matrix of the particle system
  81191. * @param positionToUpdate is the position vector to update with the result
  81192. * @param particle is the particle we are computed the position for
  81193. */
  81194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81195. /**
  81196. * Clones the current emitter and returns a copy of it
  81197. * @returns the new emitter
  81198. */
  81199. clone(): ConeParticleEmitter;
  81200. /**
  81201. * Called by the GPUParticleSystem to setup the update shader
  81202. * @param effect defines the update shader
  81203. */
  81204. applyToShader(effect: Effect): void;
  81205. /**
  81206. * Returns a string to use to update the GPU particles update shader
  81207. * @returns a string containng the defines string
  81208. */
  81209. getEffectDefines(): string;
  81210. /**
  81211. * Returns the string "ConeParticleEmitter"
  81212. * @returns a string containing the class name
  81213. */
  81214. getClassName(): string;
  81215. /**
  81216. * Serializes the particle system to a JSON object.
  81217. * @returns the JSON object
  81218. */
  81219. serialize(): any;
  81220. /**
  81221. * Parse properties from a JSON object
  81222. * @param serializationObject defines the JSON object
  81223. */
  81224. parse(serializationObject: any): void;
  81225. }
  81226. }
  81227. declare module BABYLON {
  81228. /**
  81229. * Particle emitter emitting particles from the inside of a cylinder.
  81230. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  81231. */
  81232. export class CylinderParticleEmitter implements IParticleEmitterType {
  81233. /**
  81234. * The radius of the emission cylinder.
  81235. */
  81236. radius: number;
  81237. /**
  81238. * The height of the emission cylinder.
  81239. */
  81240. height: number;
  81241. /**
  81242. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81243. */
  81244. radiusRange: number;
  81245. /**
  81246. * How much to randomize the particle direction [0-1].
  81247. */
  81248. directionRandomizer: number;
  81249. /**
  81250. * Creates a new instance CylinderParticleEmitter
  81251. * @param radius the radius of the emission cylinder (1 by default)
  81252. * @param height the height of the emission cylinder (1 by default)
  81253. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81254. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81255. */
  81256. constructor(
  81257. /**
  81258. * The radius of the emission cylinder.
  81259. */
  81260. radius?: number,
  81261. /**
  81262. * The height of the emission cylinder.
  81263. */
  81264. height?: number,
  81265. /**
  81266. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81267. */
  81268. radiusRange?: number,
  81269. /**
  81270. * How much to randomize the particle direction [0-1].
  81271. */
  81272. directionRandomizer?: number);
  81273. /**
  81274. * Called by the particle System when the direction is computed for the created particle.
  81275. * @param worldMatrix is the world matrix of the particle system
  81276. * @param directionToUpdate is the direction vector to update with the result
  81277. * @param particle is the particle we are computed the direction for
  81278. */
  81279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81280. /**
  81281. * Called by the particle System when the position is computed for the created particle.
  81282. * @param worldMatrix is the world matrix of the particle system
  81283. * @param positionToUpdate is the position vector to update with the result
  81284. * @param particle is the particle we are computed the position for
  81285. */
  81286. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81287. /**
  81288. * Clones the current emitter and returns a copy of it
  81289. * @returns the new emitter
  81290. */
  81291. clone(): CylinderParticleEmitter;
  81292. /**
  81293. * Called by the GPUParticleSystem to setup the update shader
  81294. * @param effect defines the update shader
  81295. */
  81296. applyToShader(effect: Effect): void;
  81297. /**
  81298. * Returns a string to use to update the GPU particles update shader
  81299. * @returns a string containng the defines string
  81300. */
  81301. getEffectDefines(): string;
  81302. /**
  81303. * Returns the string "CylinderParticleEmitter"
  81304. * @returns a string containing the class name
  81305. */
  81306. getClassName(): string;
  81307. /**
  81308. * Serializes the particle system to a JSON object.
  81309. * @returns the JSON object
  81310. */
  81311. serialize(): any;
  81312. /**
  81313. * Parse properties from a JSON object
  81314. * @param serializationObject defines the JSON object
  81315. */
  81316. parse(serializationObject: any): void;
  81317. }
  81318. /**
  81319. * Particle emitter emitting particles from the inside of a cylinder.
  81320. * It emits the particles randomly between two vectors.
  81321. */
  81322. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  81323. /**
  81324. * The min limit of the emission direction.
  81325. */
  81326. direction1: Vector3;
  81327. /**
  81328. * The max limit of the emission direction.
  81329. */
  81330. direction2: Vector3;
  81331. /**
  81332. * Creates a new instance CylinderDirectedParticleEmitter
  81333. * @param radius the radius of the emission cylinder (1 by default)
  81334. * @param height the height of the emission cylinder (1 by default)
  81335. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81336. * @param direction1 the min limit of the emission direction (up vector by default)
  81337. * @param direction2 the max limit of the emission direction (up vector by default)
  81338. */
  81339. constructor(radius?: number, height?: number, radiusRange?: number,
  81340. /**
  81341. * The min limit of the emission direction.
  81342. */
  81343. direction1?: Vector3,
  81344. /**
  81345. * The max limit of the emission direction.
  81346. */
  81347. direction2?: Vector3);
  81348. /**
  81349. * Called by the particle System when the direction is computed for the created particle.
  81350. * @param worldMatrix is the world matrix of the particle system
  81351. * @param directionToUpdate is the direction vector to update with the result
  81352. * @param particle is the particle we are computed the direction for
  81353. */
  81354. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81355. /**
  81356. * Clones the current emitter and returns a copy of it
  81357. * @returns the new emitter
  81358. */
  81359. clone(): CylinderDirectedParticleEmitter;
  81360. /**
  81361. * Called by the GPUParticleSystem to setup the update shader
  81362. * @param effect defines the update shader
  81363. */
  81364. applyToShader(effect: Effect): void;
  81365. /**
  81366. * Returns a string to use to update the GPU particles update shader
  81367. * @returns a string containng the defines string
  81368. */
  81369. getEffectDefines(): string;
  81370. /**
  81371. * Returns the string "CylinderDirectedParticleEmitter"
  81372. * @returns a string containing the class name
  81373. */
  81374. getClassName(): string;
  81375. /**
  81376. * Serializes the particle system to a JSON object.
  81377. * @returns the JSON object
  81378. */
  81379. serialize(): any;
  81380. /**
  81381. * Parse properties from a JSON object
  81382. * @param serializationObject defines the JSON object
  81383. */
  81384. parse(serializationObject: any): void;
  81385. }
  81386. }
  81387. declare module BABYLON {
  81388. /**
  81389. * Particle emitter emitting particles from the inside of a hemisphere.
  81390. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  81391. */
  81392. export class HemisphericParticleEmitter implements IParticleEmitterType {
  81393. /**
  81394. * The radius of the emission hemisphere.
  81395. */
  81396. radius: number;
  81397. /**
  81398. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81399. */
  81400. radiusRange: number;
  81401. /**
  81402. * How much to randomize the particle direction [0-1].
  81403. */
  81404. directionRandomizer: number;
  81405. /**
  81406. * Creates a new instance HemisphericParticleEmitter
  81407. * @param radius the radius of the emission hemisphere (1 by default)
  81408. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81409. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81410. */
  81411. constructor(
  81412. /**
  81413. * The radius of the emission hemisphere.
  81414. */
  81415. radius?: number,
  81416. /**
  81417. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81418. */
  81419. radiusRange?: number,
  81420. /**
  81421. * How much to randomize the particle direction [0-1].
  81422. */
  81423. directionRandomizer?: number);
  81424. /**
  81425. * Called by the particle System when the direction is computed for the created particle.
  81426. * @param worldMatrix is the world matrix of the particle system
  81427. * @param directionToUpdate is the direction vector to update with the result
  81428. * @param particle is the particle we are computed the direction for
  81429. */
  81430. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81431. /**
  81432. * Called by the particle System when the position is computed for the created particle.
  81433. * @param worldMatrix is the world matrix of the particle system
  81434. * @param positionToUpdate is the position vector to update with the result
  81435. * @param particle is the particle we are computed the position for
  81436. */
  81437. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81438. /**
  81439. * Clones the current emitter and returns a copy of it
  81440. * @returns the new emitter
  81441. */
  81442. clone(): HemisphericParticleEmitter;
  81443. /**
  81444. * Called by the GPUParticleSystem to setup the update shader
  81445. * @param effect defines the update shader
  81446. */
  81447. applyToShader(effect: Effect): void;
  81448. /**
  81449. * Returns a string to use to update the GPU particles update shader
  81450. * @returns a string containng the defines string
  81451. */
  81452. getEffectDefines(): string;
  81453. /**
  81454. * Returns the string "HemisphericParticleEmitter"
  81455. * @returns a string containing the class name
  81456. */
  81457. getClassName(): string;
  81458. /**
  81459. * Serializes the particle system to a JSON object.
  81460. * @returns the JSON object
  81461. */
  81462. serialize(): any;
  81463. /**
  81464. * Parse properties from a JSON object
  81465. * @param serializationObject defines the JSON object
  81466. */
  81467. parse(serializationObject: any): void;
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. /**
  81472. * Particle emitter emitting particles from a point.
  81473. * It emits the particles randomly between 2 given directions.
  81474. */
  81475. export class PointParticleEmitter implements IParticleEmitterType {
  81476. /**
  81477. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81478. */
  81479. direction1: Vector3;
  81480. /**
  81481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81482. */
  81483. direction2: Vector3;
  81484. /**
  81485. * Creates a new instance PointParticleEmitter
  81486. */
  81487. constructor();
  81488. /**
  81489. * Called by the particle System when the direction is computed for the created particle.
  81490. * @param worldMatrix is the world matrix of the particle system
  81491. * @param directionToUpdate is the direction vector to update with the result
  81492. * @param particle is the particle we are computed the direction for
  81493. */
  81494. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81495. /**
  81496. * Called by the particle System when the position is computed for the created particle.
  81497. * @param worldMatrix is the world matrix of the particle system
  81498. * @param positionToUpdate is the position vector to update with the result
  81499. * @param particle is the particle we are computed the position for
  81500. */
  81501. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81502. /**
  81503. * Clones the current emitter and returns a copy of it
  81504. * @returns the new emitter
  81505. */
  81506. clone(): PointParticleEmitter;
  81507. /**
  81508. * Called by the GPUParticleSystem to setup the update shader
  81509. * @param effect defines the update shader
  81510. */
  81511. applyToShader(effect: Effect): void;
  81512. /**
  81513. * Returns a string to use to update the GPU particles update shader
  81514. * @returns a string containng the defines string
  81515. */
  81516. getEffectDefines(): string;
  81517. /**
  81518. * Returns the string "PointParticleEmitter"
  81519. * @returns a string containing the class name
  81520. */
  81521. getClassName(): string;
  81522. /**
  81523. * Serializes the particle system to a JSON object.
  81524. * @returns the JSON object
  81525. */
  81526. serialize(): any;
  81527. /**
  81528. * Parse properties from a JSON object
  81529. * @param serializationObject defines the JSON object
  81530. */
  81531. parse(serializationObject: any): void;
  81532. }
  81533. }
  81534. declare module BABYLON {
  81535. /**
  81536. * Particle emitter emitting particles from the inside of a sphere.
  81537. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  81538. */
  81539. export class SphereParticleEmitter implements IParticleEmitterType {
  81540. /**
  81541. * The radius of the emission sphere.
  81542. */
  81543. radius: number;
  81544. /**
  81545. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81546. */
  81547. radiusRange: number;
  81548. /**
  81549. * How much to randomize the particle direction [0-1].
  81550. */
  81551. directionRandomizer: number;
  81552. /**
  81553. * Creates a new instance SphereParticleEmitter
  81554. * @param radius the radius of the emission sphere (1 by default)
  81555. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  81556. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  81557. */
  81558. constructor(
  81559. /**
  81560. * The radius of the emission sphere.
  81561. */
  81562. radius?: number,
  81563. /**
  81564. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  81565. */
  81566. radiusRange?: number,
  81567. /**
  81568. * How much to randomize the particle direction [0-1].
  81569. */
  81570. directionRandomizer?: number);
  81571. /**
  81572. * Called by the particle System when the direction is computed for the created particle.
  81573. * @param worldMatrix is the world matrix of the particle system
  81574. * @param directionToUpdate is the direction vector to update with the result
  81575. * @param particle is the particle we are computed the direction for
  81576. */
  81577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81578. /**
  81579. * Called by the particle System when the position is computed for the created particle.
  81580. * @param worldMatrix is the world matrix of the particle system
  81581. * @param positionToUpdate is the position vector to update with the result
  81582. * @param particle is the particle we are computed the position for
  81583. */
  81584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  81585. /**
  81586. * Clones the current emitter and returns a copy of it
  81587. * @returns the new emitter
  81588. */
  81589. clone(): SphereParticleEmitter;
  81590. /**
  81591. * Called by the GPUParticleSystem to setup the update shader
  81592. * @param effect defines the update shader
  81593. */
  81594. applyToShader(effect: Effect): void;
  81595. /**
  81596. * Returns a string to use to update the GPU particles update shader
  81597. * @returns a string containng the defines string
  81598. */
  81599. getEffectDefines(): string;
  81600. /**
  81601. * Returns the string "SphereParticleEmitter"
  81602. * @returns a string containing the class name
  81603. */
  81604. getClassName(): string;
  81605. /**
  81606. * Serializes the particle system to a JSON object.
  81607. * @returns the JSON object
  81608. */
  81609. serialize(): any;
  81610. /**
  81611. * Parse properties from a JSON object
  81612. * @param serializationObject defines the JSON object
  81613. */
  81614. parse(serializationObject: any): void;
  81615. }
  81616. /**
  81617. * Particle emitter emitting particles from the inside of a sphere.
  81618. * It emits the particles randomly between two vectors.
  81619. */
  81620. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  81621. /**
  81622. * The min limit of the emission direction.
  81623. */
  81624. direction1: Vector3;
  81625. /**
  81626. * The max limit of the emission direction.
  81627. */
  81628. direction2: Vector3;
  81629. /**
  81630. * Creates a new instance SphereDirectedParticleEmitter
  81631. * @param radius the radius of the emission sphere (1 by default)
  81632. * @param direction1 the min limit of the emission direction (up vector by default)
  81633. * @param direction2 the max limit of the emission direction (up vector by default)
  81634. */
  81635. constructor(radius?: number,
  81636. /**
  81637. * The min limit of the emission direction.
  81638. */
  81639. direction1?: Vector3,
  81640. /**
  81641. * The max limit of the emission direction.
  81642. */
  81643. direction2?: Vector3);
  81644. /**
  81645. * Called by the particle System when the direction is computed for the created particle.
  81646. * @param worldMatrix is the world matrix of the particle system
  81647. * @param directionToUpdate is the direction vector to update with the result
  81648. * @param particle is the particle we are computed the direction for
  81649. */
  81650. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  81651. /**
  81652. * Clones the current emitter and returns a copy of it
  81653. * @returns the new emitter
  81654. */
  81655. clone(): SphereDirectedParticleEmitter;
  81656. /**
  81657. * Called by the GPUParticleSystem to setup the update shader
  81658. * @param effect defines the update shader
  81659. */
  81660. applyToShader(effect: Effect): void;
  81661. /**
  81662. * Returns a string to use to update the GPU particles update shader
  81663. * @returns a string containng the defines string
  81664. */
  81665. getEffectDefines(): string;
  81666. /**
  81667. * Returns the string "SphereDirectedParticleEmitter"
  81668. * @returns a string containing the class name
  81669. */
  81670. getClassName(): string;
  81671. /**
  81672. * Serializes the particle system to a JSON object.
  81673. * @returns the JSON object
  81674. */
  81675. serialize(): any;
  81676. /**
  81677. * Parse properties from a JSON object
  81678. * @param serializationObject defines the JSON object
  81679. */
  81680. parse(serializationObject: any): void;
  81681. }
  81682. }
  81683. declare module BABYLON {
  81684. /**
  81685. * Interface representing a particle system in Babylon.js.
  81686. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  81687. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  81688. */
  81689. export interface IParticleSystem {
  81690. /**
  81691. * List of animations used by the particle system.
  81692. */
  81693. animations: Animation[];
  81694. /**
  81695. * The id of the Particle system.
  81696. */
  81697. id: string;
  81698. /**
  81699. * The name of the Particle system.
  81700. */
  81701. name: string;
  81702. /**
  81703. * The emitter represents the Mesh or position we are attaching the particle system to.
  81704. */
  81705. emitter: Nullable<AbstractMesh | Vector3>;
  81706. /**
  81707. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81708. */
  81709. isBillboardBased: boolean;
  81710. /**
  81711. * The rendering group used by the Particle system to chose when to render.
  81712. */
  81713. renderingGroupId: number;
  81714. /**
  81715. * The layer mask we are rendering the particles through.
  81716. */
  81717. layerMask: number;
  81718. /**
  81719. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81720. */
  81721. updateSpeed: number;
  81722. /**
  81723. * The amount of time the particle system is running (depends of the overall update speed).
  81724. */
  81725. targetStopDuration: number;
  81726. /**
  81727. * The texture used to render each particle. (this can be a spritesheet)
  81728. */
  81729. particleTexture: Nullable<Texture>;
  81730. /**
  81731. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  81732. */
  81733. blendMode: number;
  81734. /**
  81735. * Minimum life time of emitting particles.
  81736. */
  81737. minLifeTime: number;
  81738. /**
  81739. * Maximum life time of emitting particles.
  81740. */
  81741. maxLifeTime: number;
  81742. /**
  81743. * Minimum Size of emitting particles.
  81744. */
  81745. minSize: number;
  81746. /**
  81747. * Maximum Size of emitting particles.
  81748. */
  81749. maxSize: number;
  81750. /**
  81751. * Minimum scale of emitting particles on X axis.
  81752. */
  81753. minScaleX: number;
  81754. /**
  81755. * Maximum scale of emitting particles on X axis.
  81756. */
  81757. maxScaleX: number;
  81758. /**
  81759. * Minimum scale of emitting particles on Y axis.
  81760. */
  81761. minScaleY: number;
  81762. /**
  81763. * Maximum scale of emitting particles on Y axis.
  81764. */
  81765. maxScaleY: number;
  81766. /**
  81767. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81768. */
  81769. color1: Color4;
  81770. /**
  81771. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  81772. */
  81773. color2: Color4;
  81774. /**
  81775. * Color the particle will have at the end of its lifetime.
  81776. */
  81777. colorDead: Color4;
  81778. /**
  81779. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  81780. */
  81781. emitRate: number;
  81782. /**
  81783. * You can use gravity if you want to give an orientation to your particles.
  81784. */
  81785. gravity: Vector3;
  81786. /**
  81787. * Minimum power of emitting particles.
  81788. */
  81789. minEmitPower: number;
  81790. /**
  81791. * Maximum power of emitting particles.
  81792. */
  81793. maxEmitPower: number;
  81794. /**
  81795. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81796. */
  81797. minAngularSpeed: number;
  81798. /**
  81799. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81800. */
  81801. maxAngularSpeed: number;
  81802. /**
  81803. * Gets or sets the minimal initial rotation in radians.
  81804. */
  81805. minInitialRotation: number;
  81806. /**
  81807. * Gets or sets the maximal initial rotation in radians.
  81808. */
  81809. maxInitialRotation: number;
  81810. /**
  81811. * The particle emitter type defines the emitter used by the particle system.
  81812. * It can be for example box, sphere, or cone...
  81813. */
  81814. particleEmitterType: Nullable<IParticleEmitterType>;
  81815. /**
  81816. * Defines the delay in milliseconds before starting the system (0 by default)
  81817. */
  81818. startDelay: number;
  81819. /**
  81820. * 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
  81821. */
  81822. preWarmCycles: number;
  81823. /**
  81824. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  81825. */
  81826. preWarmStepOffset: number;
  81827. /**
  81828. * 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)
  81829. */
  81830. spriteCellChangeSpeed: number;
  81831. /**
  81832. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81833. */
  81834. startSpriteCellID: number;
  81835. /**
  81836. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81837. */
  81838. endSpriteCellID: number;
  81839. /**
  81840. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81841. */
  81842. spriteCellWidth: number;
  81843. /**
  81844. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81845. */
  81846. spriteCellHeight: number;
  81847. /**
  81848. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81849. */
  81850. spriteRandomStartCell: boolean;
  81851. /**
  81852. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  81853. */
  81854. isAnimationSheetEnabled: boolean;
  81855. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81856. translationPivot: Vector2;
  81857. /**
  81858. * Gets or sets a texture used to add random noise to particle positions
  81859. */
  81860. noiseTexture: Nullable<BaseTexture>;
  81861. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81862. noiseStrength: Vector3;
  81863. /**
  81864. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81865. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81866. */
  81867. billboardMode: number;
  81868. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81869. limitVelocityDamping: number;
  81870. /**
  81871. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81872. */
  81873. beginAnimationOnStart: boolean;
  81874. /**
  81875. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81876. */
  81877. beginAnimationFrom: number;
  81878. /**
  81879. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81880. */
  81881. beginAnimationTo: number;
  81882. /**
  81883. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81884. */
  81885. beginAnimationLoop: boolean;
  81886. /**
  81887. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81888. */
  81889. disposeOnStop: boolean;
  81890. /**
  81891. * Gets the maximum number of particles active at the same time.
  81892. * @returns The max number of active particles.
  81893. */
  81894. getCapacity(): number;
  81895. /**
  81896. * Gets if the system has been started. (Note: this will still be true after stop is called)
  81897. * @returns True if it has been started, otherwise false.
  81898. */
  81899. isStarted(): boolean;
  81900. /**
  81901. * Animates the particle system for this frame.
  81902. */
  81903. animate(): void;
  81904. /**
  81905. * Renders the particle system in its current state.
  81906. * @returns the current number of particles
  81907. */
  81908. render(): number;
  81909. /**
  81910. * Dispose the particle system and frees its associated resources.
  81911. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  81912. */
  81913. dispose(disposeTexture?: boolean): void;
  81914. /**
  81915. * Clones the particle system.
  81916. * @param name The name of the cloned object
  81917. * @param newEmitter The new emitter to use
  81918. * @returns the cloned particle system
  81919. */
  81920. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  81921. /**
  81922. * Serializes the particle system to a JSON object.
  81923. * @returns the JSON object
  81924. */
  81925. serialize(): any;
  81926. /**
  81927. * Rebuild the particle system
  81928. */
  81929. rebuild(): void;
  81930. /**
  81931. * Starts the particle system and begins to emit
  81932. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  81933. */
  81934. start(delay?: number): void;
  81935. /**
  81936. * Stops the particle system.
  81937. */
  81938. stop(): void;
  81939. /**
  81940. * Remove all active particles
  81941. */
  81942. reset(): void;
  81943. /**
  81944. * Is this system ready to be used/rendered
  81945. * @return true if the system is ready
  81946. */
  81947. isReady(): boolean;
  81948. /**
  81949. * Adds a new color gradient
  81950. * @param gradient defines the gradient to use (between 0 and 1)
  81951. * @param color1 defines the color to affect to the specified gradient
  81952. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  81953. * @returns the current particle system
  81954. */
  81955. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  81956. /**
  81957. * Remove a specific color gradient
  81958. * @param gradient defines the gradient to remove
  81959. * @returns the current particle system
  81960. */
  81961. removeColorGradient(gradient: number): IParticleSystem;
  81962. /**
  81963. * Adds a new size gradient
  81964. * @param gradient defines the gradient to use (between 0 and 1)
  81965. * @param factor defines the size factor to affect to the specified gradient
  81966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81967. * @returns the current particle system
  81968. */
  81969. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  81970. /**
  81971. * Remove a specific size gradient
  81972. * @param gradient defines the gradient to remove
  81973. * @returns the current particle system
  81974. */
  81975. removeSizeGradient(gradient: number): IParticleSystem;
  81976. /**
  81977. * Gets the current list of color gradients.
  81978. * You must use addColorGradient and removeColorGradient to udpate this list
  81979. * @returns the list of color gradients
  81980. */
  81981. getColorGradients(): Nullable<Array<ColorGradient>>;
  81982. /**
  81983. * Gets the current list of size gradients.
  81984. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81985. * @returns the list of size gradients
  81986. */
  81987. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81988. /**
  81989. * Gets the current list of angular speed gradients.
  81990. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81991. * @returns the list of angular speed gradients
  81992. */
  81993. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81994. /**
  81995. * Adds a new angular speed gradient
  81996. * @param gradient defines the gradient to use (between 0 and 1)
  81997. * @param factor defines the angular speed to affect to the specified gradient
  81998. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  81999. * @returns the current particle system
  82000. */
  82001. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82002. /**
  82003. * Remove a specific angular speed gradient
  82004. * @param gradient defines the gradient to remove
  82005. * @returns the current particle system
  82006. */
  82007. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82008. /**
  82009. * Gets the current list of velocity gradients.
  82010. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  82011. * @returns the list of velocity gradients
  82012. */
  82013. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  82014. /**
  82015. * Adds a new velocity gradient
  82016. * @param gradient defines the gradient to use (between 0 and 1)
  82017. * @param factor defines the velocity to affect to the specified gradient
  82018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82019. * @returns the current particle system
  82020. */
  82021. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82022. /**
  82023. * Remove a specific velocity gradient
  82024. * @param gradient defines the gradient to remove
  82025. * @returns the current particle system
  82026. */
  82027. removeVelocityGradient(gradient: number): IParticleSystem;
  82028. /**
  82029. * Gets the current list of limit velocity gradients.
  82030. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  82031. * @returns the list of limit velocity gradients
  82032. */
  82033. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  82034. /**
  82035. * Adds a new limit velocity gradient
  82036. * @param gradient defines the gradient to use (between 0 and 1)
  82037. * @param factor defines the limit velocity to affect to the specified gradient
  82038. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82039. * @returns the current particle system
  82040. */
  82041. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82042. /**
  82043. * Remove a specific limit velocity gradient
  82044. * @param gradient defines the gradient to remove
  82045. * @returns the current particle system
  82046. */
  82047. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82048. /**
  82049. * Adds a new drag gradient
  82050. * @param gradient defines the gradient to use (between 0 and 1)
  82051. * @param factor defines the drag to affect to the specified gradient
  82052. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82053. * @returns the current particle system
  82054. */
  82055. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82056. /**
  82057. * Remove a specific drag gradient
  82058. * @param gradient defines the gradient to remove
  82059. * @returns the current particle system
  82060. */
  82061. removeDragGradient(gradient: number): IParticleSystem;
  82062. /**
  82063. * Gets the current list of drag gradients.
  82064. * You must use addDragGradient and removeDragGradient to udpate this list
  82065. * @returns the list of drag gradients
  82066. */
  82067. getDragGradients(): Nullable<Array<FactorGradient>>;
  82068. /**
  82069. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82070. * @param gradient defines the gradient to use (between 0 and 1)
  82071. * @param factor defines the emit rate to affect to the specified gradient
  82072. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82073. * @returns the current particle system
  82074. */
  82075. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82076. /**
  82077. * Remove a specific emit rate gradient
  82078. * @param gradient defines the gradient to remove
  82079. * @returns the current particle system
  82080. */
  82081. removeEmitRateGradient(gradient: number): IParticleSystem;
  82082. /**
  82083. * Gets the current list of emit rate gradients.
  82084. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  82085. * @returns the list of emit rate gradients
  82086. */
  82087. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  82088. /**
  82089. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82090. * @param gradient defines the gradient to use (between 0 and 1)
  82091. * @param factor defines the start size to affect to the specified gradient
  82092. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82093. * @returns the current particle system
  82094. */
  82095. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82096. /**
  82097. * Remove a specific start size gradient
  82098. * @param gradient defines the gradient to remove
  82099. * @returns the current particle system
  82100. */
  82101. removeStartSizeGradient(gradient: number): IParticleSystem;
  82102. /**
  82103. * Gets the current list of start size gradients.
  82104. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  82105. * @returns the list of start size gradients
  82106. */
  82107. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  82108. /**
  82109. * Adds a new life time gradient
  82110. * @param gradient defines the gradient to use (between 0 and 1)
  82111. * @param factor defines the life time factor to affect to the specified gradient
  82112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82113. * @returns the current particle system
  82114. */
  82115. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82116. /**
  82117. * Remove a specific life time gradient
  82118. * @param gradient defines the gradient to remove
  82119. * @returns the current particle system
  82120. */
  82121. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82122. /**
  82123. * Gets the current list of life time gradients.
  82124. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  82125. * @returns the list of life time gradients
  82126. */
  82127. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  82128. /**
  82129. * Gets the current list of color gradients.
  82130. * You must use addColorGradient and removeColorGradient to udpate this list
  82131. * @returns the list of color gradients
  82132. */
  82133. getColorGradients(): Nullable<Array<ColorGradient>>;
  82134. /**
  82135. * Adds a new ramp gradient used to remap particle colors
  82136. * @param gradient defines the gradient to use (between 0 and 1)
  82137. * @param color defines the color to affect to the specified gradient
  82138. * @returns the current particle system
  82139. */
  82140. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  82141. /**
  82142. * Gets the current list of ramp gradients.
  82143. * You must use addRampGradient and removeRampGradient to udpate this list
  82144. * @returns the list of ramp gradients
  82145. */
  82146. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82147. /** Gets or sets a boolean indicating that ramp gradients must be used
  82148. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82149. */
  82150. useRampGradients: boolean;
  82151. /**
  82152. * Adds a new color remap gradient
  82153. * @param gradient defines the gradient to use (between 0 and 1)
  82154. * @param min defines the color remap minimal range
  82155. * @param max defines the color remap maximal range
  82156. * @returns the current particle system
  82157. */
  82158. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82159. /**
  82160. * Gets the current list of color remap gradients.
  82161. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  82162. * @returns the list of color remap gradients
  82163. */
  82164. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  82165. /**
  82166. * Adds a new alpha remap gradient
  82167. * @param gradient defines the gradient to use (between 0 and 1)
  82168. * @param min defines the alpha remap minimal range
  82169. * @param max defines the alpha remap maximal range
  82170. * @returns the current particle system
  82171. */
  82172. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82173. /**
  82174. * Gets the current list of alpha remap gradients.
  82175. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  82176. * @returns the list of alpha remap gradients
  82177. */
  82178. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  82179. /**
  82180. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  82181. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82182. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82183. * @returns the emitter
  82184. */
  82185. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  82186. /**
  82187. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  82188. * @param radius The radius of the hemisphere to emit from
  82189. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82190. * @returns the emitter
  82191. */
  82192. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  82193. /**
  82194. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  82195. * @param radius The radius of the sphere to emit from
  82196. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  82197. * @returns the emitter
  82198. */
  82199. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  82200. /**
  82201. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  82202. * @param radius The radius of the sphere to emit from
  82203. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  82204. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  82205. * @returns the emitter
  82206. */
  82207. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82208. /**
  82209. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  82210. * @param radius The radius of the emission cylinder
  82211. * @param height The height of the emission cylinder
  82212. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82213. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82214. * @returns the emitter
  82215. */
  82216. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  82217. /**
  82218. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82219. * @param radius The radius of the cylinder to emit from
  82220. * @param height The height of the emission cylinder
  82221. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82222. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82223. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82224. * @returns the emitter
  82225. */
  82226. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  82227. /**
  82228. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82229. * @param radius The radius of the cone to emit from
  82230. * @param angle The base angle of the cone
  82231. * @returns the emitter
  82232. */
  82233. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  82234. /**
  82235. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82236. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82237. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82238. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82239. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82240. * @returns the emitter
  82241. */
  82242. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82243. /**
  82244. * Get hosting scene
  82245. * @returns the scene
  82246. */
  82247. getScene(): Scene;
  82248. }
  82249. }
  82250. declare module BABYLON {
  82251. /**
  82252. * Creates an instance based on a source mesh.
  82253. */
  82254. export class InstancedMesh extends AbstractMesh {
  82255. private _sourceMesh;
  82256. private _currentLOD;
  82257. /** @hidden */
  82258. _indexInSourceMeshInstanceArray: number;
  82259. constructor(name: string, source: Mesh);
  82260. /**
  82261. * Returns the string "InstancedMesh".
  82262. */
  82263. getClassName(): string;
  82264. /** Gets the list of lights affecting that mesh */
  82265. readonly lightSources: Light[];
  82266. _resyncLightSources(): void;
  82267. _resyncLighSource(light: Light): void;
  82268. _removeLightSource(light: Light): void;
  82269. /**
  82270. * If the source mesh receives shadows
  82271. */
  82272. readonly receiveShadows: boolean;
  82273. /**
  82274. * The material of the source mesh
  82275. */
  82276. readonly material: Nullable<Material>;
  82277. /**
  82278. * Visibility of the source mesh
  82279. */
  82280. readonly visibility: number;
  82281. /**
  82282. * Skeleton of the source mesh
  82283. */
  82284. readonly skeleton: Nullable<Skeleton>;
  82285. /**
  82286. * Rendering ground id of the source mesh
  82287. */
  82288. renderingGroupId: number;
  82289. /**
  82290. * Returns the total number of vertices (integer).
  82291. */
  82292. getTotalVertices(): number;
  82293. /**
  82294. * Returns a positive integer : the total number of indices in this mesh geometry.
  82295. * @returns the numner of indices or zero if the mesh has no geometry.
  82296. */
  82297. getTotalIndices(): number;
  82298. /**
  82299. * The source mesh of the instance
  82300. */
  82301. readonly sourceMesh: Mesh;
  82302. /**
  82303. * Is this node ready to be used/rendered
  82304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  82305. * @return {boolean} is it ready
  82306. */
  82307. isReady(completeCheck?: boolean): boolean;
  82308. /**
  82309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82310. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  82311. * @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.
  82312. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  82313. */
  82314. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  82315. /**
  82316. * Sets the vertex data of the mesh geometry for the requested `kind`.
  82317. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  82318. * The `data` are either a numeric array either a Float32Array.
  82319. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  82320. * 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).
  82321. * Note that a new underlying VertexBuffer object is created each call.
  82322. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  82323. *
  82324. * Possible `kind` values :
  82325. * - VertexBuffer.PositionKind
  82326. * - VertexBuffer.UVKind
  82327. * - VertexBuffer.UV2Kind
  82328. * - VertexBuffer.UV3Kind
  82329. * - VertexBuffer.UV4Kind
  82330. * - VertexBuffer.UV5Kind
  82331. * - VertexBuffer.UV6Kind
  82332. * - VertexBuffer.ColorKind
  82333. * - VertexBuffer.MatricesIndicesKind
  82334. * - VertexBuffer.MatricesIndicesExtraKind
  82335. * - VertexBuffer.MatricesWeightsKind
  82336. * - VertexBuffer.MatricesWeightsExtraKind
  82337. *
  82338. * Returns the Mesh.
  82339. */
  82340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  82341. /**
  82342. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  82343. * If the mesh has no geometry, it is simply returned as it is.
  82344. * The `data` are either a numeric array either a Float32Array.
  82345. * No new underlying VertexBuffer object is created.
  82346. * 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.
  82347. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  82348. *
  82349. * Possible `kind` values :
  82350. * - VertexBuffer.PositionKind
  82351. * - VertexBuffer.UVKind
  82352. * - VertexBuffer.UV2Kind
  82353. * - VertexBuffer.UV3Kind
  82354. * - VertexBuffer.UV4Kind
  82355. * - VertexBuffer.UV5Kind
  82356. * - VertexBuffer.UV6Kind
  82357. * - VertexBuffer.ColorKind
  82358. * - VertexBuffer.MatricesIndicesKind
  82359. * - VertexBuffer.MatricesIndicesExtraKind
  82360. * - VertexBuffer.MatricesWeightsKind
  82361. * - VertexBuffer.MatricesWeightsExtraKind
  82362. *
  82363. * Returns the Mesh.
  82364. */
  82365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  82366. /**
  82367. * Sets the mesh indices.
  82368. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  82369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  82370. * This method creates a new index buffer each call.
  82371. * Returns the Mesh.
  82372. */
  82373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  82374. /**
  82375. * Boolean : True if the mesh owns the requested kind of data.
  82376. */
  82377. isVerticesDataPresent(kind: string): boolean;
  82378. /**
  82379. * Returns an array of indices (IndicesArray).
  82380. */
  82381. getIndices(): Nullable<IndicesArray>;
  82382. readonly _positions: Nullable<Vector3[]>;
  82383. /**
  82384. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  82385. * This means the mesh underlying bounding box and sphere are recomputed.
  82386. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  82387. * @returns the current mesh
  82388. */
  82389. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  82390. /** @hidden */
  82391. _preActivate(): InstancedMesh;
  82392. /** @hidden */
  82393. _activate(renderId: number, intermediateRendering: boolean): boolean;
  82394. /** @hidden */
  82395. _postActivate(): void;
  82396. getWorldMatrix(): Matrix;
  82397. readonly isAnInstance: boolean;
  82398. /**
  82399. * Returns the current associated LOD AbstractMesh.
  82400. */
  82401. getLOD(camera: Camera): AbstractMesh;
  82402. /** @hidden */
  82403. _syncSubMeshes(): InstancedMesh;
  82404. /** @hidden */
  82405. _generatePointsArray(): boolean;
  82406. /**
  82407. * Creates a new InstancedMesh from the current mesh.
  82408. * - name (string) : the cloned mesh name
  82409. * - newParent (optional Node) : the optional Node to parent the clone to.
  82410. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  82411. *
  82412. * Returns the clone.
  82413. */
  82414. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  82415. /**
  82416. * Disposes the InstancedMesh.
  82417. * Returns nothing.
  82418. */
  82419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  82420. }
  82421. }
  82422. declare module BABYLON {
  82423. /**
  82424. * Defines the options associated with the creation of a shader material.
  82425. */
  82426. export interface IShaderMaterialOptions {
  82427. /**
  82428. * Does the material work in alpha blend mode
  82429. */
  82430. needAlphaBlending: boolean;
  82431. /**
  82432. * Does the material work in alpha test mode
  82433. */
  82434. needAlphaTesting: boolean;
  82435. /**
  82436. * The list of attribute names used in the shader
  82437. */
  82438. attributes: string[];
  82439. /**
  82440. * The list of unifrom names used in the shader
  82441. */
  82442. uniforms: string[];
  82443. /**
  82444. * The list of UBO names used in the shader
  82445. */
  82446. uniformBuffers: string[];
  82447. /**
  82448. * The list of sampler names used in the shader
  82449. */
  82450. samplers: string[];
  82451. /**
  82452. * The list of defines used in the shader
  82453. */
  82454. defines: string[];
  82455. }
  82456. /**
  82457. * 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.
  82458. *
  82459. * This returned material effects how the mesh will look based on the code in the shaders.
  82460. *
  82461. * @see http://doc.babylonjs.com/how_to/shader_material
  82462. */
  82463. export class ShaderMaterial extends Material {
  82464. private _shaderPath;
  82465. private _options;
  82466. private _textures;
  82467. private _textureArrays;
  82468. private _floats;
  82469. private _ints;
  82470. private _floatsArrays;
  82471. private _colors3;
  82472. private _colors3Arrays;
  82473. private _colors4;
  82474. private _colors4Arrays;
  82475. private _vectors2;
  82476. private _vectors3;
  82477. private _vectors4;
  82478. private _matrices;
  82479. private _matrices3x3;
  82480. private _matrices2x2;
  82481. private _vectors2Arrays;
  82482. private _vectors3Arrays;
  82483. private _vectors4Arrays;
  82484. private _cachedWorldViewMatrix;
  82485. private _cachedWorldViewProjectionMatrix;
  82486. private _renderId;
  82487. /**
  82488. * Instantiate a new shader material.
  82489. * 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.
  82490. * This returned material effects how the mesh will look based on the code in the shaders.
  82491. * @see http://doc.babylonjs.com/how_to/shader_material
  82492. * @param name Define the name of the material in the scene
  82493. * @param scene Define the scene the material belongs to
  82494. * @param shaderPath Defines the route to the shader code in one of three ways:
  82495. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  82496. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  82497. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  82498. * @param options Define the options used to create the shader
  82499. */
  82500. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  82501. /**
  82502. * Gets the options used to compile the shader.
  82503. * They can be modified to trigger a new compilation
  82504. */
  82505. readonly options: IShaderMaterialOptions;
  82506. /**
  82507. * Gets the current class name of the material e.g. "ShaderMaterial"
  82508. * Mainly use in serialization.
  82509. * @returns the class name
  82510. */
  82511. getClassName(): string;
  82512. /**
  82513. * Specifies if the material will require alpha blending
  82514. * @returns a boolean specifying if alpha blending is needed
  82515. */
  82516. needAlphaBlending(): boolean;
  82517. /**
  82518. * Specifies if this material should be rendered in alpha test mode
  82519. * @returns a boolean specifying if an alpha test is needed.
  82520. */
  82521. needAlphaTesting(): boolean;
  82522. private _checkUniform;
  82523. /**
  82524. * Set a texture in the shader.
  82525. * @param name Define the name of the uniform samplers as defined in the shader
  82526. * @param texture Define the texture to bind to this sampler
  82527. * @return the material itself allowing "fluent" like uniform updates
  82528. */
  82529. setTexture(name: string, texture: Texture): ShaderMaterial;
  82530. /**
  82531. * Set a texture array in the shader.
  82532. * @param name Define the name of the uniform sampler array as defined in the shader
  82533. * @param textures Define the list of textures to bind to this sampler
  82534. * @return the material itself allowing "fluent" like uniform updates
  82535. */
  82536. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  82537. /**
  82538. * Set a float in the shader.
  82539. * @param name Define the name of the uniform as defined in the shader
  82540. * @param value Define the value to give to the uniform
  82541. * @return the material itself allowing "fluent" like uniform updates
  82542. */
  82543. setFloat(name: string, value: number): ShaderMaterial;
  82544. /**
  82545. * Set a int in the shader.
  82546. * @param name Define the name of the uniform as defined in the shader
  82547. * @param value Define the value to give to the uniform
  82548. * @return the material itself allowing "fluent" like uniform updates
  82549. */
  82550. setInt(name: string, value: number): ShaderMaterial;
  82551. /**
  82552. * Set an array of floats in the shader.
  82553. * @param name Define the name of the uniform as defined in the shader
  82554. * @param value Define the value to give to the uniform
  82555. * @return the material itself allowing "fluent" like uniform updates
  82556. */
  82557. setFloats(name: string, value: number[]): ShaderMaterial;
  82558. /**
  82559. * Set a vec3 in the shader from a Color3.
  82560. * @param name Define the name of the uniform as defined in the shader
  82561. * @param value Define the value to give to the uniform
  82562. * @return the material itself allowing "fluent" like uniform updates
  82563. */
  82564. setColor3(name: string, value: Color3): ShaderMaterial;
  82565. /**
  82566. * Set a vec3 array in the shader from a Color3 array.
  82567. * @param name Define the name of the uniform as defined in the shader
  82568. * @param value Define the value to give to the uniform
  82569. * @return the material itself allowing "fluent" like uniform updates
  82570. */
  82571. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  82572. /**
  82573. * Set a vec4 in the shader from a Color4.
  82574. * @param name Define the name of the uniform as defined in the shader
  82575. * @param value Define the value to give to the uniform
  82576. * @return the material itself allowing "fluent" like uniform updates
  82577. */
  82578. setColor4(name: string, value: Color4): ShaderMaterial;
  82579. /**
  82580. * Set a vec4 array in the shader from a Color4 array.
  82581. * @param name Define the name of the uniform as defined in the shader
  82582. * @param value Define the value to give to the uniform
  82583. * @return the material itself allowing "fluent" like uniform updates
  82584. */
  82585. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  82586. /**
  82587. * Set a vec2 in the shader from a Vector2.
  82588. * @param name Define the name of the uniform as defined in the shader
  82589. * @param value Define the value to give to the uniform
  82590. * @return the material itself allowing "fluent" like uniform updates
  82591. */
  82592. setVector2(name: string, value: Vector2): ShaderMaterial;
  82593. /**
  82594. * Set a vec3 in the shader from a Vector3.
  82595. * @param name Define the name of the uniform as defined in the shader
  82596. * @param value Define the value to give to the uniform
  82597. * @return the material itself allowing "fluent" like uniform updates
  82598. */
  82599. setVector3(name: string, value: Vector3): ShaderMaterial;
  82600. /**
  82601. * Set a vec4 in the shader from a Vector4.
  82602. * @param name Define the name of the uniform as defined in the shader
  82603. * @param value Define the value to give to the uniform
  82604. * @return the material itself allowing "fluent" like uniform updates
  82605. */
  82606. setVector4(name: string, value: Vector4): ShaderMaterial;
  82607. /**
  82608. * Set a mat4 in the shader from a Matrix.
  82609. * @param name Define the name of the uniform as defined in the shader
  82610. * @param value Define the value to give to the uniform
  82611. * @return the material itself allowing "fluent" like uniform updates
  82612. */
  82613. setMatrix(name: string, value: Matrix): ShaderMaterial;
  82614. /**
  82615. * Set a mat3 in the shader from a Float32Array.
  82616. * @param name Define the name of the uniform as defined in the shader
  82617. * @param value Define the value to give to the uniform
  82618. * @return the material itself allowing "fluent" like uniform updates
  82619. */
  82620. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  82621. /**
  82622. * Set a mat2 in the shader from a Float32Array.
  82623. * @param name Define the name of the uniform as defined in the shader
  82624. * @param value Define the value to give to the uniform
  82625. * @return the material itself allowing "fluent" like uniform updates
  82626. */
  82627. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  82628. /**
  82629. * Set a vec2 array in the shader from a number array.
  82630. * @param name Define the name of the uniform as defined in the shader
  82631. * @param value Define the value to give to the uniform
  82632. * @return the material itself allowing "fluent" like uniform updates
  82633. */
  82634. setArray2(name: string, value: number[]): ShaderMaterial;
  82635. /**
  82636. * Set a vec3 array in the shader from a number array.
  82637. * @param name Define the name of the uniform as defined in the shader
  82638. * @param value Define the value to give to the uniform
  82639. * @return the material itself allowing "fluent" like uniform updates
  82640. */
  82641. setArray3(name: string, value: number[]): ShaderMaterial;
  82642. /**
  82643. * Set a vec4 array in the shader from a number array.
  82644. * @param name Define the name of the uniform as defined in the shader
  82645. * @param value Define the value to give to the uniform
  82646. * @return the material itself allowing "fluent" like uniform updates
  82647. */
  82648. setArray4(name: string, value: number[]): ShaderMaterial;
  82649. private _checkCache;
  82650. /**
  82651. * Specifies that the submesh is ready to be used
  82652. * @param mesh defines the mesh to check
  82653. * @param subMesh defines which submesh to check
  82654. * @param useInstances specifies that instances should be used
  82655. * @returns a boolean indicating that the submesh is ready or not
  82656. */
  82657. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  82658. /**
  82659. * Checks if the material is ready to render the requested mesh
  82660. * @param mesh Define the mesh to render
  82661. * @param useInstances Define whether or not the material is used with instances
  82662. * @returns true if ready, otherwise false
  82663. */
  82664. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  82665. /**
  82666. * Binds the world matrix to the material
  82667. * @param world defines the world transformation matrix
  82668. */
  82669. bindOnlyWorldMatrix(world: Matrix): void;
  82670. /**
  82671. * Binds the material to the mesh
  82672. * @param world defines the world transformation matrix
  82673. * @param mesh defines the mesh to bind the material to
  82674. */
  82675. bind(world: Matrix, mesh?: Mesh): void;
  82676. /**
  82677. * Gets the active textures from the material
  82678. * @returns an array of textures
  82679. */
  82680. getActiveTextures(): BaseTexture[];
  82681. /**
  82682. * Specifies if the material uses a texture
  82683. * @param texture defines the texture to check against the material
  82684. * @returns a boolean specifying if the material uses the texture
  82685. */
  82686. hasTexture(texture: BaseTexture): boolean;
  82687. /**
  82688. * Makes a duplicate of the material, and gives it a new name
  82689. * @param name defines the new name for the duplicated material
  82690. * @returns the cloned material
  82691. */
  82692. clone(name: string): ShaderMaterial;
  82693. /**
  82694. * Disposes the material
  82695. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  82696. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  82697. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  82698. */
  82699. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  82700. /**
  82701. * Serializes this material in a JSON representation
  82702. * @returns the serialized material object
  82703. */
  82704. serialize(): any;
  82705. /**
  82706. * Creates a shader material from parsed shader material data
  82707. * @param source defines the JSON represnetation of the material
  82708. * @param scene defines the hosting scene
  82709. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  82710. * @returns a new material
  82711. */
  82712. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  82713. }
  82714. }
  82715. declare module BABYLON {
  82716. /** @hidden */
  82717. export var colorPixelShader: {
  82718. name: string;
  82719. shader: string;
  82720. };
  82721. }
  82722. declare module BABYLON {
  82723. /** @hidden */
  82724. export var colorVertexShader: {
  82725. name: string;
  82726. shader: string;
  82727. };
  82728. }
  82729. declare module BABYLON {
  82730. /**
  82731. * Line mesh
  82732. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  82733. */
  82734. export class LinesMesh extends Mesh {
  82735. /**
  82736. * If vertex color should be applied to the mesh
  82737. */
  82738. readonly useVertexColor?: boolean | undefined;
  82739. /**
  82740. * If vertex alpha should be applied to the mesh
  82741. */
  82742. readonly useVertexAlpha?: boolean | undefined;
  82743. /**
  82744. * Color of the line (Default: White)
  82745. */
  82746. color: Color3;
  82747. /**
  82748. * Alpha of the line (Default: 1)
  82749. */
  82750. alpha: number;
  82751. /**
  82752. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82753. * This margin is expressed in world space coordinates, so its value may vary.
  82754. * Default value is 0.1
  82755. */
  82756. intersectionThreshold: number;
  82757. private _colorShader;
  82758. private color4;
  82759. /**
  82760. * Creates a new LinesMesh
  82761. * @param name defines the name
  82762. * @param scene defines the hosting scene
  82763. * @param parent defines the parent mesh if any
  82764. * @param source defines the optional source LinesMesh used to clone data from
  82765. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  82766. * When false, achieved by calling a clone(), also passing False.
  82767. * This will make creation of children, recursive.
  82768. * @param useVertexColor defines if this LinesMesh supports vertex color
  82769. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  82770. */
  82771. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  82772. /**
  82773. * If vertex color should be applied to the mesh
  82774. */
  82775. useVertexColor?: boolean | undefined,
  82776. /**
  82777. * If vertex alpha should be applied to the mesh
  82778. */
  82779. useVertexAlpha?: boolean | undefined);
  82780. private _addClipPlaneDefine;
  82781. private _removeClipPlaneDefine;
  82782. isReady(): boolean;
  82783. /**
  82784. * Returns the string "LineMesh"
  82785. */
  82786. getClassName(): string;
  82787. /**
  82788. * @hidden
  82789. */
  82790. /**
  82791. * @hidden
  82792. */
  82793. material: Material;
  82794. /**
  82795. * @hidden
  82796. */
  82797. readonly checkCollisions: boolean;
  82798. /** @hidden */
  82799. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  82800. /** @hidden */
  82801. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  82802. /**
  82803. * Disposes of the line mesh
  82804. * @param doNotRecurse If children should be disposed
  82805. */
  82806. dispose(doNotRecurse?: boolean): void;
  82807. /**
  82808. * Returns a new LineMesh object cloned from the current one.
  82809. */
  82810. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  82811. /**
  82812. * Creates a new InstancedLinesMesh object from the mesh model.
  82813. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82814. * @param name defines the name of the new instance
  82815. * @returns a new InstancedLinesMesh
  82816. */
  82817. createInstance(name: string): InstancedLinesMesh;
  82818. }
  82819. /**
  82820. * Creates an instance based on a source LinesMesh
  82821. */
  82822. export class InstancedLinesMesh extends InstancedMesh {
  82823. /**
  82824. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  82825. * This margin is expressed in world space coordinates, so its value may vary.
  82826. * Initilized with the intersectionThreshold value of the source LinesMesh
  82827. */
  82828. intersectionThreshold: number;
  82829. constructor(name: string, source: LinesMesh);
  82830. /**
  82831. * Returns the string "InstancedLinesMesh".
  82832. */
  82833. getClassName(): string;
  82834. }
  82835. }
  82836. declare module BABYLON {
  82837. /** @hidden */
  82838. export var linePixelShader: {
  82839. name: string;
  82840. shader: string;
  82841. };
  82842. }
  82843. declare module BABYLON {
  82844. /** @hidden */
  82845. export var lineVertexShader: {
  82846. name: string;
  82847. shader: string;
  82848. };
  82849. }
  82850. declare module BABYLON {
  82851. interface AbstractMesh {
  82852. /**
  82853. * Gets the edgesRenderer associated with the mesh
  82854. */
  82855. edgesRenderer: Nullable<EdgesRenderer>;
  82856. }
  82857. interface LinesMesh {
  82858. /**
  82859. * Enables the edge rendering mode on the mesh.
  82860. * This mode makes the mesh edges visible
  82861. * @param epsilon defines the maximal distance between two angles to detect a face
  82862. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82863. * @returns the currentAbstractMesh
  82864. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82865. */
  82866. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  82867. }
  82868. interface InstancedLinesMesh {
  82869. /**
  82870. * Enables the edge rendering mode on the mesh.
  82871. * This mode makes the mesh edges visible
  82872. * @param epsilon defines the maximal distance between two angles to detect a face
  82873. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  82874. * @returns the current InstancedLinesMesh
  82875. * @see https://www.babylonjs-playground.com/#19O9TU#0
  82876. */
  82877. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  82878. }
  82879. /**
  82880. * Defines the minimum contract an Edges renderer should follow.
  82881. */
  82882. export interface IEdgesRenderer extends IDisposable {
  82883. /**
  82884. * Gets or sets a boolean indicating if the edgesRenderer is active
  82885. */
  82886. isEnabled: boolean;
  82887. /**
  82888. * Renders the edges of the attached mesh,
  82889. */
  82890. render(): void;
  82891. /**
  82892. * Checks wether or not the edges renderer is ready to render.
  82893. * @return true if ready, otherwise false.
  82894. */
  82895. isReady(): boolean;
  82896. }
  82897. /**
  82898. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  82899. */
  82900. export class EdgesRenderer implements IEdgesRenderer {
  82901. /**
  82902. * Define the size of the edges with an orthographic camera
  82903. */
  82904. edgesWidthScalerForOrthographic: number;
  82905. /**
  82906. * Define the size of the edges with a perspective camera
  82907. */
  82908. edgesWidthScalerForPerspective: number;
  82909. protected _source: AbstractMesh;
  82910. protected _linesPositions: number[];
  82911. protected _linesNormals: number[];
  82912. protected _linesIndices: number[];
  82913. protected _epsilon: number;
  82914. protected _indicesCount: number;
  82915. protected _lineShader: ShaderMaterial;
  82916. protected _ib: DataBuffer;
  82917. protected _buffers: {
  82918. [key: string]: Nullable<VertexBuffer>;
  82919. };
  82920. protected _checkVerticesInsteadOfIndices: boolean;
  82921. private _meshRebuildObserver;
  82922. private _meshDisposeObserver;
  82923. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  82924. isEnabled: boolean;
  82925. /**
  82926. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  82927. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  82928. * @param source Mesh used to create edges
  82929. * @param epsilon sum of angles in adjacency to check for edge
  82930. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  82931. * @param generateEdgesLines - should generate Lines or only prepare resources.
  82932. */
  82933. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  82934. protected _prepareRessources(): void;
  82935. /** @hidden */
  82936. _rebuild(): void;
  82937. /**
  82938. * Releases the required resources for the edges renderer
  82939. */
  82940. dispose(): void;
  82941. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  82942. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  82943. /**
  82944. * Checks if the pair of p0 and p1 is en edge
  82945. * @param faceIndex
  82946. * @param edge
  82947. * @param faceNormals
  82948. * @param p0
  82949. * @param p1
  82950. * @private
  82951. */
  82952. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  82953. /**
  82954. * push line into the position, normal and index buffer
  82955. * @protected
  82956. */
  82957. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  82958. /**
  82959. * Generates lines edges from adjacencjes
  82960. * @private
  82961. */
  82962. _generateEdgesLines(): void;
  82963. /**
  82964. * Checks wether or not the edges renderer is ready to render.
  82965. * @return true if ready, otherwise false.
  82966. */
  82967. isReady(): boolean;
  82968. /**
  82969. * Renders the edges of the attached mesh,
  82970. */
  82971. render(): void;
  82972. }
  82973. /**
  82974. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  82975. */
  82976. export class LineEdgesRenderer extends EdgesRenderer {
  82977. /**
  82978. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  82979. * @param source LineMesh used to generate edges
  82980. * @param epsilon not important (specified angle for edge detection)
  82981. * @param checkVerticesInsteadOfIndices not important for LineMesh
  82982. */
  82983. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  82984. /**
  82985. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  82986. */
  82987. _generateEdgesLines(): void;
  82988. }
  82989. }
  82990. declare module BABYLON {
  82991. /**
  82992. * This represents the object necessary to create a rendering group.
  82993. * This is exclusively used and created by the rendering manager.
  82994. * To modify the behavior, you use the available helpers in your scene or meshes.
  82995. * @hidden
  82996. */
  82997. export class RenderingGroup {
  82998. index: number;
  82999. private static _zeroVector;
  83000. private _scene;
  83001. private _opaqueSubMeshes;
  83002. private _transparentSubMeshes;
  83003. private _alphaTestSubMeshes;
  83004. private _depthOnlySubMeshes;
  83005. private _particleSystems;
  83006. private _spriteManagers;
  83007. private _opaqueSortCompareFn;
  83008. private _alphaTestSortCompareFn;
  83009. private _transparentSortCompareFn;
  83010. private _renderOpaque;
  83011. private _renderAlphaTest;
  83012. private _renderTransparent;
  83013. /** @hidden */
  83014. _edgesRenderers: SmartArray<IEdgesRenderer>;
  83015. onBeforeTransparentRendering: () => void;
  83016. /**
  83017. * Set the opaque sort comparison function.
  83018. * If null the sub meshes will be render in the order they were created
  83019. */
  83020. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83021. /**
  83022. * Set the alpha test sort comparison function.
  83023. * If null the sub meshes will be render in the order they were created
  83024. */
  83025. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83026. /**
  83027. * Set the transparent sort comparison function.
  83028. * If null the sub meshes will be render in the order they were created
  83029. */
  83030. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  83031. /**
  83032. * Creates a new rendering group.
  83033. * @param index The rendering group index
  83034. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  83035. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  83036. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  83037. */
  83038. 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>);
  83039. /**
  83040. * Render all the sub meshes contained in the group.
  83041. * @param customRenderFunction Used to override the default render behaviour of the group.
  83042. * @returns true if rendered some submeshes.
  83043. */
  83044. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  83045. /**
  83046. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  83047. * @param subMeshes The submeshes to render
  83048. */
  83049. private renderOpaqueSorted;
  83050. /**
  83051. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  83052. * @param subMeshes The submeshes to render
  83053. */
  83054. private renderAlphaTestSorted;
  83055. /**
  83056. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  83057. * @param subMeshes The submeshes to render
  83058. */
  83059. private renderTransparentSorted;
  83060. /**
  83061. * Renders the submeshes in a specified order.
  83062. * @param subMeshes The submeshes to sort before render
  83063. * @param sortCompareFn The comparison function use to sort
  83064. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  83065. * @param transparent Specifies to activate blending if true
  83066. */
  83067. private static renderSorted;
  83068. /**
  83069. * Renders the submeshes in the order they were dispatched (no sort applied).
  83070. * @param subMeshes The submeshes to render
  83071. */
  83072. private static renderUnsorted;
  83073. /**
  83074. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83075. * are rendered back to front if in the same alpha index.
  83076. *
  83077. * @param a The first submesh
  83078. * @param b The second submesh
  83079. * @returns The result of the comparison
  83080. */
  83081. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  83082. /**
  83083. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83084. * are rendered back to front.
  83085. *
  83086. * @param a The first submesh
  83087. * @param b The second submesh
  83088. * @returns The result of the comparison
  83089. */
  83090. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  83091. /**
  83092. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  83093. * are rendered front to back (prevent overdraw).
  83094. *
  83095. * @param a The first submesh
  83096. * @param b The second submesh
  83097. * @returns The result of the comparison
  83098. */
  83099. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  83100. /**
  83101. * Resets the different lists of submeshes to prepare a new frame.
  83102. */
  83103. prepare(): void;
  83104. dispose(): void;
  83105. /**
  83106. * Inserts the submesh in its correct queue depending on its material.
  83107. * @param subMesh The submesh to dispatch
  83108. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83109. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83110. */
  83111. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83112. dispatchSprites(spriteManager: ISpriteManager): void;
  83113. dispatchParticles(particleSystem: IParticleSystem): void;
  83114. private _renderParticles;
  83115. private _renderSprites;
  83116. }
  83117. }
  83118. declare module BABYLON {
  83119. /**
  83120. * Interface describing the different options available in the rendering manager
  83121. * regarding Auto Clear between groups.
  83122. */
  83123. export interface IRenderingManagerAutoClearSetup {
  83124. /**
  83125. * Defines whether or not autoclear is enable.
  83126. */
  83127. autoClear: boolean;
  83128. /**
  83129. * Defines whether or not to autoclear the depth buffer.
  83130. */
  83131. depth: boolean;
  83132. /**
  83133. * Defines whether or not to autoclear the stencil buffer.
  83134. */
  83135. stencil: boolean;
  83136. }
  83137. /**
  83138. * This class is used by the onRenderingGroupObservable
  83139. */
  83140. export class RenderingGroupInfo {
  83141. /**
  83142. * The Scene that being rendered
  83143. */
  83144. scene: Scene;
  83145. /**
  83146. * The camera currently used for the rendering pass
  83147. */
  83148. camera: Nullable<Camera>;
  83149. /**
  83150. * The ID of the renderingGroup being processed
  83151. */
  83152. renderingGroupId: number;
  83153. }
  83154. /**
  83155. * This is the manager responsible of all the rendering for meshes sprites and particles.
  83156. * It is enable to manage the different groups as well as the different necessary sort functions.
  83157. * This should not be used directly aside of the few static configurations
  83158. */
  83159. export class RenderingManager {
  83160. /**
  83161. * The max id used for rendering groups (not included)
  83162. */
  83163. static MAX_RENDERINGGROUPS: number;
  83164. /**
  83165. * The min id used for rendering groups (included)
  83166. */
  83167. static MIN_RENDERINGGROUPS: number;
  83168. /**
  83169. * Used to globally prevent autoclearing scenes.
  83170. */
  83171. static AUTOCLEAR: boolean;
  83172. /**
  83173. * @hidden
  83174. */
  83175. _useSceneAutoClearSetup: boolean;
  83176. private _scene;
  83177. private _renderingGroups;
  83178. private _depthStencilBufferAlreadyCleaned;
  83179. private _autoClearDepthStencil;
  83180. private _customOpaqueSortCompareFn;
  83181. private _customAlphaTestSortCompareFn;
  83182. private _customTransparentSortCompareFn;
  83183. private _renderingGroupInfo;
  83184. /**
  83185. * Instantiates a new rendering group for a particular scene
  83186. * @param scene Defines the scene the groups belongs to
  83187. */
  83188. constructor(scene: Scene);
  83189. private _clearDepthStencilBuffer;
  83190. /**
  83191. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  83192. * @hidden
  83193. */
  83194. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  83195. /**
  83196. * Resets the different information of the group to prepare a new frame
  83197. * @hidden
  83198. */
  83199. reset(): void;
  83200. /**
  83201. * Dispose and release the group and its associated resources.
  83202. * @hidden
  83203. */
  83204. dispose(): void;
  83205. /**
  83206. * Clear the info related to rendering groups preventing retention points during dispose.
  83207. */
  83208. freeRenderingGroups(): void;
  83209. private _prepareRenderingGroup;
  83210. /**
  83211. * Add a sprite manager to the rendering manager in order to render it this frame.
  83212. * @param spriteManager Define the sprite manager to render
  83213. */
  83214. dispatchSprites(spriteManager: ISpriteManager): void;
  83215. /**
  83216. * Add a particle system to the rendering manager in order to render it this frame.
  83217. * @param particleSystem Define the particle system to render
  83218. */
  83219. dispatchParticles(particleSystem: IParticleSystem): void;
  83220. /**
  83221. * Add a submesh to the manager in order to render it this frame
  83222. * @param subMesh The submesh to dispatch
  83223. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  83224. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  83225. */
  83226. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  83227. /**
  83228. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83229. * This allowed control for front to back rendering or reversly depending of the special needs.
  83230. *
  83231. * @param renderingGroupId The rendering group id corresponding to its index
  83232. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83233. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83234. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83235. */
  83236. 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;
  83237. /**
  83238. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83239. *
  83240. * @param renderingGroupId The rendering group id corresponding to its index
  83241. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83242. * @param depth Automatically clears depth between groups if true and autoClear is true.
  83243. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  83244. */
  83245. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  83246. /**
  83247. * Gets the current auto clear configuration for one rendering group of the rendering
  83248. * manager.
  83249. * @param index the rendering group index to get the information for
  83250. * @returns The auto clear setup for the requested rendering group
  83251. */
  83252. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  83253. }
  83254. }
  83255. declare module BABYLON {
  83256. /**
  83257. * This Helps creating a texture that will be created from a camera in your scene.
  83258. * It is basically a dynamic texture that could be used to create special effects for instance.
  83259. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  83260. */
  83261. export class RenderTargetTexture extends Texture {
  83262. isCube: boolean;
  83263. /**
  83264. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  83265. */
  83266. static readonly REFRESHRATE_RENDER_ONCE: number;
  83267. /**
  83268. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  83269. */
  83270. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  83271. /**
  83272. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  83273. * the central point of your effect and can save a lot of performances.
  83274. */
  83275. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  83276. /**
  83277. * Use this predicate to dynamically define the list of mesh you want to render.
  83278. * If set, the renderList property will be overwritten.
  83279. */
  83280. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  83281. private _renderList;
  83282. /**
  83283. * Use this list to define the list of mesh you want to render.
  83284. */
  83285. renderList: Nullable<Array<AbstractMesh>>;
  83286. private _hookArray;
  83287. /**
  83288. * Define if particles should be rendered in your texture.
  83289. */
  83290. renderParticles: boolean;
  83291. /**
  83292. * Define if sprites should be rendered in your texture.
  83293. */
  83294. renderSprites: boolean;
  83295. /**
  83296. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  83297. */
  83298. coordinatesMode: number;
  83299. /**
  83300. * Define the camera used to render the texture.
  83301. */
  83302. activeCamera: Nullable<Camera>;
  83303. /**
  83304. * Override the render function of the texture with your own one.
  83305. */
  83306. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  83307. /**
  83308. * Define if camera post processes should be use while rendering the texture.
  83309. */
  83310. useCameraPostProcesses: boolean;
  83311. /**
  83312. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  83313. */
  83314. ignoreCameraViewport: boolean;
  83315. private _postProcessManager;
  83316. private _postProcesses;
  83317. private _resizeObserver;
  83318. /**
  83319. * An event triggered when the texture is unbind.
  83320. */
  83321. onBeforeBindObservable: Observable<RenderTargetTexture>;
  83322. /**
  83323. * An event triggered when the texture is unbind.
  83324. */
  83325. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  83326. private _onAfterUnbindObserver;
  83327. /**
  83328. * Set a after unbind callback in the texture.
  83329. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  83330. */
  83331. onAfterUnbind: () => void;
  83332. /**
  83333. * An event triggered before rendering the texture
  83334. */
  83335. onBeforeRenderObservable: Observable<number>;
  83336. private _onBeforeRenderObserver;
  83337. /**
  83338. * Set a before render callback in the texture.
  83339. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  83340. */
  83341. onBeforeRender: (faceIndex: number) => void;
  83342. /**
  83343. * An event triggered after rendering the texture
  83344. */
  83345. onAfterRenderObservable: Observable<number>;
  83346. private _onAfterRenderObserver;
  83347. /**
  83348. * Set a after render callback in the texture.
  83349. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  83350. */
  83351. onAfterRender: (faceIndex: number) => void;
  83352. /**
  83353. * An event triggered after the texture clear
  83354. */
  83355. onClearObservable: Observable<Engine>;
  83356. private _onClearObserver;
  83357. /**
  83358. * Set a clear callback in the texture.
  83359. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  83360. */
  83361. onClear: (Engine: Engine) => void;
  83362. /**
  83363. * Define the clear color of the Render Target if it should be different from the scene.
  83364. */
  83365. clearColor: Color4;
  83366. protected _size: number | {
  83367. width: number;
  83368. height: number;
  83369. };
  83370. protected _initialSizeParameter: number | {
  83371. width: number;
  83372. height: number;
  83373. } | {
  83374. ratio: number;
  83375. };
  83376. protected _sizeRatio: Nullable<number>;
  83377. /** @hidden */
  83378. _generateMipMaps: boolean;
  83379. protected _renderingManager: RenderingManager;
  83380. /** @hidden */
  83381. _waitingRenderList: string[];
  83382. protected _doNotChangeAspectRatio: boolean;
  83383. protected _currentRefreshId: number;
  83384. protected _refreshRate: number;
  83385. protected _textureMatrix: Matrix;
  83386. protected _samples: number;
  83387. protected _renderTargetOptions: RenderTargetCreationOptions;
  83388. /**
  83389. * Gets render target creation options that were used.
  83390. */
  83391. readonly renderTargetOptions: RenderTargetCreationOptions;
  83392. protected _engine: Engine;
  83393. protected _onRatioRescale(): void;
  83394. /**
  83395. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  83396. * It must define where the camera used to render the texture is set
  83397. */
  83398. boundingBoxPosition: Vector3;
  83399. private _boundingBoxSize;
  83400. /**
  83401. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  83402. * When defined, the cubemap will switch to local mode
  83403. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  83404. * @example https://www.babylonjs-playground.com/#RNASML
  83405. */
  83406. boundingBoxSize: Vector3;
  83407. /**
  83408. * In case the RTT has been created with a depth texture, get the associated
  83409. * depth texture.
  83410. * Otherwise, return null.
  83411. */
  83412. depthStencilTexture: Nullable<InternalTexture>;
  83413. /**
  83414. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  83415. * or used a shadow, depth texture...
  83416. * @param name The friendly name of the texture
  83417. * @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)
  83418. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  83419. * @param generateMipMaps True if mip maps need to be generated after render.
  83420. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  83421. * @param type The type of the buffer in the RTT (int, half float, float...)
  83422. * @param isCube True if a cube texture needs to be created
  83423. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  83424. * @param generateDepthBuffer True to generate a depth buffer
  83425. * @param generateStencilBuffer True to generate a stencil buffer
  83426. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  83427. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  83428. * @param delayAllocation if the texture allocation should be delayed (default: false)
  83429. */
  83430. constructor(name: string, size: number | {
  83431. width: number;
  83432. height: number;
  83433. } | {
  83434. ratio: number;
  83435. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  83436. /**
  83437. * Creates a depth stencil texture.
  83438. * This is only available in WebGL 2 or with the depth texture extension available.
  83439. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  83440. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  83441. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  83442. */
  83443. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  83444. private _processSizeParameter;
  83445. /**
  83446. * Define the number of samples to use in case of MSAA.
  83447. * It defaults to one meaning no MSAA has been enabled.
  83448. */
  83449. samples: number;
  83450. /**
  83451. * Resets the refresh counter of the texture and start bak from scratch.
  83452. * Could be useful to regenerate the texture if it is setup to render only once.
  83453. */
  83454. resetRefreshCounter(): void;
  83455. /**
  83456. * Define the refresh rate of the texture or the rendering frequency.
  83457. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83458. */
  83459. refreshRate: number;
  83460. /**
  83461. * Adds a post process to the render target rendering passes.
  83462. * @param postProcess define the post process to add
  83463. */
  83464. addPostProcess(postProcess: PostProcess): void;
  83465. /**
  83466. * Clear all the post processes attached to the render target
  83467. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  83468. */
  83469. clearPostProcesses(dispose?: boolean): void;
  83470. /**
  83471. * Remove one of the post process from the list of attached post processes to the texture
  83472. * @param postProcess define the post process to remove from the list
  83473. */
  83474. removePostProcess(postProcess: PostProcess): void;
  83475. /** @hidden */
  83476. _shouldRender(): boolean;
  83477. /**
  83478. * Gets the actual render size of the texture.
  83479. * @returns the width of the render size
  83480. */
  83481. getRenderSize(): number;
  83482. /**
  83483. * Gets the actual render width of the texture.
  83484. * @returns the width of the render size
  83485. */
  83486. getRenderWidth(): number;
  83487. /**
  83488. * Gets the actual render height of the texture.
  83489. * @returns the height of the render size
  83490. */
  83491. getRenderHeight(): number;
  83492. /**
  83493. * Get if the texture can be rescaled or not.
  83494. */
  83495. readonly canRescale: boolean;
  83496. /**
  83497. * Resize the texture using a ratio.
  83498. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  83499. */
  83500. scale(ratio: number): void;
  83501. /**
  83502. * Get the texture reflection matrix used to rotate/transform the reflection.
  83503. * @returns the reflection matrix
  83504. */
  83505. getReflectionTextureMatrix(): Matrix;
  83506. /**
  83507. * Resize the texture to a new desired size.
  83508. * Be carrefull as it will recreate all the data in the new texture.
  83509. * @param size Define the new size. It can be:
  83510. * - a number for squared texture,
  83511. * - an object containing { width: number, height: number }
  83512. * - or an object containing a ratio { ratio: number }
  83513. */
  83514. resize(size: number | {
  83515. width: number;
  83516. height: number;
  83517. } | {
  83518. ratio: number;
  83519. }): void;
  83520. /**
  83521. * Renders all the objects from the render list into the texture.
  83522. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  83523. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  83524. */
  83525. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  83526. private _bestReflectionRenderTargetDimension;
  83527. /**
  83528. * @hidden
  83529. * @param faceIndex face index to bind to if this is a cubetexture
  83530. */
  83531. _bindFrameBuffer(faceIndex?: number): void;
  83532. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  83533. private renderToTarget;
  83534. /**
  83535. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  83536. * This allowed control for front to back rendering or reversly depending of the special needs.
  83537. *
  83538. * @param renderingGroupId The rendering group id corresponding to its index
  83539. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  83540. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  83541. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  83542. */
  83543. 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;
  83544. /**
  83545. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  83546. *
  83547. * @param renderingGroupId The rendering group id corresponding to its index
  83548. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  83549. */
  83550. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  83551. /**
  83552. * Clones the texture.
  83553. * @returns the cloned texture
  83554. */
  83555. clone(): RenderTargetTexture;
  83556. /**
  83557. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  83558. * @returns The JSON representation of the texture
  83559. */
  83560. serialize(): any;
  83561. /**
  83562. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  83563. */
  83564. disposeFramebufferObjects(): void;
  83565. /**
  83566. * Dispose the texture and release its associated resources.
  83567. */
  83568. dispose(): void;
  83569. /** @hidden */
  83570. _rebuild(): void;
  83571. /**
  83572. * Clear the info related to rendering groups preventing retention point in material dispose.
  83573. */
  83574. freeRenderingGroups(): void;
  83575. /**
  83576. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  83577. * @returns the view count
  83578. */
  83579. getViewCount(): number;
  83580. }
  83581. }
  83582. declare module BABYLON {
  83583. /**
  83584. * Base class for the main features of a material in Babylon.js
  83585. */
  83586. export class Material implements IAnimatable {
  83587. /**
  83588. * Returns the triangle fill mode
  83589. */
  83590. static readonly TriangleFillMode: number;
  83591. /**
  83592. * Returns the wireframe mode
  83593. */
  83594. static readonly WireFrameFillMode: number;
  83595. /**
  83596. * Returns the point fill mode
  83597. */
  83598. static readonly PointFillMode: number;
  83599. /**
  83600. * Returns the point list draw mode
  83601. */
  83602. static readonly PointListDrawMode: number;
  83603. /**
  83604. * Returns the line list draw mode
  83605. */
  83606. static readonly LineListDrawMode: number;
  83607. /**
  83608. * Returns the line loop draw mode
  83609. */
  83610. static readonly LineLoopDrawMode: number;
  83611. /**
  83612. * Returns the line strip draw mode
  83613. */
  83614. static readonly LineStripDrawMode: number;
  83615. /**
  83616. * Returns the triangle strip draw mode
  83617. */
  83618. static readonly TriangleStripDrawMode: number;
  83619. /**
  83620. * Returns the triangle fan draw mode
  83621. */
  83622. static readonly TriangleFanDrawMode: number;
  83623. /**
  83624. * Stores the clock-wise side orientation
  83625. */
  83626. static readonly ClockWiseSideOrientation: number;
  83627. /**
  83628. * Stores the counter clock-wise side orientation
  83629. */
  83630. static readonly CounterClockWiseSideOrientation: number;
  83631. /**
  83632. * The dirty texture flag value
  83633. */
  83634. static readonly TextureDirtyFlag: number;
  83635. /**
  83636. * The dirty light flag value
  83637. */
  83638. static readonly LightDirtyFlag: number;
  83639. /**
  83640. * The dirty fresnel flag value
  83641. */
  83642. static readonly FresnelDirtyFlag: number;
  83643. /**
  83644. * The dirty attribute flag value
  83645. */
  83646. static readonly AttributesDirtyFlag: number;
  83647. /**
  83648. * The dirty misc flag value
  83649. */
  83650. static readonly MiscDirtyFlag: number;
  83651. /**
  83652. * The all dirty flag value
  83653. */
  83654. static readonly AllDirtyFlag: number;
  83655. /**
  83656. * The ID of the material
  83657. */
  83658. id: string;
  83659. /**
  83660. * Gets or sets the unique id of the material
  83661. */
  83662. uniqueId: number;
  83663. /**
  83664. * The name of the material
  83665. */
  83666. name: string;
  83667. /**
  83668. * Gets or sets user defined metadata
  83669. */
  83670. metadata: any;
  83671. /**
  83672. * For internal use only. Please do not use.
  83673. */
  83674. reservedDataStore: any;
  83675. /**
  83676. * Specifies if the ready state should be checked on each call
  83677. */
  83678. checkReadyOnEveryCall: boolean;
  83679. /**
  83680. * Specifies if the ready state should be checked once
  83681. */
  83682. checkReadyOnlyOnce: boolean;
  83683. /**
  83684. * The state of the material
  83685. */
  83686. state: string;
  83687. /**
  83688. * The alpha value of the material
  83689. */
  83690. protected _alpha: number;
  83691. /**
  83692. * List of inspectable custom properties (used by the Inspector)
  83693. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  83694. */
  83695. inspectableCustomProperties: IInspectable[];
  83696. /**
  83697. * Sets the alpha value of the material
  83698. */
  83699. /**
  83700. * Gets the alpha value of the material
  83701. */
  83702. alpha: number;
  83703. /**
  83704. * Specifies if back face culling is enabled
  83705. */
  83706. protected _backFaceCulling: boolean;
  83707. /**
  83708. * Sets the back-face culling state
  83709. */
  83710. /**
  83711. * Gets the back-face culling state
  83712. */
  83713. backFaceCulling: boolean;
  83714. /**
  83715. * Stores the value for side orientation
  83716. */
  83717. sideOrientation: number;
  83718. /**
  83719. * Callback triggered when the material is compiled
  83720. */
  83721. onCompiled: Nullable<(effect: Effect) => void>;
  83722. /**
  83723. * Callback triggered when an error occurs
  83724. */
  83725. onError: Nullable<(effect: Effect, errors: string) => void>;
  83726. /**
  83727. * Callback triggered to get the render target textures
  83728. */
  83729. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  83730. /**
  83731. * Gets a boolean indicating that current material needs to register RTT
  83732. */
  83733. readonly hasRenderTargetTextures: boolean;
  83734. /**
  83735. * Specifies if the material should be serialized
  83736. */
  83737. doNotSerialize: boolean;
  83738. /**
  83739. * @hidden
  83740. */
  83741. _storeEffectOnSubMeshes: boolean;
  83742. /**
  83743. * Stores the animations for the material
  83744. */
  83745. animations: Nullable<Array<Animation>>;
  83746. /**
  83747. * An event triggered when the material is disposed
  83748. */
  83749. onDisposeObservable: Observable<Material>;
  83750. /**
  83751. * An observer which watches for dispose events
  83752. */
  83753. private _onDisposeObserver;
  83754. private _onUnBindObservable;
  83755. /**
  83756. * Called during a dispose event
  83757. */
  83758. onDispose: () => void;
  83759. private _onBindObservable;
  83760. /**
  83761. * An event triggered when the material is bound
  83762. */
  83763. readonly onBindObservable: Observable<AbstractMesh>;
  83764. /**
  83765. * An observer which watches for bind events
  83766. */
  83767. private _onBindObserver;
  83768. /**
  83769. * Called during a bind event
  83770. */
  83771. onBind: (Mesh: AbstractMesh) => void;
  83772. /**
  83773. * An event triggered when the material is unbound
  83774. */
  83775. readonly onUnBindObservable: Observable<Material>;
  83776. /**
  83777. * Stores the value of the alpha mode
  83778. */
  83779. private _alphaMode;
  83780. /**
  83781. * Sets the value of the alpha mode.
  83782. *
  83783. * | Value | Type | Description |
  83784. * | --- | --- | --- |
  83785. * | 0 | ALPHA_DISABLE | |
  83786. * | 1 | ALPHA_ADD | |
  83787. * | 2 | ALPHA_COMBINE | |
  83788. * | 3 | ALPHA_SUBTRACT | |
  83789. * | 4 | ALPHA_MULTIPLY | |
  83790. * | 5 | ALPHA_MAXIMIZED | |
  83791. * | 6 | ALPHA_ONEONE | |
  83792. * | 7 | ALPHA_PREMULTIPLIED | |
  83793. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  83794. * | 9 | ALPHA_INTERPOLATE | |
  83795. * | 10 | ALPHA_SCREENMODE | |
  83796. *
  83797. */
  83798. /**
  83799. * Gets the value of the alpha mode
  83800. */
  83801. alphaMode: number;
  83802. /**
  83803. * Stores the state of the need depth pre-pass value
  83804. */
  83805. private _needDepthPrePass;
  83806. /**
  83807. * Sets the need depth pre-pass value
  83808. */
  83809. /**
  83810. * Gets the depth pre-pass value
  83811. */
  83812. needDepthPrePass: boolean;
  83813. /**
  83814. * Specifies if depth writing should be disabled
  83815. */
  83816. disableDepthWrite: boolean;
  83817. /**
  83818. * Specifies if depth writing should be forced
  83819. */
  83820. forceDepthWrite: boolean;
  83821. /**
  83822. * Specifies if there should be a separate pass for culling
  83823. */
  83824. separateCullingPass: boolean;
  83825. /**
  83826. * Stores the state specifing if fog should be enabled
  83827. */
  83828. private _fogEnabled;
  83829. /**
  83830. * Sets the state for enabling fog
  83831. */
  83832. /**
  83833. * Gets the value of the fog enabled state
  83834. */
  83835. fogEnabled: boolean;
  83836. /**
  83837. * Stores the size of points
  83838. */
  83839. pointSize: number;
  83840. /**
  83841. * Stores the z offset value
  83842. */
  83843. zOffset: number;
  83844. /**
  83845. * Gets a value specifying if wireframe mode is enabled
  83846. */
  83847. /**
  83848. * Sets the state of wireframe mode
  83849. */
  83850. wireframe: boolean;
  83851. /**
  83852. * Gets the value specifying if point clouds are enabled
  83853. */
  83854. /**
  83855. * Sets the state of point cloud mode
  83856. */
  83857. pointsCloud: boolean;
  83858. /**
  83859. * Gets the material fill mode
  83860. */
  83861. /**
  83862. * Sets the material fill mode
  83863. */
  83864. fillMode: number;
  83865. /**
  83866. * @hidden
  83867. * Stores the effects for the material
  83868. */
  83869. _effect: Nullable<Effect>;
  83870. /**
  83871. * @hidden
  83872. * Specifies if the material was previously ready
  83873. */
  83874. _wasPreviouslyReady: boolean;
  83875. /**
  83876. * Specifies if uniform buffers should be used
  83877. */
  83878. private _useUBO;
  83879. /**
  83880. * Stores a reference to the scene
  83881. */
  83882. private _scene;
  83883. /**
  83884. * Stores the fill mode state
  83885. */
  83886. private _fillMode;
  83887. /**
  83888. * Specifies if the depth write state should be cached
  83889. */
  83890. private _cachedDepthWriteState;
  83891. /**
  83892. * Stores the uniform buffer
  83893. */
  83894. protected _uniformBuffer: UniformBuffer;
  83895. /** @hidden */
  83896. _indexInSceneMaterialArray: number;
  83897. /** @hidden */
  83898. meshMap: Nullable<{
  83899. [id: string]: AbstractMesh | undefined;
  83900. }>;
  83901. /**
  83902. * Creates a material instance
  83903. * @param name defines the name of the material
  83904. * @param scene defines the scene to reference
  83905. * @param doNotAdd specifies if the material should be added to the scene
  83906. */
  83907. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  83908. /**
  83909. * Returns a string representation of the current material
  83910. * @param fullDetails defines a boolean indicating which levels of logging is desired
  83911. * @returns a string with material information
  83912. */
  83913. toString(fullDetails?: boolean): string;
  83914. /**
  83915. * Gets the class name of the material
  83916. * @returns a string with the class name of the material
  83917. */
  83918. getClassName(): string;
  83919. /**
  83920. * Specifies if updates for the material been locked
  83921. */
  83922. readonly isFrozen: boolean;
  83923. /**
  83924. * Locks updates for the material
  83925. */
  83926. freeze(): void;
  83927. /**
  83928. * Unlocks updates for the material
  83929. */
  83930. unfreeze(): void;
  83931. /**
  83932. * Specifies if the material is ready to be used
  83933. * @param mesh defines the mesh to check
  83934. * @param useInstances specifies if instances should be used
  83935. * @returns a boolean indicating if the material is ready to be used
  83936. */
  83937. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  83938. /**
  83939. * Specifies that the submesh is ready to be used
  83940. * @param mesh defines the mesh to check
  83941. * @param subMesh defines which submesh to check
  83942. * @param useInstances specifies that instances should be used
  83943. * @returns a boolean indicating that the submesh is ready or not
  83944. */
  83945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  83946. /**
  83947. * Returns the material effect
  83948. * @returns the effect associated with the material
  83949. */
  83950. getEffect(): Nullable<Effect>;
  83951. /**
  83952. * Returns the current scene
  83953. * @returns a Scene
  83954. */
  83955. getScene(): Scene;
  83956. /**
  83957. * Specifies if the material will require alpha blending
  83958. * @returns a boolean specifying if alpha blending is needed
  83959. */
  83960. needAlphaBlending(): boolean;
  83961. /**
  83962. * Specifies if the mesh will require alpha blending
  83963. * @param mesh defines the mesh to check
  83964. * @returns a boolean specifying if alpha blending is needed for the mesh
  83965. */
  83966. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  83967. /**
  83968. * Specifies if this material should be rendered in alpha test mode
  83969. * @returns a boolean specifying if an alpha test is needed.
  83970. */
  83971. needAlphaTesting(): boolean;
  83972. /**
  83973. * Gets the texture used for the alpha test
  83974. * @returns the texture to use for alpha testing
  83975. */
  83976. getAlphaTestTexture(): Nullable<BaseTexture>;
  83977. /**
  83978. * Marks the material to indicate that it needs to be re-calculated
  83979. */
  83980. markDirty(): void;
  83981. /** @hidden */
  83982. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  83983. /**
  83984. * Binds the material to the mesh
  83985. * @param world defines the world transformation matrix
  83986. * @param mesh defines the mesh to bind the material to
  83987. */
  83988. bind(world: Matrix, mesh?: Mesh): void;
  83989. /**
  83990. * Binds the submesh to the material
  83991. * @param world defines the world transformation matrix
  83992. * @param mesh defines the mesh containing the submesh
  83993. * @param subMesh defines the submesh to bind the material to
  83994. */
  83995. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  83996. /**
  83997. * Binds the world matrix to the material
  83998. * @param world defines the world transformation matrix
  83999. */
  84000. bindOnlyWorldMatrix(world: Matrix): void;
  84001. /**
  84002. * Binds the scene's uniform buffer to the effect.
  84003. * @param effect defines the effect to bind to the scene uniform buffer
  84004. * @param sceneUbo defines the uniform buffer storing scene data
  84005. */
  84006. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84007. /**
  84008. * Binds the view matrix to the effect
  84009. * @param effect defines the effect to bind the view matrix to
  84010. */
  84011. bindView(effect: Effect): void;
  84012. /**
  84013. * Binds the view projection matrix to the effect
  84014. * @param effect defines the effect to bind the view projection matrix to
  84015. */
  84016. bindViewProjection(effect: Effect): void;
  84017. /**
  84018. * Specifies if material alpha testing should be turned on for the mesh
  84019. * @param mesh defines the mesh to check
  84020. */
  84021. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84022. /**
  84023. * Processes to execute after binding the material to a mesh
  84024. * @param mesh defines the rendered mesh
  84025. */
  84026. protected _afterBind(mesh?: Mesh): void;
  84027. /**
  84028. * Unbinds the material from the mesh
  84029. */
  84030. unbind(): void;
  84031. /**
  84032. * Gets the active textures from the material
  84033. * @returns an array of textures
  84034. */
  84035. getActiveTextures(): BaseTexture[];
  84036. /**
  84037. * Specifies if the material uses a texture
  84038. * @param texture defines the texture to check against the material
  84039. * @returns a boolean specifying if the material uses the texture
  84040. */
  84041. hasTexture(texture: BaseTexture): boolean;
  84042. /**
  84043. * Makes a duplicate of the material, and gives it a new name
  84044. * @param name defines the new name for the duplicated material
  84045. * @returns the cloned material
  84046. */
  84047. clone(name: string): Nullable<Material>;
  84048. /**
  84049. * Gets the meshes bound to the material
  84050. * @returns an array of meshes bound to the material
  84051. */
  84052. getBindedMeshes(): AbstractMesh[];
  84053. /**
  84054. * Force shader compilation
  84055. * @param mesh defines the mesh associated with this material
  84056. * @param onCompiled defines a function to execute once the material is compiled
  84057. * @param options defines the options to configure the compilation
  84058. */
  84059. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84060. clipPlane: boolean;
  84061. }>): void;
  84062. /**
  84063. * Force shader compilation
  84064. * @param mesh defines the mesh that will use this material
  84065. * @param options defines additional options for compiling the shaders
  84066. * @returns a promise that resolves when the compilation completes
  84067. */
  84068. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84069. clipPlane: boolean;
  84070. }>): Promise<void>;
  84071. private static readonly _AllDirtyCallBack;
  84072. private static readonly _ImageProcessingDirtyCallBack;
  84073. private static readonly _TextureDirtyCallBack;
  84074. private static readonly _FresnelDirtyCallBack;
  84075. private static readonly _MiscDirtyCallBack;
  84076. private static readonly _LightsDirtyCallBack;
  84077. private static readonly _AttributeDirtyCallBack;
  84078. private static _FresnelAndMiscDirtyCallBack;
  84079. private static _TextureAndMiscDirtyCallBack;
  84080. private static readonly _DirtyCallbackArray;
  84081. private static readonly _RunDirtyCallBacks;
  84082. /**
  84083. * Marks a define in the material to indicate that it needs to be re-computed
  84084. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84085. */
  84086. markAsDirty(flag: number): void;
  84087. /**
  84088. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84089. * @param func defines a function which checks material defines against the submeshes
  84090. */
  84091. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84092. /**
  84093. * Indicates that we need to re-calculated for all submeshes
  84094. */
  84095. protected _markAllSubMeshesAsAllDirty(): void;
  84096. /**
  84097. * Indicates that image processing needs to be re-calculated for all submeshes
  84098. */
  84099. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84100. /**
  84101. * Indicates that textures need to be re-calculated for all submeshes
  84102. */
  84103. protected _markAllSubMeshesAsTexturesDirty(): void;
  84104. /**
  84105. * Indicates that fresnel needs to be re-calculated for all submeshes
  84106. */
  84107. protected _markAllSubMeshesAsFresnelDirty(): void;
  84108. /**
  84109. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84110. */
  84111. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84112. /**
  84113. * Indicates that lights need to be re-calculated for all submeshes
  84114. */
  84115. protected _markAllSubMeshesAsLightsDirty(): void;
  84116. /**
  84117. * Indicates that attributes need to be re-calculated for all submeshes
  84118. */
  84119. protected _markAllSubMeshesAsAttributesDirty(): void;
  84120. /**
  84121. * Indicates that misc needs to be re-calculated for all submeshes
  84122. */
  84123. protected _markAllSubMeshesAsMiscDirty(): void;
  84124. /**
  84125. * Indicates that textures and misc need to be re-calculated for all submeshes
  84126. */
  84127. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84128. /**
  84129. * Disposes the material
  84130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84132. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84133. */
  84134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84135. /** @hidden */
  84136. private releaseVertexArrayObject;
  84137. /**
  84138. * Serializes this material
  84139. * @returns the serialized material object
  84140. */
  84141. serialize(): any;
  84142. /**
  84143. * Creates a material from parsed material data
  84144. * @param parsedMaterial defines parsed material data
  84145. * @param scene defines the hosting scene
  84146. * @param rootUrl defines the root URL to use to load textures
  84147. * @returns a new material
  84148. */
  84149. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84150. }
  84151. }
  84152. declare module BABYLON {
  84153. /**
  84154. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84155. * separate meshes. This can be use to improve performances.
  84156. * @see http://doc.babylonjs.com/how_to/multi_materials
  84157. */
  84158. export class MultiMaterial extends Material {
  84159. private _subMaterials;
  84160. /**
  84161. * Gets or Sets the list of Materials used within the multi material.
  84162. * They need to be ordered according to the submeshes order in the associated mesh
  84163. */
  84164. subMaterials: Nullable<Material>[];
  84165. /**
  84166. * Function used to align with Node.getChildren()
  84167. * @returns the list of Materials used within the multi material
  84168. */
  84169. getChildren(): Nullable<Material>[];
  84170. /**
  84171. * Instantiates a new Multi Material
  84172. * A multi-material is used to apply different materials to different parts of the same object without the need of
  84173. * separate meshes. This can be use to improve performances.
  84174. * @see http://doc.babylonjs.com/how_to/multi_materials
  84175. * @param name Define the name in the scene
  84176. * @param scene Define the scene the material belongs to
  84177. */
  84178. constructor(name: string, scene: Scene);
  84179. private _hookArray;
  84180. /**
  84181. * Get one of the submaterial by its index in the submaterials array
  84182. * @param index The index to look the sub material at
  84183. * @returns The Material if the index has been defined
  84184. */
  84185. getSubMaterial(index: number): Nullable<Material>;
  84186. /**
  84187. * Get the list of active textures for the whole sub materials list.
  84188. * @returns All the textures that will be used during the rendering
  84189. */
  84190. getActiveTextures(): BaseTexture[];
  84191. /**
  84192. * Gets the current class name of the material e.g. "MultiMaterial"
  84193. * Mainly use in serialization.
  84194. * @returns the class name
  84195. */
  84196. getClassName(): string;
  84197. /**
  84198. * Checks if the material is ready to render the requested sub mesh
  84199. * @param mesh Define the mesh the submesh belongs to
  84200. * @param subMesh Define the sub mesh to look readyness for
  84201. * @param useInstances Define whether or not the material is used with instances
  84202. * @returns true if ready, otherwise false
  84203. */
  84204. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84205. /**
  84206. * Clones the current material and its related sub materials
  84207. * @param name Define the name of the newly cloned material
  84208. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  84209. * @returns the cloned material
  84210. */
  84211. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  84212. /**
  84213. * Serializes the materials into a JSON representation.
  84214. * @returns the JSON representation
  84215. */
  84216. serialize(): any;
  84217. /**
  84218. * Dispose the material and release its associated resources
  84219. * @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)
  84220. * @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)
  84221. * @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)
  84222. */
  84223. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  84224. /**
  84225. * Creates a MultiMaterial from parsed MultiMaterial data.
  84226. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  84227. * @param scene defines the hosting scene
  84228. * @returns a new MultiMaterial
  84229. */
  84230. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  84231. }
  84232. }
  84233. declare module BABYLON {
  84234. /**
  84235. * Base class for submeshes
  84236. */
  84237. export class BaseSubMesh {
  84238. /** @hidden */
  84239. _materialDefines: Nullable<MaterialDefines>;
  84240. /** @hidden */
  84241. _materialEffect: Nullable<Effect>;
  84242. /**
  84243. * Gets associated effect
  84244. */
  84245. readonly effect: Nullable<Effect>;
  84246. /**
  84247. * Sets associated effect (effect used to render this submesh)
  84248. * @param effect defines the effect to associate with
  84249. * @param defines defines the set of defines used to compile this effect
  84250. */
  84251. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84252. }
  84253. /**
  84254. * Defines a subdivision inside a mesh
  84255. */
  84256. export class SubMesh extends BaseSubMesh implements ICullable {
  84257. /** the material index to use */
  84258. materialIndex: number;
  84259. /** vertex index start */
  84260. verticesStart: number;
  84261. /** vertices count */
  84262. verticesCount: number;
  84263. /** index start */
  84264. indexStart: number;
  84265. /** indices count */
  84266. indexCount: number;
  84267. /** @hidden */
  84268. _linesIndexCount: number;
  84269. private _mesh;
  84270. private _renderingMesh;
  84271. private _boundingInfo;
  84272. private _linesIndexBuffer;
  84273. /** @hidden */
  84274. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84275. /** @hidden */
  84276. _trianglePlanes: Plane[];
  84277. /** @hidden */
  84278. _lastColliderTransformMatrix: Nullable<Matrix>;
  84279. /** @hidden */
  84280. _renderId: number;
  84281. /** @hidden */
  84282. _alphaIndex: number;
  84283. /** @hidden */
  84284. _distanceToCamera: number;
  84285. /** @hidden */
  84286. _id: number;
  84287. private _currentMaterial;
  84288. /**
  84289. * Add a new submesh to a mesh
  84290. * @param materialIndex defines the material index to use
  84291. * @param verticesStart defines vertex index start
  84292. * @param verticesCount defines vertices count
  84293. * @param indexStart defines index start
  84294. * @param indexCount defines indices count
  84295. * @param mesh defines the parent mesh
  84296. * @param renderingMesh defines an optional rendering mesh
  84297. * @param createBoundingBox defines if bounding box should be created for this submesh
  84298. * @returns the new submesh
  84299. */
  84300. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84301. /**
  84302. * Creates a new submesh
  84303. * @param materialIndex defines the material index to use
  84304. * @param verticesStart defines vertex index start
  84305. * @param verticesCount defines vertices count
  84306. * @param indexStart defines index start
  84307. * @param indexCount defines indices count
  84308. * @param mesh defines the parent mesh
  84309. * @param renderingMesh defines an optional rendering mesh
  84310. * @param createBoundingBox defines if bounding box should be created for this submesh
  84311. */
  84312. constructor(
  84313. /** the material index to use */
  84314. materialIndex: number,
  84315. /** vertex index start */
  84316. verticesStart: number,
  84317. /** vertices count */
  84318. verticesCount: number,
  84319. /** index start */
  84320. indexStart: number,
  84321. /** indices count */
  84322. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84323. /**
  84324. * Returns true if this submesh covers the entire parent mesh
  84325. * @ignorenaming
  84326. */
  84327. readonly IsGlobal: boolean;
  84328. /**
  84329. * Returns the submesh BoudingInfo object
  84330. * @returns current bounding info (or mesh's one if the submesh is global)
  84331. */
  84332. getBoundingInfo(): BoundingInfo;
  84333. /**
  84334. * Sets the submesh BoundingInfo
  84335. * @param boundingInfo defines the new bounding info to use
  84336. * @returns the SubMesh
  84337. */
  84338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84339. /**
  84340. * Returns the mesh of the current submesh
  84341. * @return the parent mesh
  84342. */
  84343. getMesh(): AbstractMesh;
  84344. /**
  84345. * Returns the rendering mesh of the submesh
  84346. * @returns the rendering mesh (could be different from parent mesh)
  84347. */
  84348. getRenderingMesh(): Mesh;
  84349. /**
  84350. * Returns the submesh material
  84351. * @returns null or the current material
  84352. */
  84353. getMaterial(): Nullable<Material>;
  84354. /**
  84355. * Sets a new updated BoundingInfo object to the submesh
  84356. * @param data defines an optional position array to use to determine the bounding info
  84357. * @returns the SubMesh
  84358. */
  84359. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84360. /** @hidden */
  84361. _checkCollision(collider: Collider): boolean;
  84362. /**
  84363. * Updates the submesh BoundingInfo
  84364. * @param world defines the world matrix to use to update the bounding info
  84365. * @returns the submesh
  84366. */
  84367. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84368. /**
  84369. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84370. * @param frustumPlanes defines the frustum planes
  84371. * @returns true if the submesh is intersecting with the frustum
  84372. */
  84373. isInFrustum(frustumPlanes: Plane[]): boolean;
  84374. /**
  84375. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84376. * @param frustumPlanes defines the frustum planes
  84377. * @returns true if the submesh is inside the frustum
  84378. */
  84379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84380. /**
  84381. * Renders the submesh
  84382. * @param enableAlphaMode defines if alpha needs to be used
  84383. * @returns the submesh
  84384. */
  84385. render(enableAlphaMode: boolean): SubMesh;
  84386. /**
  84387. * @hidden
  84388. */
  84389. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84390. /**
  84391. * Checks if the submesh intersects with a ray
  84392. * @param ray defines the ray to test
  84393. * @returns true is the passed ray intersects the submesh bounding box
  84394. */
  84395. canIntersects(ray: Ray): boolean;
  84396. /**
  84397. * Intersects current submesh with a ray
  84398. * @param ray defines the ray to test
  84399. * @param positions defines mesh's positions array
  84400. * @param indices defines mesh's indices array
  84401. * @param fastCheck defines if only bounding info should be used
  84402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84403. * @returns intersection info or null if no intersection
  84404. */
  84405. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84406. /** @hidden */
  84407. private _intersectLines;
  84408. /** @hidden */
  84409. private _intersectUnIndexedLines;
  84410. /** @hidden */
  84411. private _intersectTriangles;
  84412. /** @hidden */
  84413. private _intersectUnIndexedTriangles;
  84414. /** @hidden */
  84415. _rebuild(): void;
  84416. /**
  84417. * Creates a new submesh from the passed mesh
  84418. * @param newMesh defines the new hosting mesh
  84419. * @param newRenderingMesh defines an optional rendering mesh
  84420. * @returns the new submesh
  84421. */
  84422. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84423. /**
  84424. * Release associated resources
  84425. */
  84426. dispose(): void;
  84427. /**
  84428. * Gets the class name
  84429. * @returns the string "SubMesh".
  84430. */
  84431. getClassName(): string;
  84432. /**
  84433. * Creates a new submesh from indices data
  84434. * @param materialIndex the index of the main mesh material
  84435. * @param startIndex the index where to start the copy in the mesh indices array
  84436. * @param indexCount the number of indices to copy then from the startIndex
  84437. * @param mesh the main mesh to create the submesh from
  84438. * @param renderingMesh the optional rendering mesh
  84439. * @returns a new submesh
  84440. */
  84441. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84442. }
  84443. }
  84444. declare module BABYLON {
  84445. /**
  84446. * Class used to represent data loading progression
  84447. */
  84448. export class SceneLoaderFlags {
  84449. private static _ForceFullSceneLoadingForIncremental;
  84450. private static _ShowLoadingScreen;
  84451. private static _CleanBoneMatrixWeights;
  84452. private static _loggingLevel;
  84453. /**
  84454. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  84455. */
  84456. static ForceFullSceneLoadingForIncremental: boolean;
  84457. /**
  84458. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  84459. */
  84460. static ShowLoadingScreen: boolean;
  84461. /**
  84462. * Defines the current logging level (while loading the scene)
  84463. * @ignorenaming
  84464. */
  84465. static loggingLevel: number;
  84466. /**
  84467. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  84468. */
  84469. static CleanBoneMatrixWeights: boolean;
  84470. }
  84471. }
  84472. declare module BABYLON {
  84473. /**
  84474. * Class used to store geometry data (vertex buffers + index buffer)
  84475. */
  84476. export class Geometry implements IGetSetVerticesData {
  84477. /**
  84478. * Gets or sets the ID of the geometry
  84479. */
  84480. id: string;
  84481. /**
  84482. * Gets or sets the unique ID of the geometry
  84483. */
  84484. uniqueId: number;
  84485. /**
  84486. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84487. */
  84488. delayLoadState: number;
  84489. /**
  84490. * Gets the file containing the data to load when running in delay load state
  84491. */
  84492. delayLoadingFile: Nullable<string>;
  84493. /**
  84494. * Callback called when the geometry is updated
  84495. */
  84496. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84497. private _scene;
  84498. private _engine;
  84499. private _meshes;
  84500. private _totalVertices;
  84501. /** @hidden */
  84502. _indices: IndicesArray;
  84503. /** @hidden */
  84504. _vertexBuffers: {
  84505. [key: string]: VertexBuffer;
  84506. };
  84507. private _isDisposed;
  84508. private _extend;
  84509. private _boundingBias;
  84510. /** @hidden */
  84511. _delayInfo: Array<string>;
  84512. private _indexBuffer;
  84513. private _indexBufferIsUpdatable;
  84514. /** @hidden */
  84515. _boundingInfo: Nullable<BoundingInfo>;
  84516. /** @hidden */
  84517. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84518. /** @hidden */
  84519. _softwareSkinningFrameId: number;
  84520. private _vertexArrayObjects;
  84521. private _updatable;
  84522. /** @hidden */
  84523. _positions: Nullable<Vector3[]>;
  84524. /**
  84525. * 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
  84526. */
  84527. /**
  84528. * 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
  84529. */
  84530. boundingBias: Vector2;
  84531. /**
  84532. * Static function used to attach a new empty geometry to a mesh
  84533. * @param mesh defines the mesh to attach the geometry to
  84534. * @returns the new Geometry
  84535. */
  84536. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84537. /**
  84538. * Creates a new geometry
  84539. * @param id defines the unique ID
  84540. * @param scene defines the hosting scene
  84541. * @param vertexData defines the VertexData used to get geometry data
  84542. * @param updatable defines if geometry must be updatable (false by default)
  84543. * @param mesh defines the mesh that will be associated with the geometry
  84544. */
  84545. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84546. /**
  84547. * Gets the current extend of the geometry
  84548. */
  84549. readonly extend: {
  84550. minimum: Vector3;
  84551. maximum: Vector3;
  84552. };
  84553. /**
  84554. * Gets the hosting scene
  84555. * @returns the hosting Scene
  84556. */
  84557. getScene(): Scene;
  84558. /**
  84559. * Gets the hosting engine
  84560. * @returns the hosting Engine
  84561. */
  84562. getEngine(): Engine;
  84563. /**
  84564. * Defines if the geometry is ready to use
  84565. * @returns true if the geometry is ready to be used
  84566. */
  84567. isReady(): boolean;
  84568. /**
  84569. * Gets a value indicating that the geometry should not be serialized
  84570. */
  84571. readonly doNotSerialize: boolean;
  84572. /** @hidden */
  84573. _rebuild(): void;
  84574. /**
  84575. * Affects all geometry data in one call
  84576. * @param vertexData defines the geometry data
  84577. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84578. */
  84579. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84580. /**
  84581. * Set specific vertex data
  84582. * @param kind defines the data kind (Position, normal, etc...)
  84583. * @param data defines the vertex data to use
  84584. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84585. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84586. */
  84587. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84588. /**
  84589. * Removes a specific vertex data
  84590. * @param kind defines the data kind (Position, normal, etc...)
  84591. */
  84592. removeVerticesData(kind: string): void;
  84593. /**
  84594. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84595. * @param buffer defines the vertex buffer to use
  84596. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84597. */
  84598. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84599. /**
  84600. * Update a specific vertex buffer
  84601. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84602. * It will do nothing if the buffer is not updatable
  84603. * @param kind defines the data kind (Position, normal, etc...)
  84604. * @param data defines the data to use
  84605. * @param offset defines the offset in the target buffer where to store the data
  84606. * @param useBytes set to true if the offset is in bytes
  84607. */
  84608. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84609. /**
  84610. * Update a specific vertex buffer
  84611. * This function will create a new buffer if the current one is not updatable
  84612. * @param kind defines the data kind (Position, normal, etc...)
  84613. * @param data defines the data to use
  84614. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84615. */
  84616. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84617. private _updateBoundingInfo;
  84618. /** @hidden */
  84619. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84620. /**
  84621. * Gets total number of vertices
  84622. * @returns the total number of vertices
  84623. */
  84624. getTotalVertices(): number;
  84625. /**
  84626. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84627. * @param kind defines the data kind (Position, normal, etc...)
  84628. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84629. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84630. * @returns a float array containing vertex data
  84631. */
  84632. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84633. /**
  84634. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84635. * @param kind defines the data kind (Position, normal, etc...)
  84636. * @returns true if the vertex buffer with the specified kind is updatable
  84637. */
  84638. isVertexBufferUpdatable(kind: string): boolean;
  84639. /**
  84640. * Gets a specific vertex buffer
  84641. * @param kind defines the data kind (Position, normal, etc...)
  84642. * @returns a VertexBuffer
  84643. */
  84644. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84645. /**
  84646. * Returns all vertex buffers
  84647. * @return an object holding all vertex buffers indexed by kind
  84648. */
  84649. getVertexBuffers(): Nullable<{
  84650. [key: string]: VertexBuffer;
  84651. }>;
  84652. /**
  84653. * Gets a boolean indicating if specific vertex buffer is present
  84654. * @param kind defines the data kind (Position, normal, etc...)
  84655. * @returns true if data is present
  84656. */
  84657. isVerticesDataPresent(kind: string): boolean;
  84658. /**
  84659. * Gets a list of all attached data kinds (Position, normal, etc...)
  84660. * @returns a list of string containing all kinds
  84661. */
  84662. getVerticesDataKinds(): string[];
  84663. /**
  84664. * Update index buffer
  84665. * @param indices defines the indices to store in the index buffer
  84666. * @param offset defines the offset in the target buffer where to store the data
  84667. * @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)
  84668. */
  84669. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84670. /**
  84671. * Creates a new index buffer
  84672. * @param indices defines the indices to store in the index buffer
  84673. * @param totalVertices defines the total number of vertices (could be null)
  84674. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84675. */
  84676. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84677. /**
  84678. * Return the total number of indices
  84679. * @returns the total number of indices
  84680. */
  84681. getTotalIndices(): number;
  84682. /**
  84683. * Gets the index buffer array
  84684. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84685. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84686. * @returns the index buffer array
  84687. */
  84688. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84689. /**
  84690. * Gets the index buffer
  84691. * @return the index buffer
  84692. */
  84693. getIndexBuffer(): Nullable<DataBuffer>;
  84694. /** @hidden */
  84695. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84696. /**
  84697. * Release the associated resources for a specific mesh
  84698. * @param mesh defines the source mesh
  84699. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84700. */
  84701. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84702. /**
  84703. * Apply current geometry to a given mesh
  84704. * @param mesh defines the mesh to apply geometry to
  84705. */
  84706. applyToMesh(mesh: Mesh): void;
  84707. private _updateExtend;
  84708. private _applyToMesh;
  84709. private notifyUpdate;
  84710. /**
  84711. * Load the geometry if it was flagged as delay loaded
  84712. * @param scene defines the hosting scene
  84713. * @param onLoaded defines a callback called when the geometry is loaded
  84714. */
  84715. load(scene: Scene, onLoaded?: () => void): void;
  84716. private _queueLoad;
  84717. /**
  84718. * Invert the geometry to move from a right handed system to a left handed one.
  84719. */
  84720. toLeftHanded(): void;
  84721. /** @hidden */
  84722. _resetPointsArrayCache(): void;
  84723. /** @hidden */
  84724. _generatePointsArray(): boolean;
  84725. /**
  84726. * Gets a value indicating if the geometry is disposed
  84727. * @returns true if the geometry was disposed
  84728. */
  84729. isDisposed(): boolean;
  84730. private _disposeVertexArrayObjects;
  84731. /**
  84732. * Free all associated resources
  84733. */
  84734. dispose(): void;
  84735. /**
  84736. * Clone the current geometry into a new geometry
  84737. * @param id defines the unique ID of the new geometry
  84738. * @returns a new geometry object
  84739. */
  84740. copy(id: string): Geometry;
  84741. /**
  84742. * Serialize the current geometry info (and not the vertices data) into a JSON object
  84743. * @return a JSON representation of the current geometry data (without the vertices data)
  84744. */
  84745. serialize(): any;
  84746. private toNumberArray;
  84747. /**
  84748. * Serialize all vertices data into a JSON oject
  84749. * @returns a JSON representation of the current geometry data
  84750. */
  84751. serializeVerticeData(): any;
  84752. /**
  84753. * Extracts a clone of a mesh geometry
  84754. * @param mesh defines the source mesh
  84755. * @param id defines the unique ID of the new geometry object
  84756. * @returns the new geometry object
  84757. */
  84758. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  84759. /**
  84760. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  84761. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  84762. * Be aware Math.random() could cause collisions, but:
  84763. * "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"
  84764. * @returns a string containing a new GUID
  84765. */
  84766. static RandomId(): string;
  84767. /** @hidden */
  84768. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  84769. private static _CleanMatricesWeights;
  84770. /**
  84771. * Create a new geometry from persisted data (Using .babylon file format)
  84772. * @param parsedVertexData defines the persisted data
  84773. * @param scene defines the hosting scene
  84774. * @param rootUrl defines the root url to use to load assets (like delayed data)
  84775. * @returns the new geometry object
  84776. */
  84777. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  84778. }
  84779. }
  84780. declare module BABYLON {
  84781. /**
  84782. * Define an interface for all classes that will get and set the data on vertices
  84783. */
  84784. export interface IGetSetVerticesData {
  84785. /**
  84786. * Gets a boolean indicating if specific vertex data is present
  84787. * @param kind defines the vertex data kind to use
  84788. * @returns true is data kind is present
  84789. */
  84790. isVerticesDataPresent(kind: string): boolean;
  84791. /**
  84792. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84793. * @param kind defines the data kind (Position, normal, etc...)
  84794. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84795. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84796. * @returns a float array containing vertex data
  84797. */
  84798. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84799. /**
  84800. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84801. * @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.
  84802. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84803. * @returns the indices array or an empty array if the mesh has no geometry
  84804. */
  84805. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84806. /**
  84807. * Set specific vertex data
  84808. * @param kind defines the data kind (Position, normal, etc...)
  84809. * @param data defines the vertex data to use
  84810. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84811. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84812. */
  84813. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  84814. /**
  84815. * Update a specific associated vertex buffer
  84816. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  84817. * - VertexBuffer.PositionKind
  84818. * - VertexBuffer.UVKind
  84819. * - VertexBuffer.UV2Kind
  84820. * - VertexBuffer.UV3Kind
  84821. * - VertexBuffer.UV4Kind
  84822. * - VertexBuffer.UV5Kind
  84823. * - VertexBuffer.UV6Kind
  84824. * - VertexBuffer.ColorKind
  84825. * - VertexBuffer.MatricesIndicesKind
  84826. * - VertexBuffer.MatricesIndicesExtraKind
  84827. * - VertexBuffer.MatricesWeightsKind
  84828. * - VertexBuffer.MatricesWeightsExtraKind
  84829. * @param data defines the data source
  84830. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  84831. * @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)
  84832. */
  84833. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  84834. /**
  84835. * Creates a new index buffer
  84836. * @param indices defines the indices to store in the index buffer
  84837. * @param totalVertices defines the total number of vertices (could be null)
  84838. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84839. */
  84840. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  84841. }
  84842. /**
  84843. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  84844. */
  84845. export class VertexData {
  84846. /**
  84847. * Mesh side orientation : usually the external or front surface
  84848. */
  84849. static readonly FRONTSIDE: number;
  84850. /**
  84851. * Mesh side orientation : usually the internal or back surface
  84852. */
  84853. static readonly BACKSIDE: number;
  84854. /**
  84855. * Mesh side orientation : both internal and external or front and back surfaces
  84856. */
  84857. static readonly DOUBLESIDE: number;
  84858. /**
  84859. * Mesh side orientation : by default, `FRONTSIDE`
  84860. */
  84861. static readonly DEFAULTSIDE: number;
  84862. /**
  84863. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  84864. */
  84865. positions: Nullable<FloatArray>;
  84866. /**
  84867. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  84868. */
  84869. normals: Nullable<FloatArray>;
  84870. /**
  84871. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  84872. */
  84873. tangents: Nullable<FloatArray>;
  84874. /**
  84875. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84876. */
  84877. uvs: Nullable<FloatArray>;
  84878. /**
  84879. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84880. */
  84881. uvs2: Nullable<FloatArray>;
  84882. /**
  84883. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84884. */
  84885. uvs3: Nullable<FloatArray>;
  84886. /**
  84887. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84888. */
  84889. uvs4: Nullable<FloatArray>;
  84890. /**
  84891. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84892. */
  84893. uvs5: Nullable<FloatArray>;
  84894. /**
  84895. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  84896. */
  84897. uvs6: Nullable<FloatArray>;
  84898. /**
  84899. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  84900. */
  84901. colors: Nullable<FloatArray>;
  84902. /**
  84903. * 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).
  84904. */
  84905. matricesIndices: Nullable<FloatArray>;
  84906. /**
  84907. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  84908. */
  84909. matricesWeights: Nullable<FloatArray>;
  84910. /**
  84911. * An array extending the number of possible indices
  84912. */
  84913. matricesIndicesExtra: Nullable<FloatArray>;
  84914. /**
  84915. * An array extending the number of possible weights when the number of indices is extended
  84916. */
  84917. matricesWeightsExtra: Nullable<FloatArray>;
  84918. /**
  84919. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  84920. */
  84921. indices: Nullable<IndicesArray>;
  84922. /**
  84923. * Uses the passed data array to set the set the values for the specified kind of data
  84924. * @param data a linear array of floating numbers
  84925. * @param kind the type of data that is being set, eg positions, colors etc
  84926. */
  84927. set(data: FloatArray, kind: string): void;
  84928. /**
  84929. * Associates the vertexData to the passed Mesh.
  84930. * Sets it as updatable or not (default `false`)
  84931. * @param mesh the mesh the vertexData is applied to
  84932. * @param updatable when used and having the value true allows new data to update the vertexData
  84933. * @returns the VertexData
  84934. */
  84935. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  84936. /**
  84937. * Associates the vertexData to the passed Geometry.
  84938. * Sets it as updatable or not (default `false`)
  84939. * @param geometry the geometry the vertexData is applied to
  84940. * @param updatable when used and having the value true allows new data to update the vertexData
  84941. * @returns VertexData
  84942. */
  84943. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  84944. /**
  84945. * Updates the associated mesh
  84946. * @param mesh the mesh to be updated
  84947. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84948. * @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
  84949. * @returns VertexData
  84950. */
  84951. updateMesh(mesh: Mesh): VertexData;
  84952. /**
  84953. * Updates the associated geometry
  84954. * @param geometry the geometry to be updated
  84955. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  84956. * @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
  84957. * @returns VertexData.
  84958. */
  84959. updateGeometry(geometry: Geometry): VertexData;
  84960. private _applyTo;
  84961. private _update;
  84962. /**
  84963. * Transforms each position and each normal of the vertexData according to the passed Matrix
  84964. * @param matrix the transforming matrix
  84965. * @returns the VertexData
  84966. */
  84967. transform(matrix: Matrix): VertexData;
  84968. /**
  84969. * Merges the passed VertexData into the current one
  84970. * @param other the VertexData to be merged into the current one
  84971. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  84972. * @returns the modified VertexData
  84973. */
  84974. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  84975. private _mergeElement;
  84976. private _validate;
  84977. /**
  84978. * Serializes the VertexData
  84979. * @returns a serialized object
  84980. */
  84981. serialize(): any;
  84982. /**
  84983. * Extracts the vertexData from a mesh
  84984. * @param mesh the mesh from which to extract the VertexData
  84985. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  84986. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84987. * @returns the object VertexData associated to the passed mesh
  84988. */
  84989. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84990. /**
  84991. * Extracts the vertexData from the geometry
  84992. * @param geometry the geometry from which to extract the VertexData
  84993. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  84994. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  84995. * @returns the object VertexData associated to the passed mesh
  84996. */
  84997. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  84998. private static _ExtractFrom;
  84999. /**
  85000. * Creates the VertexData for a Ribbon
  85001. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85002. * * pathArray array of paths, each of which an array of successive Vector3
  85003. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85004. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85005. * * 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
  85006. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85007. * * 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)
  85008. * * 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)
  85009. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85010. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85011. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85012. * @returns the VertexData of the ribbon
  85013. */
  85014. static CreateRibbon(options: {
  85015. pathArray: Vector3[][];
  85016. closeArray?: boolean;
  85017. closePath?: boolean;
  85018. offset?: number;
  85019. sideOrientation?: number;
  85020. frontUVs?: Vector4;
  85021. backUVs?: Vector4;
  85022. invertUV?: boolean;
  85023. uvs?: Vector2[];
  85024. colors?: Color4[];
  85025. }): VertexData;
  85026. /**
  85027. * Creates the VertexData for a box
  85028. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85029. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85030. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85031. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85032. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85033. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85034. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85035. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85036. * * 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)
  85037. * * 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)
  85038. * @returns the VertexData of the box
  85039. */
  85040. static CreateBox(options: {
  85041. size?: number;
  85042. width?: number;
  85043. height?: number;
  85044. depth?: number;
  85045. faceUV?: Vector4[];
  85046. faceColors?: Color4[];
  85047. sideOrientation?: number;
  85048. frontUVs?: Vector4;
  85049. backUVs?: Vector4;
  85050. }): VertexData;
  85051. /**
  85052. * Creates the VertexData for a tiled box
  85053. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85054. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85055. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85056. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85057. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85058. * @returns the VertexData of the box
  85059. */
  85060. static CreateTiledBox(options: {
  85061. pattern?: number;
  85062. width?: number;
  85063. height?: number;
  85064. depth?: number;
  85065. tileSize?: number;
  85066. tileWidth?: number;
  85067. tileHeight?: number;
  85068. alignHorizontal?: number;
  85069. alignVertical?: number;
  85070. faceUV?: Vector4[];
  85071. faceColors?: Color4[];
  85072. sideOrientation?: number;
  85073. }): VertexData;
  85074. /**
  85075. * Creates the VertexData for a tiled plane
  85076. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85077. * * pattern a limited pattern arrangement depending on the number
  85078. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85079. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85080. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85081. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85082. * * 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)
  85083. * * 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)
  85084. * @returns the VertexData of the tiled plane
  85085. */
  85086. static CreateTiledPlane(options: {
  85087. pattern?: number;
  85088. tileSize?: number;
  85089. tileWidth?: number;
  85090. tileHeight?: number;
  85091. size?: number;
  85092. width?: number;
  85093. height?: number;
  85094. alignHorizontal?: number;
  85095. alignVertical?: number;
  85096. sideOrientation?: number;
  85097. frontUVs?: Vector4;
  85098. backUVs?: Vector4;
  85099. }): VertexData;
  85100. /**
  85101. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85102. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85103. * * segments sets the number of horizontal strips optional, default 32
  85104. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85105. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85106. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85107. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85108. * * 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
  85109. * * 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
  85110. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85111. * * 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)
  85112. * * 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)
  85113. * @returns the VertexData of the ellipsoid
  85114. */
  85115. static CreateSphere(options: {
  85116. segments?: number;
  85117. diameter?: number;
  85118. diameterX?: number;
  85119. diameterY?: number;
  85120. diameterZ?: number;
  85121. arc?: number;
  85122. slice?: number;
  85123. sideOrientation?: number;
  85124. frontUVs?: Vector4;
  85125. backUVs?: Vector4;
  85126. }): VertexData;
  85127. /**
  85128. * Creates the VertexData for a cylinder, cone or prism
  85129. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85130. * * height sets the height (y direction) of the cylinder, optional, default 2
  85131. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85132. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85133. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85134. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85135. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85136. * * 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
  85137. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85138. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85139. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85140. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85142. * * 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)
  85143. * * 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)
  85144. * @returns the VertexData of the cylinder, cone or prism
  85145. */
  85146. static CreateCylinder(options: {
  85147. height?: number;
  85148. diameterTop?: number;
  85149. diameterBottom?: number;
  85150. diameter?: number;
  85151. tessellation?: number;
  85152. subdivisions?: number;
  85153. arc?: number;
  85154. faceColors?: Color4[];
  85155. faceUV?: Vector4[];
  85156. hasRings?: boolean;
  85157. enclose?: boolean;
  85158. sideOrientation?: number;
  85159. frontUVs?: Vector4;
  85160. backUVs?: Vector4;
  85161. }): VertexData;
  85162. /**
  85163. * Creates the VertexData for a torus
  85164. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85165. * * diameter the diameter of the torus, optional default 1
  85166. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85167. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85169. * * 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)
  85170. * * 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)
  85171. * @returns the VertexData of the torus
  85172. */
  85173. static CreateTorus(options: {
  85174. diameter?: number;
  85175. thickness?: number;
  85176. tessellation?: number;
  85177. sideOrientation?: number;
  85178. frontUVs?: Vector4;
  85179. backUVs?: Vector4;
  85180. }): VertexData;
  85181. /**
  85182. * Creates the VertexData of the LineSystem
  85183. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85184. * - lines an array of lines, each line being an array of successive Vector3
  85185. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85186. * @returns the VertexData of the LineSystem
  85187. */
  85188. static CreateLineSystem(options: {
  85189. lines: Vector3[][];
  85190. colors?: Nullable<Color4[][]>;
  85191. }): VertexData;
  85192. /**
  85193. * Create the VertexData for a DashedLines
  85194. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85195. * - points an array successive Vector3
  85196. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85197. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85198. * - dashNb the intended total number of dashes, optional, default 200
  85199. * @returns the VertexData for the DashedLines
  85200. */
  85201. static CreateDashedLines(options: {
  85202. points: Vector3[];
  85203. dashSize?: number;
  85204. gapSize?: number;
  85205. dashNb?: number;
  85206. }): VertexData;
  85207. /**
  85208. * Creates the VertexData for a Ground
  85209. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85210. * - width the width (x direction) of the ground, optional, default 1
  85211. * - height the height (z direction) of the ground, optional, default 1
  85212. * - subdivisions the number of subdivisions per side, optional, default 1
  85213. * @returns the VertexData of the Ground
  85214. */
  85215. static CreateGround(options: {
  85216. width?: number;
  85217. height?: number;
  85218. subdivisions?: number;
  85219. subdivisionsX?: number;
  85220. subdivisionsY?: number;
  85221. }): VertexData;
  85222. /**
  85223. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85224. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85225. * * xmin the ground minimum X coordinate, optional, default -1
  85226. * * zmin the ground minimum Z coordinate, optional, default -1
  85227. * * xmax the ground maximum X coordinate, optional, default 1
  85228. * * zmax the ground maximum Z coordinate, optional, default 1
  85229. * * 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}
  85230. * * 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}
  85231. * @returns the VertexData of the TiledGround
  85232. */
  85233. static CreateTiledGround(options: {
  85234. xmin: number;
  85235. zmin: number;
  85236. xmax: number;
  85237. zmax: number;
  85238. subdivisions?: {
  85239. w: number;
  85240. h: number;
  85241. };
  85242. precision?: {
  85243. w: number;
  85244. h: number;
  85245. };
  85246. }): VertexData;
  85247. /**
  85248. * Creates the VertexData of the Ground designed from a heightmap
  85249. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85250. * * width the width (x direction) of the ground
  85251. * * height the height (z direction) of the ground
  85252. * * subdivisions the number of subdivisions per side
  85253. * * minHeight the minimum altitude on the ground, optional, default 0
  85254. * * maxHeight the maximum altitude on the ground, optional default 1
  85255. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85256. * * buffer the array holding the image color data
  85257. * * bufferWidth the width of image
  85258. * * bufferHeight the height of image
  85259. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85260. * @returns the VertexData of the Ground designed from a heightmap
  85261. */
  85262. static CreateGroundFromHeightMap(options: {
  85263. width: number;
  85264. height: number;
  85265. subdivisions: number;
  85266. minHeight: number;
  85267. maxHeight: number;
  85268. colorFilter: Color3;
  85269. buffer: Uint8Array;
  85270. bufferWidth: number;
  85271. bufferHeight: number;
  85272. alphaFilter: number;
  85273. }): VertexData;
  85274. /**
  85275. * Creates the VertexData for a Plane
  85276. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85277. * * size sets the width and height of the plane to the value of size, optional default 1
  85278. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85279. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85280. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85281. * * 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)
  85282. * * 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)
  85283. * @returns the VertexData of the box
  85284. */
  85285. static CreatePlane(options: {
  85286. size?: number;
  85287. width?: number;
  85288. height?: number;
  85289. sideOrientation?: number;
  85290. frontUVs?: Vector4;
  85291. backUVs?: Vector4;
  85292. }): VertexData;
  85293. /**
  85294. * Creates the VertexData of the Disc or regular Polygon
  85295. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85296. * * radius the radius of the disc, optional default 0.5
  85297. * * tessellation the number of polygon sides, optional, default 64
  85298. * * 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
  85299. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85300. * * 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)
  85301. * * 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)
  85302. * @returns the VertexData of the box
  85303. */
  85304. static CreateDisc(options: {
  85305. radius?: number;
  85306. tessellation?: number;
  85307. arc?: number;
  85308. sideOrientation?: number;
  85309. frontUVs?: Vector4;
  85310. backUVs?: Vector4;
  85311. }): VertexData;
  85312. /**
  85313. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85314. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85315. * @param polygon a mesh built from polygonTriangulation.build()
  85316. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85317. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85318. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85319. * @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)
  85320. * @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)
  85321. * @returns the VertexData of the Polygon
  85322. */
  85323. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85324. /**
  85325. * Creates the VertexData of the IcoSphere
  85326. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85327. * * radius the radius of the IcoSphere, optional default 1
  85328. * * radiusX allows stretching in the x direction, optional, default radius
  85329. * * radiusY allows stretching in the y direction, optional, default radius
  85330. * * radiusZ allows stretching in the z direction, optional, default radius
  85331. * * flat when true creates a flat shaded mesh, optional, default true
  85332. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85333. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85334. * * 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)
  85335. * * 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)
  85336. * @returns the VertexData of the IcoSphere
  85337. */
  85338. static CreateIcoSphere(options: {
  85339. radius?: number;
  85340. radiusX?: number;
  85341. radiusY?: number;
  85342. radiusZ?: number;
  85343. flat?: boolean;
  85344. subdivisions?: number;
  85345. sideOrientation?: number;
  85346. frontUVs?: Vector4;
  85347. backUVs?: Vector4;
  85348. }): VertexData;
  85349. /**
  85350. * Creates the VertexData for a Polyhedron
  85351. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85352. * * type provided types are:
  85353. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85354. * * 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)
  85355. * * size the size of the IcoSphere, optional default 1
  85356. * * sizeX allows stretching in the x direction, optional, default size
  85357. * * sizeY allows stretching in the y direction, optional, default size
  85358. * * sizeZ allows stretching in the z direction, optional, default size
  85359. * * 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
  85360. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85361. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85362. * * flat when true creates a flat shaded mesh, optional, default true
  85363. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85365. * * 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)
  85366. * * 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)
  85367. * @returns the VertexData of the Polyhedron
  85368. */
  85369. static CreatePolyhedron(options: {
  85370. type?: number;
  85371. size?: number;
  85372. sizeX?: number;
  85373. sizeY?: number;
  85374. sizeZ?: number;
  85375. custom?: any;
  85376. faceUV?: Vector4[];
  85377. faceColors?: Color4[];
  85378. flat?: boolean;
  85379. sideOrientation?: number;
  85380. frontUVs?: Vector4;
  85381. backUVs?: Vector4;
  85382. }): VertexData;
  85383. /**
  85384. * Creates the VertexData for a TorusKnot
  85385. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85386. * * radius the radius of the torus knot, optional, default 2
  85387. * * tube the thickness of the tube, optional, default 0.5
  85388. * * radialSegments the number of sides on each tube segments, optional, default 32
  85389. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85390. * * p the number of windings around the z axis, optional, default 2
  85391. * * q the number of windings around the x axis, optional, default 3
  85392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85393. * * 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)
  85394. * * 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)
  85395. * @returns the VertexData of the Torus Knot
  85396. */
  85397. static CreateTorusKnot(options: {
  85398. radius?: number;
  85399. tube?: number;
  85400. radialSegments?: number;
  85401. tubularSegments?: number;
  85402. p?: number;
  85403. q?: number;
  85404. sideOrientation?: number;
  85405. frontUVs?: Vector4;
  85406. backUVs?: Vector4;
  85407. }): VertexData;
  85408. /**
  85409. * Compute normals for given positions and indices
  85410. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85411. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85412. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85413. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85414. * * facetNormals : optional array of facet normals (vector3)
  85415. * * facetPositions : optional array of facet positions (vector3)
  85416. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85417. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85418. * * bInfo : optional bounding info, required for facetPartitioning computation
  85419. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85420. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85421. * * useRightHandedSystem: optional boolean to for right handed system computation
  85422. * * depthSort : optional boolean to enable the facet depth sort computation
  85423. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85424. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85425. */
  85426. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85427. facetNormals?: any;
  85428. facetPositions?: any;
  85429. facetPartitioning?: any;
  85430. ratio?: number;
  85431. bInfo?: any;
  85432. bbSize?: Vector3;
  85433. subDiv?: any;
  85434. useRightHandedSystem?: boolean;
  85435. depthSort?: boolean;
  85436. distanceTo?: Vector3;
  85437. depthSortedFacets?: any;
  85438. }): void;
  85439. /** @hidden */
  85440. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85441. /**
  85442. * Applies VertexData created from the imported parameters to the geometry
  85443. * @param parsedVertexData the parsed data from an imported file
  85444. * @param geometry the geometry to apply the VertexData to
  85445. */
  85446. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85447. }
  85448. }
  85449. declare module BABYLON {
  85450. /**
  85451. * Defines a target to use with MorphTargetManager
  85452. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85453. */
  85454. export class MorphTarget implements IAnimatable {
  85455. /** defines the name of the target */
  85456. name: string;
  85457. /**
  85458. * Gets or sets the list of animations
  85459. */
  85460. animations: Animation[];
  85461. private _scene;
  85462. private _positions;
  85463. private _normals;
  85464. private _tangents;
  85465. private _uvs;
  85466. private _influence;
  85467. /**
  85468. * Observable raised when the influence changes
  85469. */
  85470. onInfluenceChanged: Observable<boolean>;
  85471. /** @hidden */
  85472. _onDataLayoutChanged: Observable<void>;
  85473. /**
  85474. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  85475. */
  85476. influence: number;
  85477. /**
  85478. * Gets or sets the id of the morph Target
  85479. */
  85480. id: string;
  85481. private _animationPropertiesOverride;
  85482. /**
  85483. * Gets or sets the animation properties override
  85484. */
  85485. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  85486. /**
  85487. * Creates a new MorphTarget
  85488. * @param name defines the name of the target
  85489. * @param influence defines the influence to use
  85490. * @param scene defines the scene the morphtarget belongs to
  85491. */
  85492. constructor(
  85493. /** defines the name of the target */
  85494. name: string, influence?: number, scene?: Nullable<Scene>);
  85495. /**
  85496. * Gets a boolean defining if the target contains position data
  85497. */
  85498. readonly hasPositions: boolean;
  85499. /**
  85500. * Gets a boolean defining if the target contains normal data
  85501. */
  85502. readonly hasNormals: boolean;
  85503. /**
  85504. * Gets a boolean defining if the target contains tangent data
  85505. */
  85506. readonly hasTangents: boolean;
  85507. /**
  85508. * Gets a boolean defining if the target contains texture coordinates data
  85509. */
  85510. readonly hasUVs: boolean;
  85511. /**
  85512. * Affects position data to this target
  85513. * @param data defines the position data to use
  85514. */
  85515. setPositions(data: Nullable<FloatArray>): void;
  85516. /**
  85517. * Gets the position data stored in this target
  85518. * @returns a FloatArray containing the position data (or null if not present)
  85519. */
  85520. getPositions(): Nullable<FloatArray>;
  85521. /**
  85522. * Affects normal data to this target
  85523. * @param data defines the normal data to use
  85524. */
  85525. setNormals(data: Nullable<FloatArray>): void;
  85526. /**
  85527. * Gets the normal data stored in this target
  85528. * @returns a FloatArray containing the normal data (or null if not present)
  85529. */
  85530. getNormals(): Nullable<FloatArray>;
  85531. /**
  85532. * Affects tangent data to this target
  85533. * @param data defines the tangent data to use
  85534. */
  85535. setTangents(data: Nullable<FloatArray>): void;
  85536. /**
  85537. * Gets the tangent data stored in this target
  85538. * @returns a FloatArray containing the tangent data (or null if not present)
  85539. */
  85540. getTangents(): Nullable<FloatArray>;
  85541. /**
  85542. * Affects texture coordinates data to this target
  85543. * @param data defines the texture coordinates data to use
  85544. */
  85545. setUVs(data: Nullable<FloatArray>): void;
  85546. /**
  85547. * Gets the texture coordinates data stored in this target
  85548. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  85549. */
  85550. getUVs(): Nullable<FloatArray>;
  85551. /**
  85552. * Serializes the current target into a Serialization object
  85553. * @returns the serialized object
  85554. */
  85555. serialize(): any;
  85556. /**
  85557. * Returns the string "MorphTarget"
  85558. * @returns "MorphTarget"
  85559. */
  85560. getClassName(): string;
  85561. /**
  85562. * Creates a new target from serialized data
  85563. * @param serializationObject defines the serialized data to use
  85564. * @returns a new MorphTarget
  85565. */
  85566. static Parse(serializationObject: any): MorphTarget;
  85567. /**
  85568. * Creates a MorphTarget from mesh data
  85569. * @param mesh defines the source mesh
  85570. * @param name defines the name to use for the new target
  85571. * @param influence defines the influence to attach to the target
  85572. * @returns a new MorphTarget
  85573. */
  85574. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  85575. }
  85576. }
  85577. declare module BABYLON {
  85578. /**
  85579. * This class is used to deform meshes using morphing between different targets
  85580. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  85581. */
  85582. export class MorphTargetManager {
  85583. private _targets;
  85584. private _targetInfluenceChangedObservers;
  85585. private _targetDataLayoutChangedObservers;
  85586. private _activeTargets;
  85587. private _scene;
  85588. private _influences;
  85589. private _supportsNormals;
  85590. private _supportsTangents;
  85591. private _supportsUVs;
  85592. private _vertexCount;
  85593. private _uniqueId;
  85594. private _tempInfluences;
  85595. /**
  85596. * Gets or sets a boolean indicating if normals must be morphed
  85597. */
  85598. enableNormalMorphing: boolean;
  85599. /**
  85600. * Gets or sets a boolean indicating if tangents must be morphed
  85601. */
  85602. enableTangentMorphing: boolean;
  85603. /**
  85604. * Gets or sets a boolean indicating if UV must be morphed
  85605. */
  85606. enableUVMorphing: boolean;
  85607. /**
  85608. * Creates a new MorphTargetManager
  85609. * @param scene defines the current scene
  85610. */
  85611. constructor(scene?: Nullable<Scene>);
  85612. /**
  85613. * Gets the unique ID of this manager
  85614. */
  85615. readonly uniqueId: number;
  85616. /**
  85617. * Gets the number of vertices handled by this manager
  85618. */
  85619. readonly vertexCount: number;
  85620. /**
  85621. * Gets a boolean indicating if this manager supports morphing of normals
  85622. */
  85623. readonly supportsNormals: boolean;
  85624. /**
  85625. * Gets a boolean indicating if this manager supports morphing of tangents
  85626. */
  85627. readonly supportsTangents: boolean;
  85628. /**
  85629. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  85630. */
  85631. readonly supportsUVs: boolean;
  85632. /**
  85633. * Gets the number of targets stored in this manager
  85634. */
  85635. readonly numTargets: number;
  85636. /**
  85637. * Gets the number of influencers (ie. the number of targets with influences > 0)
  85638. */
  85639. readonly numInfluencers: number;
  85640. /**
  85641. * Gets the list of influences (one per target)
  85642. */
  85643. readonly influences: Float32Array;
  85644. /**
  85645. * Gets the active target at specified index. An active target is a target with an influence > 0
  85646. * @param index defines the index to check
  85647. * @returns the requested target
  85648. */
  85649. getActiveTarget(index: number): MorphTarget;
  85650. /**
  85651. * Gets the target at specified index
  85652. * @param index defines the index to check
  85653. * @returns the requested target
  85654. */
  85655. getTarget(index: number): MorphTarget;
  85656. /**
  85657. * Add a new target to this manager
  85658. * @param target defines the target to add
  85659. */
  85660. addTarget(target: MorphTarget): void;
  85661. /**
  85662. * Removes a target from the manager
  85663. * @param target defines the target to remove
  85664. */
  85665. removeTarget(target: MorphTarget): void;
  85666. /**
  85667. * Serializes the current manager into a Serialization object
  85668. * @returns the serialized object
  85669. */
  85670. serialize(): any;
  85671. private _syncActiveTargets;
  85672. /**
  85673. * Syncrhonize the targets with all the meshes using this morph target manager
  85674. */
  85675. synchronize(): void;
  85676. /**
  85677. * Creates a new MorphTargetManager from serialized data
  85678. * @param serializationObject defines the serialized data
  85679. * @param scene defines the hosting scene
  85680. * @returns the new MorphTargetManager
  85681. */
  85682. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  85683. }
  85684. }
  85685. declare module BABYLON {
  85686. /**
  85687. * Class used to represent a specific level of detail of a mesh
  85688. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  85689. */
  85690. export class MeshLODLevel {
  85691. /** Defines the distance where this level should star being displayed */
  85692. distance: number;
  85693. /** Defines the mesh to use to render this level */
  85694. mesh: Nullable<Mesh>;
  85695. /**
  85696. * Creates a new LOD level
  85697. * @param distance defines the distance where this level should star being displayed
  85698. * @param mesh defines the mesh to use to render this level
  85699. */
  85700. constructor(
  85701. /** Defines the distance where this level should star being displayed */
  85702. distance: number,
  85703. /** Defines the mesh to use to render this level */
  85704. mesh: Nullable<Mesh>);
  85705. }
  85706. }
  85707. declare module BABYLON {
  85708. /**
  85709. * Mesh representing the gorund
  85710. */
  85711. export class GroundMesh extends Mesh {
  85712. /** If octree should be generated */
  85713. generateOctree: boolean;
  85714. private _heightQuads;
  85715. /** @hidden */
  85716. _subdivisionsX: number;
  85717. /** @hidden */
  85718. _subdivisionsY: number;
  85719. /** @hidden */
  85720. _width: number;
  85721. /** @hidden */
  85722. _height: number;
  85723. /** @hidden */
  85724. _minX: number;
  85725. /** @hidden */
  85726. _maxX: number;
  85727. /** @hidden */
  85728. _minZ: number;
  85729. /** @hidden */
  85730. _maxZ: number;
  85731. constructor(name: string, scene: Scene);
  85732. /**
  85733. * "GroundMesh"
  85734. * @returns "GroundMesh"
  85735. */
  85736. getClassName(): string;
  85737. /**
  85738. * The minimum of x and y subdivisions
  85739. */
  85740. readonly subdivisions: number;
  85741. /**
  85742. * X subdivisions
  85743. */
  85744. readonly subdivisionsX: number;
  85745. /**
  85746. * Y subdivisions
  85747. */
  85748. readonly subdivisionsY: number;
  85749. /**
  85750. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  85751. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  85752. * @param chunksCount the number of subdivisions for x and y
  85753. * @param octreeBlocksSize (Default: 32)
  85754. */
  85755. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  85756. /**
  85757. * Returns a height (y) value in the Worl system :
  85758. * the ground altitude at the coordinates (x, z) expressed in the World system.
  85759. * @param x x coordinate
  85760. * @param z z coordinate
  85761. * @returns the ground y position if (x, z) are outside the ground surface.
  85762. */
  85763. getHeightAtCoordinates(x: number, z: number): number;
  85764. /**
  85765. * Returns a normalized vector (Vector3) orthogonal to the ground
  85766. * at the ground coordinates (x, z) expressed in the World system.
  85767. * @param x x coordinate
  85768. * @param z z coordinate
  85769. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  85770. */
  85771. getNormalAtCoordinates(x: number, z: number): Vector3;
  85772. /**
  85773. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  85774. * at the ground coordinates (x, z) expressed in the World system.
  85775. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  85776. * @param x x coordinate
  85777. * @param z z coordinate
  85778. * @param ref vector to store the result
  85779. * @returns the GroundMesh.
  85780. */
  85781. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  85782. /**
  85783. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  85784. * if the ground has been updated.
  85785. * This can be used in the render loop.
  85786. * @returns the GroundMesh.
  85787. */
  85788. updateCoordinateHeights(): GroundMesh;
  85789. private _getFacetAt;
  85790. private _initHeightQuads;
  85791. private _computeHeightQuads;
  85792. /**
  85793. * Serializes this ground mesh
  85794. * @param serializationObject object to write serialization to
  85795. */
  85796. serialize(serializationObject: any): void;
  85797. /**
  85798. * Parses a serialized ground mesh
  85799. * @param parsedMesh the serialized mesh
  85800. * @param scene the scene to create the ground mesh in
  85801. * @returns the created ground mesh
  85802. */
  85803. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  85804. }
  85805. }
  85806. declare module BABYLON {
  85807. /**
  85808. * Interface for Physics-Joint data
  85809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85810. */
  85811. export interface PhysicsJointData {
  85812. /**
  85813. * The main pivot of the joint
  85814. */
  85815. mainPivot?: Vector3;
  85816. /**
  85817. * The connected pivot of the joint
  85818. */
  85819. connectedPivot?: Vector3;
  85820. /**
  85821. * The main axis of the joint
  85822. */
  85823. mainAxis?: Vector3;
  85824. /**
  85825. * The connected axis of the joint
  85826. */
  85827. connectedAxis?: Vector3;
  85828. /**
  85829. * The collision of the joint
  85830. */
  85831. collision?: boolean;
  85832. /**
  85833. * Native Oimo/Cannon/Energy data
  85834. */
  85835. nativeParams?: any;
  85836. }
  85837. /**
  85838. * This is a holder class for the physics joint created by the physics plugin
  85839. * It holds a set of functions to control the underlying joint
  85840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85841. */
  85842. export class PhysicsJoint {
  85843. /**
  85844. * The type of the physics joint
  85845. */
  85846. type: number;
  85847. /**
  85848. * The data for the physics joint
  85849. */
  85850. jointData: PhysicsJointData;
  85851. private _physicsJoint;
  85852. protected _physicsPlugin: IPhysicsEnginePlugin;
  85853. /**
  85854. * Initializes the physics joint
  85855. * @param type The type of the physics joint
  85856. * @param jointData The data for the physics joint
  85857. */
  85858. constructor(
  85859. /**
  85860. * The type of the physics joint
  85861. */
  85862. type: number,
  85863. /**
  85864. * The data for the physics joint
  85865. */
  85866. jointData: PhysicsJointData);
  85867. /**
  85868. * Gets the physics joint
  85869. */
  85870. /**
  85871. * Sets the physics joint
  85872. */
  85873. physicsJoint: any;
  85874. /**
  85875. * Sets the physics plugin
  85876. */
  85877. physicsPlugin: IPhysicsEnginePlugin;
  85878. /**
  85879. * Execute a function that is physics-plugin specific.
  85880. * @param {Function} func the function that will be executed.
  85881. * It accepts two parameters: the physics world and the physics joint
  85882. */
  85883. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  85884. /**
  85885. * Distance-Joint type
  85886. */
  85887. static DistanceJoint: number;
  85888. /**
  85889. * Hinge-Joint type
  85890. */
  85891. static HingeJoint: number;
  85892. /**
  85893. * Ball-and-Socket joint type
  85894. */
  85895. static BallAndSocketJoint: number;
  85896. /**
  85897. * Wheel-Joint type
  85898. */
  85899. static WheelJoint: number;
  85900. /**
  85901. * Slider-Joint type
  85902. */
  85903. static SliderJoint: number;
  85904. /**
  85905. * Prismatic-Joint type
  85906. */
  85907. static PrismaticJoint: number;
  85908. /**
  85909. * Universal-Joint type
  85910. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  85911. */
  85912. static UniversalJoint: number;
  85913. /**
  85914. * Hinge-Joint 2 type
  85915. */
  85916. static Hinge2Joint: number;
  85917. /**
  85918. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  85919. */
  85920. static PointToPointJoint: number;
  85921. /**
  85922. * Spring-Joint type
  85923. */
  85924. static SpringJoint: number;
  85925. /**
  85926. * Lock-Joint type
  85927. */
  85928. static LockJoint: number;
  85929. }
  85930. /**
  85931. * A class representing a physics distance joint
  85932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85933. */
  85934. export class DistanceJoint extends PhysicsJoint {
  85935. /**
  85936. *
  85937. * @param jointData The data for the Distance-Joint
  85938. */
  85939. constructor(jointData: DistanceJointData);
  85940. /**
  85941. * Update the predefined distance.
  85942. * @param maxDistance The maximum preferred distance
  85943. * @param minDistance The minimum preferred distance
  85944. */
  85945. updateDistance(maxDistance: number, minDistance?: number): void;
  85946. }
  85947. /**
  85948. * Represents a Motor-Enabled Joint
  85949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85950. */
  85951. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  85952. /**
  85953. * Initializes the Motor-Enabled Joint
  85954. * @param type The type of the joint
  85955. * @param jointData The physica joint data for the joint
  85956. */
  85957. constructor(type: number, jointData: PhysicsJointData);
  85958. /**
  85959. * Set the motor values.
  85960. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85961. * @param force the force to apply
  85962. * @param maxForce max force for this motor.
  85963. */
  85964. setMotor(force?: number, maxForce?: number): void;
  85965. /**
  85966. * Set the motor's limits.
  85967. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85968. * @param upperLimit The upper limit of the motor
  85969. * @param lowerLimit The lower limit of the motor
  85970. */
  85971. setLimit(upperLimit: number, lowerLimit?: number): void;
  85972. }
  85973. /**
  85974. * This class represents a single physics Hinge-Joint
  85975. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  85976. */
  85977. export class HingeJoint extends MotorEnabledJoint {
  85978. /**
  85979. * Initializes the Hinge-Joint
  85980. * @param jointData The joint data for the Hinge-Joint
  85981. */
  85982. constructor(jointData: PhysicsJointData);
  85983. /**
  85984. * Set the motor values.
  85985. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85986. * @param {number} force the force to apply
  85987. * @param {number} maxForce max force for this motor.
  85988. */
  85989. setMotor(force?: number, maxForce?: number): void;
  85990. /**
  85991. * Set the motor's limits.
  85992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  85993. * @param upperLimit The upper limit of the motor
  85994. * @param lowerLimit The lower limit of the motor
  85995. */
  85996. setLimit(upperLimit: number, lowerLimit?: number): void;
  85997. }
  85998. /**
  85999. * This class represents a dual hinge physics joint (same as wheel joint)
  86000. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86001. */
  86002. export class Hinge2Joint extends MotorEnabledJoint {
  86003. /**
  86004. * Initializes the Hinge2-Joint
  86005. * @param jointData The joint data for the Hinge2-Joint
  86006. */
  86007. constructor(jointData: PhysicsJointData);
  86008. /**
  86009. * Set the motor values.
  86010. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86011. * @param {number} targetSpeed the speed the motor is to reach
  86012. * @param {number} maxForce max force for this motor.
  86013. * @param {motorIndex} the motor's index, 0 or 1.
  86014. */
  86015. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  86016. /**
  86017. * Set the motor limits.
  86018. * Attention, this function is plugin specific. Engines won't react 100% the same.
  86019. * @param {number} upperLimit the upper limit
  86020. * @param {number} lowerLimit lower limit
  86021. * @param {motorIndex} the motor's index, 0 or 1.
  86022. */
  86023. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86024. }
  86025. /**
  86026. * Interface for a motor enabled joint
  86027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86028. */
  86029. export interface IMotorEnabledJoint {
  86030. /**
  86031. * Physics joint
  86032. */
  86033. physicsJoint: any;
  86034. /**
  86035. * Sets the motor of the motor-enabled joint
  86036. * @param force The force of the motor
  86037. * @param maxForce The maximum force of the motor
  86038. * @param motorIndex The index of the motor
  86039. */
  86040. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  86041. /**
  86042. * Sets the limit of the motor
  86043. * @param upperLimit The upper limit of the motor
  86044. * @param lowerLimit The lower limit of the motor
  86045. * @param motorIndex The index of the motor
  86046. */
  86047. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86048. }
  86049. /**
  86050. * Joint data for a Distance-Joint
  86051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86052. */
  86053. export interface DistanceJointData extends PhysicsJointData {
  86054. /**
  86055. * Max distance the 2 joint objects can be apart
  86056. */
  86057. maxDistance: number;
  86058. }
  86059. /**
  86060. * Joint data from a spring joint
  86061. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86062. */
  86063. export interface SpringJointData extends PhysicsJointData {
  86064. /**
  86065. * Length of the spring
  86066. */
  86067. length: number;
  86068. /**
  86069. * Stiffness of the spring
  86070. */
  86071. stiffness: number;
  86072. /**
  86073. * Damping of the spring
  86074. */
  86075. damping: number;
  86076. /** this callback will be called when applying the force to the impostors. */
  86077. forceApplicationCallback: () => void;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /**
  86082. * Holds the data for the raycast result
  86083. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86084. */
  86085. export class PhysicsRaycastResult {
  86086. private _hasHit;
  86087. private _hitDistance;
  86088. private _hitNormalWorld;
  86089. private _hitPointWorld;
  86090. private _rayFromWorld;
  86091. private _rayToWorld;
  86092. /**
  86093. * Gets if there was a hit
  86094. */
  86095. readonly hasHit: boolean;
  86096. /**
  86097. * Gets the distance from the hit
  86098. */
  86099. readonly hitDistance: number;
  86100. /**
  86101. * Gets the hit normal/direction in the world
  86102. */
  86103. readonly hitNormalWorld: Vector3;
  86104. /**
  86105. * Gets the hit point in the world
  86106. */
  86107. readonly hitPointWorld: Vector3;
  86108. /**
  86109. * Gets the ray "start point" of the ray in the world
  86110. */
  86111. readonly rayFromWorld: Vector3;
  86112. /**
  86113. * Gets the ray "end point" of the ray in the world
  86114. */
  86115. readonly rayToWorld: Vector3;
  86116. /**
  86117. * Sets the hit data (normal & point in world space)
  86118. * @param hitNormalWorld defines the normal in world space
  86119. * @param hitPointWorld defines the point in world space
  86120. */
  86121. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  86122. /**
  86123. * Sets the distance from the start point to the hit point
  86124. * @param distance
  86125. */
  86126. setHitDistance(distance: number): void;
  86127. /**
  86128. * Calculates the distance manually
  86129. */
  86130. calculateHitDistance(): void;
  86131. /**
  86132. * Resets all the values to default
  86133. * @param from The from point on world space
  86134. * @param to The to point on world space
  86135. */
  86136. reset(from?: Vector3, to?: Vector3): void;
  86137. }
  86138. /**
  86139. * Interface for the size containing width and height
  86140. */
  86141. interface IXYZ {
  86142. /**
  86143. * X
  86144. */
  86145. x: number;
  86146. /**
  86147. * Y
  86148. */
  86149. y: number;
  86150. /**
  86151. * Z
  86152. */
  86153. z: number;
  86154. }
  86155. }
  86156. declare module BABYLON {
  86157. /**
  86158. * Interface used to describe a physics joint
  86159. */
  86160. export interface PhysicsImpostorJoint {
  86161. /** Defines the main impostor to which the joint is linked */
  86162. mainImpostor: PhysicsImpostor;
  86163. /** Defines the impostor that is connected to the main impostor using this joint */
  86164. connectedImpostor: PhysicsImpostor;
  86165. /** Defines the joint itself */
  86166. joint: PhysicsJoint;
  86167. }
  86168. /** @hidden */
  86169. export interface IPhysicsEnginePlugin {
  86170. world: any;
  86171. name: string;
  86172. setGravity(gravity: Vector3): void;
  86173. setTimeStep(timeStep: number): void;
  86174. getTimeStep(): number;
  86175. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  86176. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86177. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  86178. generatePhysicsBody(impostor: PhysicsImpostor): void;
  86179. removePhysicsBody(impostor: PhysicsImpostor): void;
  86180. generateJoint(joint: PhysicsImpostorJoint): void;
  86181. removeJoint(joint: PhysicsImpostorJoint): void;
  86182. isSupported(): boolean;
  86183. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  86184. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  86185. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86186. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  86187. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86188. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  86189. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  86190. getBodyMass(impostor: PhysicsImpostor): number;
  86191. getBodyFriction(impostor: PhysicsImpostor): number;
  86192. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  86193. getBodyRestitution(impostor: PhysicsImpostor): number;
  86194. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  86195. getBodyPressure?(impostor: PhysicsImpostor): number;
  86196. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  86197. getBodyStiffness?(impostor: PhysicsImpostor): number;
  86198. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  86199. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  86200. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  86201. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  86202. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  86203. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86204. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  86205. sleepBody(impostor: PhysicsImpostor): void;
  86206. wakeUpBody(impostor: PhysicsImpostor): void;
  86207. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86208. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  86209. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  86210. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  86211. getRadius(impostor: PhysicsImpostor): number;
  86212. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  86213. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  86214. dispose(): void;
  86215. }
  86216. /**
  86217. * Interface used to define a physics engine
  86218. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  86219. */
  86220. export interface IPhysicsEngine {
  86221. /**
  86222. * Gets the gravity vector used by the simulation
  86223. */
  86224. gravity: Vector3;
  86225. /**
  86226. * Sets the gravity vector used by the simulation
  86227. * @param gravity defines the gravity vector to use
  86228. */
  86229. setGravity(gravity: Vector3): void;
  86230. /**
  86231. * Set the time step of the physics engine.
  86232. * Default is 1/60.
  86233. * To slow it down, enter 1/600 for example.
  86234. * To speed it up, 1/30
  86235. * @param newTimeStep the new timestep to apply to this world.
  86236. */
  86237. setTimeStep(newTimeStep: number): void;
  86238. /**
  86239. * Get the time step of the physics engine.
  86240. * @returns the current time step
  86241. */
  86242. getTimeStep(): number;
  86243. /**
  86244. * Release all resources
  86245. */
  86246. dispose(): void;
  86247. /**
  86248. * Gets the name of the current physics plugin
  86249. * @returns the name of the plugin
  86250. */
  86251. getPhysicsPluginName(): string;
  86252. /**
  86253. * Adding a new impostor for the impostor tracking.
  86254. * This will be done by the impostor itself.
  86255. * @param impostor the impostor to add
  86256. */
  86257. addImpostor(impostor: PhysicsImpostor): void;
  86258. /**
  86259. * Remove an impostor from the engine.
  86260. * This impostor and its mesh will not longer be updated by the physics engine.
  86261. * @param impostor the impostor to remove
  86262. */
  86263. removeImpostor(impostor: PhysicsImpostor): void;
  86264. /**
  86265. * Add a joint to the physics engine
  86266. * @param mainImpostor defines the main impostor to which the joint is added.
  86267. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  86268. * @param joint defines the joint that will connect both impostors.
  86269. */
  86270. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86271. /**
  86272. * Removes a joint from the simulation
  86273. * @param mainImpostor defines the impostor used with the joint
  86274. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  86275. * @param joint defines the joint to remove
  86276. */
  86277. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  86278. /**
  86279. * Gets the current plugin used to run the simulation
  86280. * @returns current plugin
  86281. */
  86282. getPhysicsPlugin(): IPhysicsEnginePlugin;
  86283. /**
  86284. * Gets the list of physic impostors
  86285. * @returns an array of PhysicsImpostor
  86286. */
  86287. getImpostors(): Array<PhysicsImpostor>;
  86288. /**
  86289. * Gets the impostor for a physics enabled object
  86290. * @param object defines the object impersonated by the impostor
  86291. * @returns the PhysicsImpostor or null if not found
  86292. */
  86293. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86294. /**
  86295. * Gets the impostor for a physics body object
  86296. * @param body defines physics body used by the impostor
  86297. * @returns the PhysicsImpostor or null if not found
  86298. */
  86299. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  86300. /**
  86301. * Does a raycast in the physics world
  86302. * @param from when should the ray start?
  86303. * @param to when should the ray end?
  86304. * @returns PhysicsRaycastResult
  86305. */
  86306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  86307. /**
  86308. * Called by the scene. No need to call it.
  86309. * @param delta defines the timespam between frames
  86310. */
  86311. _step(delta: number): void;
  86312. }
  86313. }
  86314. declare module BABYLON {
  86315. /**
  86316. * The interface for the physics imposter parameters
  86317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86318. */
  86319. export interface PhysicsImpostorParameters {
  86320. /**
  86321. * The mass of the physics imposter
  86322. */
  86323. mass: number;
  86324. /**
  86325. * The friction of the physics imposter
  86326. */
  86327. friction?: number;
  86328. /**
  86329. * The coefficient of restitution of the physics imposter
  86330. */
  86331. restitution?: number;
  86332. /**
  86333. * The native options of the physics imposter
  86334. */
  86335. nativeOptions?: any;
  86336. /**
  86337. * Specifies if the parent should be ignored
  86338. */
  86339. ignoreParent?: boolean;
  86340. /**
  86341. * Specifies if bi-directional transformations should be disabled
  86342. */
  86343. disableBidirectionalTransformation?: boolean;
  86344. /**
  86345. * The pressure inside the physics imposter, soft object only
  86346. */
  86347. pressure?: number;
  86348. /**
  86349. * The stiffness the physics imposter, soft object only
  86350. */
  86351. stiffness?: number;
  86352. /**
  86353. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  86354. */
  86355. velocityIterations?: number;
  86356. /**
  86357. * The number of iterations used in maintaining consistent vertex positions, soft object only
  86358. */
  86359. positionIterations?: number;
  86360. /**
  86361. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  86362. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  86363. * Add to fix multiple points
  86364. */
  86365. fixedPoints?: number;
  86366. /**
  86367. * The collision margin around a soft object
  86368. */
  86369. margin?: number;
  86370. /**
  86371. * The collision margin around a soft object
  86372. */
  86373. damping?: number;
  86374. /**
  86375. * The path for a rope based on an extrusion
  86376. */
  86377. path?: any;
  86378. /**
  86379. * The shape of an extrusion used for a rope based on an extrusion
  86380. */
  86381. shape?: any;
  86382. }
  86383. /**
  86384. * Interface for a physics-enabled object
  86385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86386. */
  86387. export interface IPhysicsEnabledObject {
  86388. /**
  86389. * The position of the physics-enabled object
  86390. */
  86391. position: Vector3;
  86392. /**
  86393. * The rotation of the physics-enabled object
  86394. */
  86395. rotationQuaternion: Nullable<Quaternion>;
  86396. /**
  86397. * The scale of the physics-enabled object
  86398. */
  86399. scaling: Vector3;
  86400. /**
  86401. * The rotation of the physics-enabled object
  86402. */
  86403. rotation?: Vector3;
  86404. /**
  86405. * The parent of the physics-enabled object
  86406. */
  86407. parent?: any;
  86408. /**
  86409. * The bounding info of the physics-enabled object
  86410. * @returns The bounding info of the physics-enabled object
  86411. */
  86412. getBoundingInfo(): BoundingInfo;
  86413. /**
  86414. * Computes the world matrix
  86415. * @param force Specifies if the world matrix should be computed by force
  86416. * @returns A world matrix
  86417. */
  86418. computeWorldMatrix(force: boolean): Matrix;
  86419. /**
  86420. * Gets the world matrix
  86421. * @returns A world matrix
  86422. */
  86423. getWorldMatrix?(): Matrix;
  86424. /**
  86425. * Gets the child meshes
  86426. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  86427. * @returns An array of abstract meshes
  86428. */
  86429. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  86430. /**
  86431. * Gets the vertex data
  86432. * @param kind The type of vertex data
  86433. * @returns A nullable array of numbers, or a float32 array
  86434. */
  86435. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  86436. /**
  86437. * Gets the indices from the mesh
  86438. * @returns A nullable array of index arrays
  86439. */
  86440. getIndices?(): Nullable<IndicesArray>;
  86441. /**
  86442. * Gets the scene from the mesh
  86443. * @returns the indices array or null
  86444. */
  86445. getScene?(): Scene;
  86446. /**
  86447. * Gets the absolute position from the mesh
  86448. * @returns the absolute position
  86449. */
  86450. getAbsolutePosition(): Vector3;
  86451. /**
  86452. * Gets the absolute pivot point from the mesh
  86453. * @returns the absolute pivot point
  86454. */
  86455. getAbsolutePivotPoint(): Vector3;
  86456. /**
  86457. * Rotates the mesh
  86458. * @param axis The axis of rotation
  86459. * @param amount The amount of rotation
  86460. * @param space The space of the rotation
  86461. * @returns The rotation transform node
  86462. */
  86463. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  86464. /**
  86465. * Translates the mesh
  86466. * @param axis The axis of translation
  86467. * @param distance The distance of translation
  86468. * @param space The space of the translation
  86469. * @returns The transform node
  86470. */
  86471. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  86472. /**
  86473. * Sets the absolute position of the mesh
  86474. * @param absolutePosition The absolute position of the mesh
  86475. * @returns The transform node
  86476. */
  86477. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86478. /**
  86479. * Gets the class name of the mesh
  86480. * @returns The class name
  86481. */
  86482. getClassName(): string;
  86483. }
  86484. /**
  86485. * Represents a physics imposter
  86486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  86487. */
  86488. export class PhysicsImpostor {
  86489. /**
  86490. * The physics-enabled object used as the physics imposter
  86491. */
  86492. object: IPhysicsEnabledObject;
  86493. /**
  86494. * The type of the physics imposter
  86495. */
  86496. type: number;
  86497. private _options;
  86498. private _scene?;
  86499. /**
  86500. * The default object size of the imposter
  86501. */
  86502. static DEFAULT_OBJECT_SIZE: Vector3;
  86503. /**
  86504. * The identity quaternion of the imposter
  86505. */
  86506. static IDENTITY_QUATERNION: Quaternion;
  86507. /** @hidden */
  86508. _pluginData: any;
  86509. private _physicsEngine;
  86510. private _physicsBody;
  86511. private _bodyUpdateRequired;
  86512. private _onBeforePhysicsStepCallbacks;
  86513. private _onAfterPhysicsStepCallbacks;
  86514. /** @hidden */
  86515. _onPhysicsCollideCallbacks: Array<{
  86516. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  86517. otherImpostors: Array<PhysicsImpostor>;
  86518. }>;
  86519. private _deltaPosition;
  86520. private _deltaRotation;
  86521. private _deltaRotationConjugated;
  86522. /** @hidden */
  86523. _isFromLine: boolean;
  86524. private _parent;
  86525. private _isDisposed;
  86526. private static _tmpVecs;
  86527. private static _tmpQuat;
  86528. /**
  86529. * Specifies if the physics imposter is disposed
  86530. */
  86531. readonly isDisposed: boolean;
  86532. /**
  86533. * Gets the mass of the physics imposter
  86534. */
  86535. mass: number;
  86536. /**
  86537. * Gets the coefficient of friction
  86538. */
  86539. /**
  86540. * Sets the coefficient of friction
  86541. */
  86542. friction: number;
  86543. /**
  86544. * Gets the coefficient of restitution
  86545. */
  86546. /**
  86547. * Sets the coefficient of restitution
  86548. */
  86549. restitution: number;
  86550. /**
  86551. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  86552. */
  86553. /**
  86554. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  86555. */
  86556. pressure: number;
  86557. /**
  86558. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86559. */
  86560. /**
  86561. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  86562. */
  86563. stiffness: number;
  86564. /**
  86565. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86566. */
  86567. /**
  86568. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  86569. */
  86570. velocityIterations: number;
  86571. /**
  86572. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86573. */
  86574. /**
  86575. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  86576. */
  86577. positionIterations: number;
  86578. /**
  86579. * The unique id of the physics imposter
  86580. * set by the physics engine when adding this impostor to the array
  86581. */
  86582. uniqueId: number;
  86583. /**
  86584. * @hidden
  86585. */
  86586. soft: boolean;
  86587. /**
  86588. * @hidden
  86589. */
  86590. segments: number;
  86591. private _joints;
  86592. /**
  86593. * Initializes the physics imposter
  86594. * @param object The physics-enabled object used as the physics imposter
  86595. * @param type The type of the physics imposter
  86596. * @param _options The options for the physics imposter
  86597. * @param _scene The Babylon scene
  86598. */
  86599. constructor(
  86600. /**
  86601. * The physics-enabled object used as the physics imposter
  86602. */
  86603. object: IPhysicsEnabledObject,
  86604. /**
  86605. * The type of the physics imposter
  86606. */
  86607. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  86608. /**
  86609. * This function will completly initialize this impostor.
  86610. * It will create a new body - but only if this mesh has no parent.
  86611. * If it has, this impostor will not be used other than to define the impostor
  86612. * of the child mesh.
  86613. * @hidden
  86614. */
  86615. _init(): void;
  86616. private _getPhysicsParent;
  86617. /**
  86618. * Should a new body be generated.
  86619. * @returns boolean specifying if body initialization is required
  86620. */
  86621. isBodyInitRequired(): boolean;
  86622. /**
  86623. * Sets the updated scaling
  86624. * @param updated Specifies if the scaling is updated
  86625. */
  86626. setScalingUpdated(): void;
  86627. /**
  86628. * Force a regeneration of this or the parent's impostor's body.
  86629. * Use under cautious - This will remove all joints already implemented.
  86630. */
  86631. forceUpdate(): void;
  86632. /**
  86633. * Gets the body that holds this impostor. Either its own, or its parent.
  86634. */
  86635. /**
  86636. * Set the physics body. Used mainly by the physics engine/plugin
  86637. */
  86638. physicsBody: any;
  86639. /**
  86640. * Get the parent of the physics imposter
  86641. * @returns Physics imposter or null
  86642. */
  86643. /**
  86644. * Sets the parent of the physics imposter
  86645. */
  86646. parent: Nullable<PhysicsImpostor>;
  86647. /**
  86648. * Resets the update flags
  86649. */
  86650. resetUpdateFlags(): void;
  86651. /**
  86652. * Gets the object extend size
  86653. * @returns the object extend size
  86654. */
  86655. getObjectExtendSize(): Vector3;
  86656. /**
  86657. * Gets the object center
  86658. * @returns The object center
  86659. */
  86660. getObjectCenter(): Vector3;
  86661. /**
  86662. * Get a specific parametes from the options parameter
  86663. * @param paramName The object parameter name
  86664. * @returns The object parameter
  86665. */
  86666. getParam(paramName: string): any;
  86667. /**
  86668. * Sets a specific parameter in the options given to the physics plugin
  86669. * @param paramName The parameter name
  86670. * @param value The value of the parameter
  86671. */
  86672. setParam(paramName: string, value: number): void;
  86673. /**
  86674. * Specifically change the body's mass option. Won't recreate the physics body object
  86675. * @param mass The mass of the physics imposter
  86676. */
  86677. setMass(mass: number): void;
  86678. /**
  86679. * Gets the linear velocity
  86680. * @returns linear velocity or null
  86681. */
  86682. getLinearVelocity(): Nullable<Vector3>;
  86683. /**
  86684. * Sets the linear velocity
  86685. * @param velocity linear velocity or null
  86686. */
  86687. setLinearVelocity(velocity: Nullable<Vector3>): void;
  86688. /**
  86689. * Gets the angular velocity
  86690. * @returns angular velocity or null
  86691. */
  86692. getAngularVelocity(): Nullable<Vector3>;
  86693. /**
  86694. * Sets the angular velocity
  86695. * @param velocity The velocity or null
  86696. */
  86697. setAngularVelocity(velocity: Nullable<Vector3>): void;
  86698. /**
  86699. * Execute a function with the physics plugin native code
  86700. * Provide a function the will have two variables - the world object and the physics body object
  86701. * @param func The function to execute with the physics plugin native code
  86702. */
  86703. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  86704. /**
  86705. * Register a function that will be executed before the physics world is stepping forward
  86706. * @param func The function to execute before the physics world is stepped forward
  86707. */
  86708. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86709. /**
  86710. * Unregister a function that will be executed before the physics world is stepping forward
  86711. * @param func The function to execute before the physics world is stepped forward
  86712. */
  86713. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86714. /**
  86715. * Register a function that will be executed after the physics step
  86716. * @param func The function to execute after physics step
  86717. */
  86718. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86719. /**
  86720. * Unregisters a function that will be executed after the physics step
  86721. * @param func The function to execute after physics step
  86722. */
  86723. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  86724. /**
  86725. * register a function that will be executed when this impostor collides against a different body
  86726. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  86727. * @param func Callback that is executed on collision
  86728. */
  86729. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  86730. /**
  86731. * Unregisters the physics imposter on contact
  86732. * @param collideAgainst The physics object to collide against
  86733. * @param func Callback to execute on collision
  86734. */
  86735. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  86736. private _tmpQuat;
  86737. private _tmpQuat2;
  86738. /**
  86739. * Get the parent rotation
  86740. * @returns The parent rotation
  86741. */
  86742. getParentsRotation(): Quaternion;
  86743. /**
  86744. * this function is executed by the physics engine.
  86745. */
  86746. beforeStep: () => void;
  86747. /**
  86748. * this function is executed by the physics engine
  86749. */
  86750. afterStep: () => void;
  86751. /**
  86752. * Legacy collision detection event support
  86753. */
  86754. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  86755. /**
  86756. * event and body object due to cannon's event-based architecture.
  86757. */
  86758. onCollide: (e: {
  86759. body: any;
  86760. }) => void;
  86761. /**
  86762. * Apply a force
  86763. * @param force The force to apply
  86764. * @param contactPoint The contact point for the force
  86765. * @returns The physics imposter
  86766. */
  86767. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86768. /**
  86769. * Apply an impulse
  86770. * @param force The impulse force
  86771. * @param contactPoint The contact point for the impulse force
  86772. * @returns The physics imposter
  86773. */
  86774. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  86775. /**
  86776. * A help function to create a joint
  86777. * @param otherImpostor A physics imposter used to create a joint
  86778. * @param jointType The type of joint
  86779. * @param jointData The data for the joint
  86780. * @returns The physics imposter
  86781. */
  86782. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  86783. /**
  86784. * Add a joint to this impostor with a different impostor
  86785. * @param otherImpostor A physics imposter used to add a joint
  86786. * @param joint The joint to add
  86787. * @returns The physics imposter
  86788. */
  86789. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  86790. /**
  86791. * Add an anchor to a cloth impostor
  86792. * @param otherImpostor rigid impostor to anchor to
  86793. * @param width ratio across width from 0 to 1
  86794. * @param height ratio up height from 0 to 1
  86795. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  86796. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  86797. * @returns impostor the soft imposter
  86798. */
  86799. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86800. /**
  86801. * Add a hook to a rope impostor
  86802. * @param otherImpostor rigid impostor to anchor to
  86803. * @param length ratio across rope from 0 to 1
  86804. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  86805. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  86806. * @returns impostor the rope imposter
  86807. */
  86808. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  86809. /**
  86810. * Will keep this body still, in a sleep mode.
  86811. * @returns the physics imposter
  86812. */
  86813. sleep(): PhysicsImpostor;
  86814. /**
  86815. * Wake the body up.
  86816. * @returns The physics imposter
  86817. */
  86818. wakeUp(): PhysicsImpostor;
  86819. /**
  86820. * Clones the physics imposter
  86821. * @param newObject The physics imposter clones to this physics-enabled object
  86822. * @returns A nullable physics imposter
  86823. */
  86824. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  86825. /**
  86826. * Disposes the physics imposter
  86827. */
  86828. dispose(): void;
  86829. /**
  86830. * Sets the delta position
  86831. * @param position The delta position amount
  86832. */
  86833. setDeltaPosition(position: Vector3): void;
  86834. /**
  86835. * Sets the delta rotation
  86836. * @param rotation The delta rotation amount
  86837. */
  86838. setDeltaRotation(rotation: Quaternion): void;
  86839. /**
  86840. * Gets the box size of the physics imposter and stores the result in the input parameter
  86841. * @param result Stores the box size
  86842. * @returns The physics imposter
  86843. */
  86844. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  86845. /**
  86846. * Gets the radius of the physics imposter
  86847. * @returns Radius of the physics imposter
  86848. */
  86849. getRadius(): number;
  86850. /**
  86851. * Sync a bone with this impostor
  86852. * @param bone The bone to sync to the impostor.
  86853. * @param boneMesh The mesh that the bone is influencing.
  86854. * @param jointPivot The pivot of the joint / bone in local space.
  86855. * @param distToJoint Optional distance from the impostor to the joint.
  86856. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86857. */
  86858. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  86859. /**
  86860. * Sync impostor to a bone
  86861. * @param bone The bone that the impostor will be synced to.
  86862. * @param boneMesh The mesh that the bone is influencing.
  86863. * @param jointPivot The pivot of the joint / bone in local space.
  86864. * @param distToJoint Optional distance from the impostor to the joint.
  86865. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  86866. * @param boneAxis Optional vector3 axis the bone is aligned with
  86867. */
  86868. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  86869. /**
  86870. * No-Imposter type
  86871. */
  86872. static NoImpostor: number;
  86873. /**
  86874. * Sphere-Imposter type
  86875. */
  86876. static SphereImpostor: number;
  86877. /**
  86878. * Box-Imposter type
  86879. */
  86880. static BoxImpostor: number;
  86881. /**
  86882. * Plane-Imposter type
  86883. */
  86884. static PlaneImpostor: number;
  86885. /**
  86886. * Mesh-imposter type
  86887. */
  86888. static MeshImpostor: number;
  86889. /**
  86890. * Capsule-Impostor type (Ammo.js plugin only)
  86891. */
  86892. static CapsuleImpostor: number;
  86893. /**
  86894. * Cylinder-Imposter type
  86895. */
  86896. static CylinderImpostor: number;
  86897. /**
  86898. * Particle-Imposter type
  86899. */
  86900. static ParticleImpostor: number;
  86901. /**
  86902. * Heightmap-Imposter type
  86903. */
  86904. static HeightmapImpostor: number;
  86905. /**
  86906. * ConvexHull-Impostor type (Ammo.js plugin only)
  86907. */
  86908. static ConvexHullImpostor: number;
  86909. /**
  86910. * Rope-Imposter type
  86911. */
  86912. static RopeImpostor: number;
  86913. /**
  86914. * Cloth-Imposter type
  86915. */
  86916. static ClothImpostor: number;
  86917. /**
  86918. * Softbody-Imposter type
  86919. */
  86920. static SoftbodyImpostor: number;
  86921. }
  86922. }
  86923. declare module BABYLON {
  86924. /**
  86925. * @hidden
  86926. **/
  86927. export class _CreationDataStorage {
  86928. closePath?: boolean;
  86929. closeArray?: boolean;
  86930. idx: number[];
  86931. dashSize: number;
  86932. gapSize: number;
  86933. path3D: Path3D;
  86934. pathArray: Vector3[][];
  86935. arc: number;
  86936. radius: number;
  86937. cap: number;
  86938. tessellation: number;
  86939. }
  86940. /**
  86941. * @hidden
  86942. **/
  86943. class _InstanceDataStorage {
  86944. visibleInstances: any;
  86945. batchCache: _InstancesBatch;
  86946. instancesBufferSize: number;
  86947. instancesBuffer: Nullable<Buffer>;
  86948. instancesData: Float32Array;
  86949. overridenInstanceCount: number;
  86950. isFrozen: boolean;
  86951. previousBatch: Nullable<_InstancesBatch>;
  86952. hardwareInstancedRendering: boolean;
  86953. sideOrientation: number;
  86954. }
  86955. /**
  86956. * @hidden
  86957. **/
  86958. export class _InstancesBatch {
  86959. mustReturn: boolean;
  86960. visibleInstances: Nullable<InstancedMesh[]>[];
  86961. renderSelf: boolean[];
  86962. hardwareInstancedRendering: boolean[];
  86963. }
  86964. /**
  86965. * Class used to represent renderable models
  86966. */
  86967. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  86968. /**
  86969. * Mesh side orientation : usually the external or front surface
  86970. */
  86971. static readonly FRONTSIDE: number;
  86972. /**
  86973. * Mesh side orientation : usually the internal or back surface
  86974. */
  86975. static readonly BACKSIDE: number;
  86976. /**
  86977. * Mesh side orientation : both internal and external or front and back surfaces
  86978. */
  86979. static readonly DOUBLESIDE: number;
  86980. /**
  86981. * Mesh side orientation : by default, `FRONTSIDE`
  86982. */
  86983. static readonly DEFAULTSIDE: number;
  86984. /**
  86985. * Mesh cap setting : no cap
  86986. */
  86987. static readonly NO_CAP: number;
  86988. /**
  86989. * Mesh cap setting : one cap at the beginning of the mesh
  86990. */
  86991. static readonly CAP_START: number;
  86992. /**
  86993. * Mesh cap setting : one cap at the end of the mesh
  86994. */
  86995. static readonly CAP_END: number;
  86996. /**
  86997. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  86998. */
  86999. static readonly CAP_ALL: number;
  87000. /**
  87001. * Mesh pattern setting : no flip or rotate
  87002. */
  87003. static readonly NO_FLIP: number;
  87004. /**
  87005. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  87006. */
  87007. static readonly FLIP_TILE: number;
  87008. /**
  87009. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  87010. */
  87011. static readonly ROTATE_TILE: number;
  87012. /**
  87013. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  87014. */
  87015. static readonly FLIP_ROW: number;
  87016. /**
  87017. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  87018. */
  87019. static readonly ROTATE_ROW: number;
  87020. /**
  87021. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  87022. */
  87023. static readonly FLIP_N_ROTATE_TILE: number;
  87024. /**
  87025. * Mesh pattern setting : rotate pattern and rotate
  87026. */
  87027. static readonly FLIP_N_ROTATE_ROW: number;
  87028. /**
  87029. * Mesh tile positioning : part tiles same on left/right or top/bottom
  87030. */
  87031. static readonly CENTER: number;
  87032. /**
  87033. * Mesh tile positioning : part tiles on left
  87034. */
  87035. static readonly LEFT: number;
  87036. /**
  87037. * Mesh tile positioning : part tiles on right
  87038. */
  87039. static readonly RIGHT: number;
  87040. /**
  87041. * Mesh tile positioning : part tiles on top
  87042. */
  87043. static readonly TOP: number;
  87044. /**
  87045. * Mesh tile positioning : part tiles on bottom
  87046. */
  87047. static readonly BOTTOM: number;
  87048. /**
  87049. * Gets the default side orientation.
  87050. * @param orientation the orientation to value to attempt to get
  87051. * @returns the default orientation
  87052. * @hidden
  87053. */
  87054. static _GetDefaultSideOrientation(orientation?: number): number;
  87055. private _internalMeshDataInfo;
  87056. /**
  87057. * An event triggered before rendering the mesh
  87058. */
  87059. readonly onBeforeRenderObservable: Observable<Mesh>;
  87060. /**
  87061. * An event triggered before binding the mesh
  87062. */
  87063. readonly onBeforeBindObservable: Observable<Mesh>;
  87064. /**
  87065. * An event triggered after rendering the mesh
  87066. */
  87067. readonly onAfterRenderObservable: Observable<Mesh>;
  87068. /**
  87069. * An event triggered before drawing the mesh
  87070. */
  87071. readonly onBeforeDrawObservable: Observable<Mesh>;
  87072. private _onBeforeDrawObserver;
  87073. /**
  87074. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  87075. */
  87076. onBeforeDraw: () => void;
  87077. /**
  87078. * Gets the delay loading state of the mesh (when delay loading is turned on)
  87079. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  87080. */
  87081. delayLoadState: number;
  87082. /**
  87083. * Gets the list of instances created from this mesh
  87084. * it is not supposed to be modified manually.
  87085. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  87086. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87087. */
  87088. instances: InstancedMesh[];
  87089. /**
  87090. * Gets the file containing delay loading data for this mesh
  87091. */
  87092. delayLoadingFile: string;
  87093. /** @hidden */
  87094. _binaryInfo: any;
  87095. /**
  87096. * User defined function used to change how LOD level selection is done
  87097. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  87098. */
  87099. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  87100. /**
  87101. * Gets or sets the morph target manager
  87102. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  87103. */
  87104. morphTargetManager: Nullable<MorphTargetManager>;
  87105. /** @hidden */
  87106. _creationDataStorage: Nullable<_CreationDataStorage>;
  87107. /** @hidden */
  87108. _geometry: Nullable<Geometry>;
  87109. /** @hidden */
  87110. _delayInfo: Array<string>;
  87111. /** @hidden */
  87112. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  87113. /** @hidden */
  87114. _instanceDataStorage: _InstanceDataStorage;
  87115. private _effectiveMaterial;
  87116. /** @hidden */
  87117. _shouldGenerateFlatShading: boolean;
  87118. /** @hidden */
  87119. _originalBuilderSideOrientation: number;
  87120. /**
  87121. * Use this property to change the original side orientation defined at construction time
  87122. */
  87123. overrideMaterialSideOrientation: Nullable<number>;
  87124. /**
  87125. * Gets the source mesh (the one used to clone this one from)
  87126. */
  87127. readonly source: Nullable<Mesh>;
  87128. /**
  87129. * Gets or sets a boolean indicating that this mesh does not use index buffer
  87130. */
  87131. isUnIndexed: boolean;
  87132. /**
  87133. * @constructor
  87134. * @param name The value used by scene.getMeshByName() to do a lookup.
  87135. * @param scene The scene to add this mesh to.
  87136. * @param parent The parent of this mesh, if it has one
  87137. * @param source An optional Mesh from which geometry is shared, cloned.
  87138. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  87139. * When false, achieved by calling a clone(), also passing False.
  87140. * This will make creation of children, recursive.
  87141. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  87142. */
  87143. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  87144. /**
  87145. * Gets the class name
  87146. * @returns the string "Mesh".
  87147. */
  87148. getClassName(): string;
  87149. /** @hidden */
  87150. readonly _isMesh: boolean;
  87151. /**
  87152. * Returns a description of this mesh
  87153. * @param fullDetails define if full details about this mesh must be used
  87154. * @returns a descriptive string representing this mesh
  87155. */
  87156. toString(fullDetails?: boolean): string;
  87157. /** @hidden */
  87158. _unBindEffect(): void;
  87159. /**
  87160. * Gets a boolean indicating if this mesh has LOD
  87161. */
  87162. readonly hasLODLevels: boolean;
  87163. /**
  87164. * Gets the list of MeshLODLevel associated with the current mesh
  87165. * @returns an array of MeshLODLevel
  87166. */
  87167. getLODLevels(): MeshLODLevel[];
  87168. private _sortLODLevels;
  87169. /**
  87170. * Add a mesh as LOD level triggered at the given distance.
  87171. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87172. * @param distance The distance from the center of the object to show this level
  87173. * @param mesh The mesh to be added as LOD level (can be null)
  87174. * @return This mesh (for chaining)
  87175. */
  87176. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  87177. /**
  87178. * Returns the LOD level mesh at the passed distance or null if not found.
  87179. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87180. * @param distance The distance from the center of the object to show this level
  87181. * @returns a Mesh or `null`
  87182. */
  87183. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  87184. /**
  87185. * Remove a mesh from the LOD array
  87186. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87187. * @param mesh defines the mesh to be removed
  87188. * @return This mesh (for chaining)
  87189. */
  87190. removeLODLevel(mesh: Mesh): Mesh;
  87191. /**
  87192. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  87193. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  87194. * @param camera defines the camera to use to compute distance
  87195. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  87196. * @return This mesh (for chaining)
  87197. */
  87198. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  87199. /**
  87200. * Gets the mesh internal Geometry object
  87201. */
  87202. readonly geometry: Nullable<Geometry>;
  87203. /**
  87204. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  87205. * @returns the total number of vertices
  87206. */
  87207. getTotalVertices(): number;
  87208. /**
  87209. * Returns the content of an associated vertex buffer
  87210. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87211. * - VertexBuffer.PositionKind
  87212. * - VertexBuffer.UVKind
  87213. * - VertexBuffer.UV2Kind
  87214. * - VertexBuffer.UV3Kind
  87215. * - VertexBuffer.UV4Kind
  87216. * - VertexBuffer.UV5Kind
  87217. * - VertexBuffer.UV6Kind
  87218. * - VertexBuffer.ColorKind
  87219. * - VertexBuffer.MatricesIndicesKind
  87220. * - VertexBuffer.MatricesIndicesExtraKind
  87221. * - VertexBuffer.MatricesWeightsKind
  87222. * - VertexBuffer.MatricesWeightsExtraKind
  87223. * @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
  87224. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  87225. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  87226. */
  87227. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87228. /**
  87229. * Returns the mesh VertexBuffer object from the requested `kind`
  87230. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87231. * - VertexBuffer.PositionKind
  87232. * - VertexBuffer.NormalKind
  87233. * - VertexBuffer.UVKind
  87234. * - VertexBuffer.UV2Kind
  87235. * - VertexBuffer.UV3Kind
  87236. * - VertexBuffer.UV4Kind
  87237. * - VertexBuffer.UV5Kind
  87238. * - VertexBuffer.UV6Kind
  87239. * - VertexBuffer.ColorKind
  87240. * - VertexBuffer.MatricesIndicesKind
  87241. * - VertexBuffer.MatricesIndicesExtraKind
  87242. * - VertexBuffer.MatricesWeightsKind
  87243. * - VertexBuffer.MatricesWeightsExtraKind
  87244. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  87245. */
  87246. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87247. /**
  87248. * Tests if a specific vertex buffer is associated with this mesh
  87249. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87250. * - VertexBuffer.PositionKind
  87251. * - VertexBuffer.NormalKind
  87252. * - VertexBuffer.UVKind
  87253. * - VertexBuffer.UV2Kind
  87254. * - VertexBuffer.UV3Kind
  87255. * - VertexBuffer.UV4Kind
  87256. * - VertexBuffer.UV5Kind
  87257. * - VertexBuffer.UV6Kind
  87258. * - VertexBuffer.ColorKind
  87259. * - VertexBuffer.MatricesIndicesKind
  87260. * - VertexBuffer.MatricesIndicesExtraKind
  87261. * - VertexBuffer.MatricesWeightsKind
  87262. * - VertexBuffer.MatricesWeightsExtraKind
  87263. * @returns a boolean
  87264. */
  87265. isVerticesDataPresent(kind: string): boolean;
  87266. /**
  87267. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  87268. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  87269. * - VertexBuffer.PositionKind
  87270. * - VertexBuffer.UVKind
  87271. * - VertexBuffer.UV2Kind
  87272. * - VertexBuffer.UV3Kind
  87273. * - VertexBuffer.UV4Kind
  87274. * - VertexBuffer.UV5Kind
  87275. * - VertexBuffer.UV6Kind
  87276. * - VertexBuffer.ColorKind
  87277. * - VertexBuffer.MatricesIndicesKind
  87278. * - VertexBuffer.MatricesIndicesExtraKind
  87279. * - VertexBuffer.MatricesWeightsKind
  87280. * - VertexBuffer.MatricesWeightsExtraKind
  87281. * @returns a boolean
  87282. */
  87283. isVertexBufferUpdatable(kind: string): boolean;
  87284. /**
  87285. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  87286. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  87287. * - VertexBuffer.PositionKind
  87288. * - VertexBuffer.NormalKind
  87289. * - VertexBuffer.UVKind
  87290. * - VertexBuffer.UV2Kind
  87291. * - VertexBuffer.UV3Kind
  87292. * - VertexBuffer.UV4Kind
  87293. * - VertexBuffer.UV5Kind
  87294. * - VertexBuffer.UV6Kind
  87295. * - VertexBuffer.ColorKind
  87296. * - VertexBuffer.MatricesIndicesKind
  87297. * - VertexBuffer.MatricesIndicesExtraKind
  87298. * - VertexBuffer.MatricesWeightsKind
  87299. * - VertexBuffer.MatricesWeightsExtraKind
  87300. * @returns an array of strings
  87301. */
  87302. getVerticesDataKinds(): string[];
  87303. /**
  87304. * Returns a positive integer : the total number of indices in this mesh geometry.
  87305. * @returns the numner of indices or zero if the mesh has no geometry.
  87306. */
  87307. getTotalIndices(): number;
  87308. /**
  87309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  87310. * @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.
  87311. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87312. * @returns the indices array or an empty array if the mesh has no geometry
  87313. */
  87314. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87315. readonly isBlocked: boolean;
  87316. /**
  87317. * Determine if the current mesh is ready to be rendered
  87318. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87319. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  87320. * @returns true if all associated assets are ready (material, textures, shaders)
  87321. */
  87322. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  87323. /**
  87324. * 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.
  87325. */
  87326. readonly areNormalsFrozen: boolean;
  87327. /**
  87328. * 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.
  87329. * @returns the current mesh
  87330. */
  87331. freezeNormals(): Mesh;
  87332. /**
  87333. * 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
  87334. * @returns the current mesh
  87335. */
  87336. unfreezeNormals(): Mesh;
  87337. /**
  87338. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  87339. */
  87340. overridenInstanceCount: number;
  87341. /** @hidden */
  87342. _preActivate(): Mesh;
  87343. /** @hidden */
  87344. _preActivateForIntermediateRendering(renderId: number): Mesh;
  87345. /** @hidden */
  87346. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  87347. /**
  87348. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87349. * This means the mesh underlying bounding box and sphere are recomputed.
  87350. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87351. * @returns the current mesh
  87352. */
  87353. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  87354. /** @hidden */
  87355. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  87356. /**
  87357. * This function will subdivide the mesh into multiple submeshes
  87358. * @param count defines the expected number of submeshes
  87359. */
  87360. subdivide(count: number): void;
  87361. /**
  87362. * Copy a FloatArray into a specific associated vertex buffer
  87363. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87364. * - VertexBuffer.PositionKind
  87365. * - VertexBuffer.UVKind
  87366. * - VertexBuffer.UV2Kind
  87367. * - VertexBuffer.UV3Kind
  87368. * - VertexBuffer.UV4Kind
  87369. * - VertexBuffer.UV5Kind
  87370. * - VertexBuffer.UV6Kind
  87371. * - VertexBuffer.ColorKind
  87372. * - VertexBuffer.MatricesIndicesKind
  87373. * - VertexBuffer.MatricesIndicesExtraKind
  87374. * - VertexBuffer.MatricesWeightsKind
  87375. * - VertexBuffer.MatricesWeightsExtraKind
  87376. * @param data defines the data source
  87377. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87378. * @param stride defines the data stride size (can be null)
  87379. * @returns the current mesh
  87380. */
  87381. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  87382. /**
  87383. * Flags an associated vertex buffer as updatable
  87384. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  87385. * - VertexBuffer.PositionKind
  87386. * - VertexBuffer.UVKind
  87387. * - VertexBuffer.UV2Kind
  87388. * - VertexBuffer.UV3Kind
  87389. * - VertexBuffer.UV4Kind
  87390. * - VertexBuffer.UV5Kind
  87391. * - VertexBuffer.UV6Kind
  87392. * - VertexBuffer.ColorKind
  87393. * - VertexBuffer.MatricesIndicesKind
  87394. * - VertexBuffer.MatricesIndicesExtraKind
  87395. * - VertexBuffer.MatricesWeightsKind
  87396. * - VertexBuffer.MatricesWeightsExtraKind
  87397. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  87398. */
  87399. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  87400. /**
  87401. * Sets the mesh global Vertex Buffer
  87402. * @param buffer defines the buffer to use
  87403. * @returns the current mesh
  87404. */
  87405. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  87406. /**
  87407. * Update a specific associated vertex buffer
  87408. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  87409. * - VertexBuffer.PositionKind
  87410. * - VertexBuffer.UVKind
  87411. * - VertexBuffer.UV2Kind
  87412. * - VertexBuffer.UV3Kind
  87413. * - VertexBuffer.UV4Kind
  87414. * - VertexBuffer.UV5Kind
  87415. * - VertexBuffer.UV6Kind
  87416. * - VertexBuffer.ColorKind
  87417. * - VertexBuffer.MatricesIndicesKind
  87418. * - VertexBuffer.MatricesIndicesExtraKind
  87419. * - VertexBuffer.MatricesWeightsKind
  87420. * - VertexBuffer.MatricesWeightsExtraKind
  87421. * @param data defines the data source
  87422. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  87423. * @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)
  87424. * @returns the current mesh
  87425. */
  87426. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  87427. /**
  87428. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  87429. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  87430. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  87431. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  87432. * @returns the current mesh
  87433. */
  87434. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  87435. /**
  87436. * Creates a un-shared specific occurence of the geometry for the mesh.
  87437. * @returns the current mesh
  87438. */
  87439. makeGeometryUnique(): Mesh;
  87440. /**
  87441. * Set the index buffer of this mesh
  87442. * @param indices defines the source data
  87443. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  87444. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  87445. * @returns the current mesh
  87446. */
  87447. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  87448. /**
  87449. * Update the current index buffer
  87450. * @param indices defines the source data
  87451. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87452. * @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)
  87453. * @returns the current mesh
  87454. */
  87455. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  87456. /**
  87457. * Invert the geometry to move from a right handed system to a left handed one.
  87458. * @returns the current mesh
  87459. */
  87460. toLeftHanded(): Mesh;
  87461. /** @hidden */
  87462. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  87463. /** @hidden */
  87464. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  87465. /**
  87466. * Registers for this mesh a javascript function called just before the rendering process
  87467. * @param func defines the function to call before rendering this mesh
  87468. * @returns the current mesh
  87469. */
  87470. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87471. /**
  87472. * Disposes a previously registered javascript function called before the rendering
  87473. * @param func defines the function to remove
  87474. * @returns the current mesh
  87475. */
  87476. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  87477. /**
  87478. * Registers for this mesh a javascript function called just after the rendering is complete
  87479. * @param func defines the function to call after rendering this mesh
  87480. * @returns the current mesh
  87481. */
  87482. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87483. /**
  87484. * Disposes a previously registered javascript function called after the rendering.
  87485. * @param func defines the function to remove
  87486. * @returns the current mesh
  87487. */
  87488. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  87489. /** @hidden */
  87490. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  87491. /** @hidden */
  87492. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  87493. /** @hidden */
  87494. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  87495. /** @hidden */
  87496. _rebuild(): void;
  87497. /** @hidden */
  87498. _freeze(): void;
  87499. /** @hidden */
  87500. _unFreeze(): void;
  87501. /**
  87502. * 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
  87503. * @param subMesh defines the subMesh to render
  87504. * @param enableAlphaMode defines if alpha mode can be changed
  87505. * @returns the current mesh
  87506. */
  87507. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  87508. private _onBeforeDraw;
  87509. /**
  87510. * Renormalize the mesh and patch it up if there are no weights
  87511. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  87512. * However in the case of zero weights then we set just a single influence to 1.
  87513. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  87514. */
  87515. cleanMatrixWeights(): void;
  87516. private normalizeSkinFourWeights;
  87517. private normalizeSkinWeightsAndExtra;
  87518. /**
  87519. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  87520. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  87521. * the user know there was an issue with importing the mesh
  87522. * @returns a validation object with skinned, valid and report string
  87523. */
  87524. validateSkinning(): {
  87525. skinned: boolean;
  87526. valid: boolean;
  87527. report: string;
  87528. };
  87529. /** @hidden */
  87530. _checkDelayState(): Mesh;
  87531. private _queueLoad;
  87532. /**
  87533. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87534. * A mesh is in the frustum if its bounding box intersects the frustum
  87535. * @param frustumPlanes defines the frustum to test
  87536. * @returns true if the mesh is in the frustum planes
  87537. */
  87538. isInFrustum(frustumPlanes: Plane[]): boolean;
  87539. /**
  87540. * Sets the mesh material by the material or multiMaterial `id` property
  87541. * @param id is a string identifying the material or the multiMaterial
  87542. * @returns the current mesh
  87543. */
  87544. setMaterialByID(id: string): Mesh;
  87545. /**
  87546. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  87547. * @returns an array of IAnimatable
  87548. */
  87549. getAnimatables(): IAnimatable[];
  87550. /**
  87551. * Modifies the mesh geometry according to the passed transformation matrix.
  87552. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  87553. * The mesh normals are modified using the same transformation.
  87554. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87555. * @param transform defines the transform matrix to use
  87556. * @see http://doc.babylonjs.com/resources/baking_transformations
  87557. * @returns the current mesh
  87558. */
  87559. bakeTransformIntoVertices(transform: Matrix): Mesh;
  87560. /**
  87561. * Modifies the mesh geometry according to its own current World Matrix.
  87562. * The mesh World Matrix is then reset.
  87563. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  87564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  87565. * @see http://doc.babylonjs.com/resources/baking_transformations
  87566. * @returns the current mesh
  87567. */
  87568. bakeCurrentTransformIntoVertices(): Mesh;
  87569. /** @hidden */
  87570. readonly _positions: Nullable<Vector3[]>;
  87571. /** @hidden */
  87572. _resetPointsArrayCache(): Mesh;
  87573. /** @hidden */
  87574. _generatePointsArray(): boolean;
  87575. /**
  87576. * Returns a new Mesh object generated from the current mesh properties.
  87577. * This method must not get confused with createInstance()
  87578. * @param name is a string, the name given to the new mesh
  87579. * @param newParent can be any Node object (default `null`)
  87580. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  87581. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  87582. * @returns a new mesh
  87583. */
  87584. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  87585. /**
  87586. * Releases resources associated with this mesh.
  87587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87589. */
  87590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87591. /**
  87592. * Modifies the mesh geometry according to a displacement map.
  87593. * 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.
  87594. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87595. * @param url is a string, the URL from the image file is to be downloaded.
  87596. * @param minHeight is the lower limit of the displacement.
  87597. * @param maxHeight is the upper limit of the displacement.
  87598. * @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.
  87599. * @param uvOffset is an optional vector2 used to offset UV.
  87600. * @param uvScale is an optional vector2 used to scale UV.
  87601. * @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.
  87602. * @returns the Mesh.
  87603. */
  87604. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87605. /**
  87606. * Modifies the mesh geometry according to a displacementMap buffer.
  87607. * 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.
  87608. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  87609. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  87610. * @param heightMapWidth is the width of the buffer image.
  87611. * @param heightMapHeight is the height of the buffer image.
  87612. * @param minHeight is the lower limit of the displacement.
  87613. * @param maxHeight is the upper limit of the displacement.
  87614. * @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.
  87615. * @param uvOffset is an optional vector2 used to offset UV.
  87616. * @param uvScale is an optional vector2 used to scale UV.
  87617. * @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.
  87618. * @returns the Mesh.
  87619. */
  87620. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  87621. /**
  87622. * Modify the mesh to get a flat shading rendering.
  87623. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  87624. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  87625. * @returns current mesh
  87626. */
  87627. convertToFlatShadedMesh(): Mesh;
  87628. /**
  87629. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  87630. * In other words, more vertices, no more indices and a single bigger VBO.
  87631. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  87632. * @returns current mesh
  87633. */
  87634. convertToUnIndexedMesh(): Mesh;
  87635. /**
  87636. * Inverses facet orientations.
  87637. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87638. * @param flipNormals will also inverts the normals
  87639. * @returns current mesh
  87640. */
  87641. flipFaces(flipNormals?: boolean): Mesh;
  87642. /**
  87643. * Increase the number of facets and hence vertices in a mesh
  87644. * Vertex normals are interpolated from existing vertex normals
  87645. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87646. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  87647. */
  87648. increaseVertices(numberPerEdge: number): void;
  87649. /**
  87650. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  87651. * This will undo any application of covertToFlatShadedMesh
  87652. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  87653. */
  87654. forceSharedVertices(): void;
  87655. /** @hidden */
  87656. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  87657. /** @hidden */
  87658. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  87659. /**
  87660. * Creates a new InstancedMesh object from the mesh model.
  87661. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  87662. * @param name defines the name of the new instance
  87663. * @returns a new InstancedMesh
  87664. */
  87665. createInstance(name: string): InstancedMesh;
  87666. /**
  87667. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  87668. * After this call, all the mesh instances have the same submeshes than the current mesh.
  87669. * @returns the current mesh
  87670. */
  87671. synchronizeInstances(): Mesh;
  87672. /**
  87673. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  87674. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  87675. * This should be used together with the simplification to avoid disappearing triangles.
  87676. * @param successCallback an optional success callback to be called after the optimization finished.
  87677. * @returns the current mesh
  87678. */
  87679. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  87680. /**
  87681. * Serialize current mesh
  87682. * @param serializationObject defines the object which will receive the serialization data
  87683. */
  87684. serialize(serializationObject: any): void;
  87685. /** @hidden */
  87686. _syncGeometryWithMorphTargetManager(): void;
  87687. /** @hidden */
  87688. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  87689. /**
  87690. * Returns a new Mesh object parsed from the source provided.
  87691. * @param parsedMesh is the source
  87692. * @param scene defines the hosting scene
  87693. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  87694. * @returns a new Mesh
  87695. */
  87696. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  87697. /**
  87698. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  87699. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87700. * @param name defines the name of the mesh to create
  87701. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  87702. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  87703. * @param closePath creates a seam between the first and the last points of each path of the path array
  87704. * @param offset is taken in account only if the `pathArray` is containing a single path
  87705. * @param scene defines the hosting scene
  87706. * @param updatable defines if the mesh must be flagged as updatable
  87707. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87708. * @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)
  87709. * @returns a new Mesh
  87710. */
  87711. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87712. /**
  87713. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  87714. * @param name defines the name of the mesh to create
  87715. * @param radius sets the radius size (float) of the polygon (default 0.5)
  87716. * @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
  87717. * @param scene defines the hosting scene
  87718. * @param updatable defines if the mesh must be flagged as updatable
  87719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87720. * @returns a new Mesh
  87721. */
  87722. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87723. /**
  87724. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  87725. * @param name defines the name of the mesh to create
  87726. * @param size sets the size (float) of each box side (default 1)
  87727. * @param scene defines the hosting scene
  87728. * @param updatable defines if the mesh must be flagged as updatable
  87729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87730. * @returns a new Mesh
  87731. */
  87732. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  87733. /**
  87734. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  87735. * @param name defines the name of the mesh to create
  87736. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87737. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87738. * @param scene defines the hosting scene
  87739. * @param updatable defines if the mesh must be flagged as updatable
  87740. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87741. * @returns a new Mesh
  87742. */
  87743. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87744. /**
  87745. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  87746. * @param name defines the name of the mesh to create
  87747. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  87748. * @param diameter sets the diameter size (float) of the sphere (default 1)
  87749. * @param scene defines the hosting scene
  87750. * @returns a new Mesh
  87751. */
  87752. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  87753. /**
  87754. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  87755. * @param name defines the name of the mesh to create
  87756. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  87757. * @param diameterTop set the top cap diameter (floats, default 1)
  87758. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  87759. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  87760. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  87761. * @param scene defines the hosting scene
  87762. * @param updatable defines if the mesh must be flagged as updatable
  87763. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87764. * @returns a new Mesh
  87765. */
  87766. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  87767. /**
  87768. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  87769. * @param name defines the name of the mesh to create
  87770. * @param diameter sets the diameter size (float) of the torus (default 1)
  87771. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  87772. * @param tessellation sets the number of torus sides (postive integer, default 16)
  87773. * @param scene defines the hosting scene
  87774. * @param updatable defines if the mesh must be flagged as updatable
  87775. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87776. * @returns a new Mesh
  87777. */
  87778. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87779. /**
  87780. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  87781. * @param name defines the name of the mesh to create
  87782. * @param radius sets the global radius size (float) of the torus knot (default 2)
  87783. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  87784. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  87785. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  87786. * @param p the number of windings on X axis (positive integers, default 2)
  87787. * @param q the number of windings on Y axis (positive integers, default 3)
  87788. * @param scene defines the hosting scene
  87789. * @param updatable defines if the mesh must be flagged as updatable
  87790. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87791. * @returns a new Mesh
  87792. */
  87793. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87794. /**
  87795. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  87796. * @param name defines the name of the mesh to create
  87797. * @param points is an array successive Vector3
  87798. * @param scene defines the hosting scene
  87799. * @param updatable defines if the mesh must be flagged as updatable
  87800. * @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).
  87801. * @returns a new Mesh
  87802. */
  87803. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  87804. /**
  87805. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  87806. * @param name defines the name of the mesh to create
  87807. * @param points is an array successive Vector3
  87808. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  87809. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  87810. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  87811. * @param scene defines the hosting scene
  87812. * @param updatable defines if the mesh must be flagged as updatable
  87813. * @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)
  87814. * @returns a new Mesh
  87815. */
  87816. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  87817. /**
  87818. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  87819. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  87820. * 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.
  87821. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87822. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  87823. * Remember you can only change the shape positions, not their number when updating a polygon.
  87824. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  87825. * @param name defines the name of the mesh to create
  87826. * @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
  87827. * @param scene defines the hosting scene
  87828. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87829. * @param updatable defines if the mesh must be flagged as updatable
  87830. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87831. * @param earcutInjection can be used to inject your own earcut reference
  87832. * @returns a new Mesh
  87833. */
  87834. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87835. /**
  87836. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  87837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  87838. * @param name defines the name of the mesh to create
  87839. * @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
  87840. * @param depth defines the height of extrusion
  87841. * @param scene defines the hosting scene
  87842. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  87843. * @param updatable defines if the mesh must be flagged as updatable
  87844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87845. * @param earcutInjection can be used to inject your own earcut reference
  87846. * @returns a new Mesh
  87847. */
  87848. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  87849. /**
  87850. * Creates an extruded shape mesh.
  87851. * 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
  87852. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87853. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87854. * @param name defines the name of the mesh to create
  87855. * @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
  87856. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87857. * @param scale is the value to scale the shape
  87858. * @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
  87859. * @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
  87860. * @param scene defines the hosting scene
  87861. * @param updatable defines if the mesh must be flagged as updatable
  87862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87863. * @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)
  87864. * @returns a new Mesh
  87865. */
  87866. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87867. /**
  87868. * Creates an custom extruded shape mesh.
  87869. * The custom extrusion is a parametric shape.
  87870. * It has no predefined shape. Its final shape will depend on the input parameters.
  87871. * Please consider using the same method from the MeshBuilder class instead
  87872. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  87873. * @param name defines the name of the mesh to create
  87874. * @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
  87875. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  87876. * @param scaleFunction is a custom Javascript function called on each path point
  87877. * @param rotationFunction is a custom Javascript function called on each path point
  87878. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  87879. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  87880. * @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
  87881. * @param scene defines the hosting scene
  87882. * @param updatable defines if the mesh must be flagged as updatable
  87883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87884. * @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)
  87885. * @returns a new Mesh
  87886. */
  87887. 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;
  87888. /**
  87889. * Creates lathe mesh.
  87890. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  87891. * Please consider using the same method from the MeshBuilder class instead
  87892. * @param name defines the name of the mesh to create
  87893. * @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
  87894. * @param radius is the radius value of the lathe
  87895. * @param tessellation is the side number of the lathe.
  87896. * @param scene defines the hosting scene
  87897. * @param updatable defines if the mesh must be flagged as updatable
  87898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87899. * @returns a new Mesh
  87900. */
  87901. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87902. /**
  87903. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  87904. * @param name defines the name of the mesh to create
  87905. * @param size sets the size (float) of both sides of the plane at once (default 1)
  87906. * @param scene defines the hosting scene
  87907. * @param updatable defines if the mesh must be flagged as updatable
  87908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87909. * @returns a new Mesh
  87910. */
  87911. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  87912. /**
  87913. * Creates a ground mesh.
  87914. * Please consider using the same method from the MeshBuilder class instead
  87915. * @param name defines the name of the mesh to create
  87916. * @param width set the width of the ground
  87917. * @param height set the height of the ground
  87918. * @param subdivisions sets the number of subdivisions per side
  87919. * @param scene defines the hosting scene
  87920. * @param updatable defines if the mesh must be flagged as updatable
  87921. * @returns a new Mesh
  87922. */
  87923. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  87924. /**
  87925. * Creates a tiled ground mesh.
  87926. * Please consider using the same method from the MeshBuilder class instead
  87927. * @param name defines the name of the mesh to create
  87928. * @param xmin set the ground minimum X coordinate
  87929. * @param zmin set the ground minimum Y coordinate
  87930. * @param xmax set the ground maximum X coordinate
  87931. * @param zmax set the ground maximum Z coordinate
  87932. * @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
  87933. * @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
  87934. * @param scene defines the hosting scene
  87935. * @param updatable defines if the mesh must be flagged as updatable
  87936. * @returns a new Mesh
  87937. */
  87938. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  87939. w: number;
  87940. h: number;
  87941. }, precision: {
  87942. w: number;
  87943. h: number;
  87944. }, scene: Scene, updatable?: boolean): Mesh;
  87945. /**
  87946. * Creates a ground mesh from a height map.
  87947. * Please consider using the same method from the MeshBuilder class instead
  87948. * @see http://doc.babylonjs.com/babylon101/height_map
  87949. * @param name defines the name of the mesh to create
  87950. * @param url sets the URL of the height map image resource
  87951. * @param width set the ground width size
  87952. * @param height set the ground height size
  87953. * @param subdivisions sets the number of subdivision per side
  87954. * @param minHeight is the minimum altitude on the ground
  87955. * @param maxHeight is the maximum altitude on the ground
  87956. * @param scene defines the hosting scene
  87957. * @param updatable defines if the mesh must be flagged as updatable
  87958. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  87959. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  87960. * @returns a new Mesh
  87961. */
  87962. 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;
  87963. /**
  87964. * Creates a tube mesh.
  87965. * The tube is a parametric shape.
  87966. * It has no predefined shape. Its final shape will depend on the input parameters.
  87967. * Please consider using the same method from the MeshBuilder class instead
  87968. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  87969. * @param name defines the name of the mesh to create
  87970. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  87971. * @param radius sets the tube radius size
  87972. * @param tessellation is the number of sides on the tubular surface
  87973. * @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
  87974. * @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
  87975. * @param scene defines the hosting scene
  87976. * @param updatable defines if the mesh must be flagged as updatable
  87977. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87978. * @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)
  87979. * @returns a new Mesh
  87980. */
  87981. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  87982. (i: number, distance: number): number;
  87983. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  87984. /**
  87985. * Creates a polyhedron mesh.
  87986. * Please consider using the same method from the MeshBuilder class instead.
  87987. * * 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
  87988. * * The parameter `size` (positive float, default 1) sets the polygon size
  87989. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87990. * * 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`
  87991. * * 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
  87992. * * 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)`)
  87993. * * 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
  87994. * * 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
  87995. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87996. * * If you create a double-sided mesh, you can choose what parts of 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
  87997. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87998. * @param name defines the name of the mesh to create
  87999. * @param options defines the options used to create the mesh
  88000. * @param scene defines the hosting scene
  88001. * @returns a new Mesh
  88002. */
  88003. static CreatePolyhedron(name: string, options: {
  88004. type?: number;
  88005. size?: number;
  88006. sizeX?: number;
  88007. sizeY?: number;
  88008. sizeZ?: number;
  88009. custom?: any;
  88010. faceUV?: Vector4[];
  88011. faceColors?: Color4[];
  88012. updatable?: boolean;
  88013. sideOrientation?: number;
  88014. }, scene: Scene): Mesh;
  88015. /**
  88016. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88017. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88018. * * 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`)
  88019. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88020. * * 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
  88021. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88022. * * If you create a double-sided mesh, you can choose what parts of 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
  88023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88024. * @param name defines the name of the mesh
  88025. * @param options defines the options used to create the mesh
  88026. * @param scene defines the hosting scene
  88027. * @returns a new Mesh
  88028. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88029. */
  88030. static CreateIcoSphere(name: string, options: {
  88031. radius?: number;
  88032. flat?: boolean;
  88033. subdivisions?: number;
  88034. sideOrientation?: number;
  88035. updatable?: boolean;
  88036. }, scene: Scene): Mesh;
  88037. /**
  88038. * Creates a decal mesh.
  88039. * Please consider using the same method from the MeshBuilder class instead.
  88040. * A decal is a mesh usually applied as a model onto the surface of another mesh
  88041. * @param name defines the name of the mesh
  88042. * @param sourceMesh defines the mesh receiving the decal
  88043. * @param position sets the position of the decal in world coordinates
  88044. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  88045. * @param size sets the decal scaling
  88046. * @param angle sets the angle to rotate the decal
  88047. * @returns a new Mesh
  88048. */
  88049. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  88050. /**
  88051. * Prepare internal position array for software CPU skinning
  88052. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  88053. */
  88054. setPositionsForCPUSkinning(): Float32Array;
  88055. /**
  88056. * Prepare internal normal array for software CPU skinning
  88057. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  88058. */
  88059. setNormalsForCPUSkinning(): Float32Array;
  88060. /**
  88061. * Updates the vertex buffer by applying transformation from the bones
  88062. * @param skeleton defines the skeleton to apply to current mesh
  88063. * @returns the current mesh
  88064. */
  88065. applySkeleton(skeleton: Skeleton): Mesh;
  88066. /**
  88067. * 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
  88068. * @param meshes defines the list of meshes to scan
  88069. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  88070. */
  88071. static MinMax(meshes: AbstractMesh[]): {
  88072. min: Vector3;
  88073. max: Vector3;
  88074. };
  88075. /**
  88076. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  88077. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  88078. * @returns a vector3
  88079. */
  88080. static Center(meshesOrMinMaxVector: {
  88081. min: Vector3;
  88082. max: Vector3;
  88083. } | AbstractMesh[]): Vector3;
  88084. /**
  88085. * Merge the array of meshes into a single mesh for performance reasons.
  88086. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  88087. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  88088. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  88089. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  88090. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  88091. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  88092. * @returns a new mesh
  88093. */
  88094. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  88095. /** @hidden */
  88096. addInstance(instance: InstancedMesh): void;
  88097. /** @hidden */
  88098. removeInstance(instance: InstancedMesh): void;
  88099. }
  88100. }
  88101. declare module BABYLON {
  88102. /**
  88103. * This is the base class of all the camera used in the application.
  88104. * @see http://doc.babylonjs.com/features/cameras
  88105. */
  88106. export class Camera extends Node {
  88107. /** @hidden */
  88108. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  88109. /**
  88110. * This is the default projection mode used by the cameras.
  88111. * It helps recreating a feeling of perspective and better appreciate depth.
  88112. * This is the best way to simulate real life cameras.
  88113. */
  88114. static readonly PERSPECTIVE_CAMERA: number;
  88115. /**
  88116. * This helps creating camera with an orthographic mode.
  88117. * 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.
  88118. */
  88119. static readonly ORTHOGRAPHIC_CAMERA: number;
  88120. /**
  88121. * This is the default FOV mode for perspective cameras.
  88122. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  88123. */
  88124. static readonly FOVMODE_VERTICAL_FIXED: number;
  88125. /**
  88126. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  88127. */
  88128. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  88129. /**
  88130. * This specifies ther is no need for a camera rig.
  88131. * Basically only one eye is rendered corresponding to the camera.
  88132. */
  88133. static readonly RIG_MODE_NONE: number;
  88134. /**
  88135. * Simulates a camera Rig with one blue eye and one red eye.
  88136. * This can be use with 3d blue and red glasses.
  88137. */
  88138. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  88139. /**
  88140. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  88141. */
  88142. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  88143. /**
  88144. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  88145. */
  88146. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  88147. /**
  88148. * Defines that both eyes of the camera will be rendered over under each other.
  88149. */
  88150. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  88151. /**
  88152. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  88153. */
  88154. static readonly RIG_MODE_VR: number;
  88155. /**
  88156. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  88157. */
  88158. static readonly RIG_MODE_WEBVR: number;
  88159. /**
  88160. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  88161. */
  88162. static readonly RIG_MODE_CUSTOM: number;
  88163. /**
  88164. * Defines if by default attaching controls should prevent the default javascript event to continue.
  88165. */
  88166. static ForceAttachControlToAlwaysPreventDefault: boolean;
  88167. /**
  88168. * Define the input manager associated with the camera.
  88169. */
  88170. inputs: CameraInputsManager<Camera>;
  88171. /** @hidden */
  88172. _position: Vector3;
  88173. /**
  88174. * Define the current local position of the camera in the scene
  88175. */
  88176. position: Vector3;
  88177. /**
  88178. * The vector the camera should consider as up.
  88179. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  88180. */
  88181. upVector: Vector3;
  88182. /**
  88183. * Define the current limit on the left side for an orthographic camera
  88184. * In scene unit
  88185. */
  88186. orthoLeft: Nullable<number>;
  88187. /**
  88188. * Define the current limit on the right side for an orthographic camera
  88189. * In scene unit
  88190. */
  88191. orthoRight: Nullable<number>;
  88192. /**
  88193. * Define the current limit on the bottom side for an orthographic camera
  88194. * In scene unit
  88195. */
  88196. orthoBottom: Nullable<number>;
  88197. /**
  88198. * Define the current limit on the top side for an orthographic camera
  88199. * In scene unit
  88200. */
  88201. orthoTop: Nullable<number>;
  88202. /**
  88203. * Field Of View is set in Radians. (default is 0.8)
  88204. */
  88205. fov: number;
  88206. /**
  88207. * Define the minimum distance the camera can see from.
  88208. * This is important to note that the depth buffer are not infinite and the closer it starts
  88209. * the more your scene might encounter depth fighting issue.
  88210. */
  88211. minZ: number;
  88212. /**
  88213. * Define the maximum distance the camera can see to.
  88214. * This is important to note that the depth buffer are not infinite and the further it end
  88215. * the more your scene might encounter depth fighting issue.
  88216. */
  88217. maxZ: number;
  88218. /**
  88219. * Define the default inertia of the camera.
  88220. * This helps giving a smooth feeling to the camera movement.
  88221. */
  88222. inertia: number;
  88223. /**
  88224. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  88225. */
  88226. mode: number;
  88227. /**
  88228. * Define wether the camera is intermediate.
  88229. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  88230. */
  88231. isIntermediate: boolean;
  88232. /**
  88233. * Define the viewport of the camera.
  88234. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  88235. */
  88236. viewport: Viewport;
  88237. /**
  88238. * Restricts the camera to viewing objects with the same layerMask.
  88239. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  88240. */
  88241. layerMask: number;
  88242. /**
  88243. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  88244. */
  88245. fovMode: number;
  88246. /**
  88247. * Rig mode of the camera.
  88248. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  88249. * This is normally controlled byt the camera themselves as internal use.
  88250. */
  88251. cameraRigMode: number;
  88252. /**
  88253. * Defines the distance between both "eyes" in case of a RIG
  88254. */
  88255. interaxialDistance: number;
  88256. /**
  88257. * Defines if stereoscopic rendering is done side by side or over under.
  88258. */
  88259. isStereoscopicSideBySide: boolean;
  88260. /**
  88261. * 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
  88262. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  88263. * else in the scene. (Eg. security camera)
  88264. *
  88265. * 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)
  88266. */
  88267. customRenderTargets: RenderTargetTexture[];
  88268. /**
  88269. * When set, the camera will render to this render target instead of the default canvas
  88270. *
  88271. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  88272. */
  88273. outputRenderTarget: Nullable<RenderTargetTexture>;
  88274. /**
  88275. * Observable triggered when the camera view matrix has changed.
  88276. */
  88277. onViewMatrixChangedObservable: Observable<Camera>;
  88278. /**
  88279. * Observable triggered when the camera Projection matrix has changed.
  88280. */
  88281. onProjectionMatrixChangedObservable: Observable<Camera>;
  88282. /**
  88283. * Observable triggered when the inputs have been processed.
  88284. */
  88285. onAfterCheckInputsObservable: Observable<Camera>;
  88286. /**
  88287. * Observable triggered when reset has been called and applied to the camera.
  88288. */
  88289. onRestoreStateObservable: Observable<Camera>;
  88290. /** @hidden */
  88291. _cameraRigParams: any;
  88292. /** @hidden */
  88293. _rigCameras: Camera[];
  88294. /** @hidden */
  88295. _rigPostProcess: Nullable<PostProcess>;
  88296. protected _webvrViewMatrix: Matrix;
  88297. /** @hidden */
  88298. _skipRendering: boolean;
  88299. /** @hidden */
  88300. _projectionMatrix: Matrix;
  88301. /** @hidden */
  88302. _postProcesses: Nullable<PostProcess>[];
  88303. /** @hidden */
  88304. _activeMeshes: SmartArray<AbstractMesh>;
  88305. protected _globalPosition: Vector3;
  88306. /** @hidden */
  88307. _computedViewMatrix: Matrix;
  88308. private _doNotComputeProjectionMatrix;
  88309. private _transformMatrix;
  88310. private _frustumPlanes;
  88311. private _refreshFrustumPlanes;
  88312. private _storedFov;
  88313. private _stateStored;
  88314. /**
  88315. * Instantiates a new camera object.
  88316. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  88317. * @see http://doc.babylonjs.com/features/cameras
  88318. * @param name Defines the name of the camera in the scene
  88319. * @param position Defines the position of the camera
  88320. * @param scene Defines the scene the camera belongs too
  88321. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  88322. */
  88323. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  88324. /**
  88325. * Store current camera state (fov, position, etc..)
  88326. * @returns the camera
  88327. */
  88328. storeState(): Camera;
  88329. /**
  88330. * Restores the camera state values if it has been stored. You must call storeState() first
  88331. */
  88332. protected _restoreStateValues(): boolean;
  88333. /**
  88334. * Restored camera state. You must call storeState() first.
  88335. * @returns true if restored and false otherwise
  88336. */
  88337. restoreState(): boolean;
  88338. /**
  88339. * Gets the class name of the camera.
  88340. * @returns the class name
  88341. */
  88342. getClassName(): string;
  88343. /** @hidden */
  88344. readonly _isCamera: boolean;
  88345. /**
  88346. * Gets a string representation of the camera useful for debug purpose.
  88347. * @param fullDetails Defines that a more verboe level of logging is required
  88348. * @returns the string representation
  88349. */
  88350. toString(fullDetails?: boolean): string;
  88351. /**
  88352. * Gets the current world space position of the camera.
  88353. */
  88354. readonly globalPosition: Vector3;
  88355. /**
  88356. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  88357. * @returns the active meshe list
  88358. */
  88359. getActiveMeshes(): SmartArray<AbstractMesh>;
  88360. /**
  88361. * Check wether a mesh is part of the current active mesh list of the camera
  88362. * @param mesh Defines the mesh to check
  88363. * @returns true if active, false otherwise
  88364. */
  88365. isActiveMesh(mesh: Mesh): boolean;
  88366. /**
  88367. * Is this camera ready to be used/rendered
  88368. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  88369. * @return true if the camera is ready
  88370. */
  88371. isReady(completeCheck?: boolean): boolean;
  88372. /** @hidden */
  88373. _initCache(): void;
  88374. /** @hidden */
  88375. _updateCache(ignoreParentClass?: boolean): void;
  88376. /** @hidden */
  88377. _isSynchronized(): boolean;
  88378. /** @hidden */
  88379. _isSynchronizedViewMatrix(): boolean;
  88380. /** @hidden */
  88381. _isSynchronizedProjectionMatrix(): boolean;
  88382. /**
  88383. * Attach the input controls to a specific dom element to get the input from.
  88384. * @param element Defines the element the controls should be listened from
  88385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  88386. */
  88387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  88388. /**
  88389. * Detach the current controls from the specified dom element.
  88390. * @param element Defines the element to stop listening the inputs from
  88391. */
  88392. detachControl(element: HTMLElement): void;
  88393. /**
  88394. * Update the camera state according to the different inputs gathered during the frame.
  88395. */
  88396. update(): void;
  88397. /** @hidden */
  88398. _checkInputs(): void;
  88399. /** @hidden */
  88400. readonly rigCameras: Camera[];
  88401. /**
  88402. * Gets the post process used by the rig cameras
  88403. */
  88404. readonly rigPostProcess: Nullable<PostProcess>;
  88405. /**
  88406. * Internal, gets the first post proces.
  88407. * @returns the first post process to be run on this camera.
  88408. */
  88409. _getFirstPostProcess(): Nullable<PostProcess>;
  88410. private _cascadePostProcessesToRigCams;
  88411. /**
  88412. * Attach a post process to the camera.
  88413. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88414. * @param postProcess The post process to attach to the camera
  88415. * @param insertAt The position of the post process in case several of them are in use in the scene
  88416. * @returns the position the post process has been inserted at
  88417. */
  88418. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  88419. /**
  88420. * Detach a post process to the camera.
  88421. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  88422. * @param postProcess The post process to detach from the camera
  88423. */
  88424. detachPostProcess(postProcess: PostProcess): void;
  88425. /**
  88426. * Gets the current world matrix of the camera
  88427. */
  88428. getWorldMatrix(): Matrix;
  88429. /** @hidden */
  88430. _getViewMatrix(): Matrix;
  88431. /**
  88432. * Gets the current view matrix of the camera.
  88433. * @param force forces the camera to recompute the matrix without looking at the cached state
  88434. * @returns the view matrix
  88435. */
  88436. getViewMatrix(force?: boolean): Matrix;
  88437. /**
  88438. * Freeze the projection matrix.
  88439. * It will prevent the cache check of the camera projection compute and can speed up perf
  88440. * if no parameter of the camera are meant to change
  88441. * @param projection Defines manually a projection if necessary
  88442. */
  88443. freezeProjectionMatrix(projection?: Matrix): void;
  88444. /**
  88445. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  88446. */
  88447. unfreezeProjectionMatrix(): void;
  88448. /**
  88449. * Gets the current projection matrix of the camera.
  88450. * @param force forces the camera to recompute the matrix without looking at the cached state
  88451. * @returns the projection matrix
  88452. */
  88453. getProjectionMatrix(force?: boolean): Matrix;
  88454. /**
  88455. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  88456. * @returns a Matrix
  88457. */
  88458. getTransformationMatrix(): Matrix;
  88459. private _updateFrustumPlanes;
  88460. /**
  88461. * Checks if a cullable object (mesh...) is in the camera frustum
  88462. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  88463. * @param target The object to check
  88464. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  88465. * @returns true if the object is in frustum otherwise false
  88466. */
  88467. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  88468. /**
  88469. * Checks if a cullable object (mesh...) is in the camera frustum
  88470. * Unlike isInFrustum this cheks the full bounding box
  88471. * @param target The object to check
  88472. * @returns true if the object is in frustum otherwise false
  88473. */
  88474. isCompletelyInFrustum(target: ICullable): boolean;
  88475. /**
  88476. * Gets a ray in the forward direction from the camera.
  88477. * @param length Defines the length of the ray to create
  88478. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  88479. * @param origin Defines the start point of the ray which defaults to the camera position
  88480. * @returns the forward ray
  88481. */
  88482. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  88483. /**
  88484. * Releases resources associated with this node.
  88485. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88486. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88487. */
  88488. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88489. /** @hidden */
  88490. _isLeftCamera: boolean;
  88491. /**
  88492. * Gets the left camera of a rig setup in case of Rigged Camera
  88493. */
  88494. readonly isLeftCamera: boolean;
  88495. /** @hidden */
  88496. _isRightCamera: boolean;
  88497. /**
  88498. * Gets the right camera of a rig setup in case of Rigged Camera
  88499. */
  88500. readonly isRightCamera: boolean;
  88501. /**
  88502. * Gets the left camera of a rig setup in case of Rigged Camera
  88503. */
  88504. readonly leftCamera: Nullable<FreeCamera>;
  88505. /**
  88506. * Gets the right camera of a rig setup in case of Rigged Camera
  88507. */
  88508. readonly rightCamera: Nullable<FreeCamera>;
  88509. /**
  88510. * Gets the left camera target of a rig setup in case of Rigged Camera
  88511. * @returns the target position
  88512. */
  88513. getLeftTarget(): Nullable<Vector3>;
  88514. /**
  88515. * Gets the right camera target of a rig setup in case of Rigged Camera
  88516. * @returns the target position
  88517. */
  88518. getRightTarget(): Nullable<Vector3>;
  88519. /**
  88520. * @hidden
  88521. */
  88522. setCameraRigMode(mode: number, rigParams: any): void;
  88523. /** @hidden */
  88524. static _setStereoscopicRigMode(camera: Camera): void;
  88525. /** @hidden */
  88526. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  88527. /** @hidden */
  88528. static _setVRRigMode(camera: Camera, rigParams: any): void;
  88529. /** @hidden */
  88530. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  88531. /** @hidden */
  88532. _getVRProjectionMatrix(): Matrix;
  88533. protected _updateCameraRotationMatrix(): void;
  88534. protected _updateWebVRCameraRotationMatrix(): void;
  88535. /**
  88536. * This function MUST be overwritten by the different WebVR cameras available.
  88537. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88538. * @hidden
  88539. */
  88540. _getWebVRProjectionMatrix(): Matrix;
  88541. /**
  88542. * This function MUST be overwritten by the different WebVR cameras available.
  88543. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  88544. * @hidden
  88545. */
  88546. _getWebVRViewMatrix(): Matrix;
  88547. /** @hidden */
  88548. setCameraRigParameter(name: string, value: any): void;
  88549. /**
  88550. * needs to be overridden by children so sub has required properties to be copied
  88551. * @hidden
  88552. */
  88553. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  88554. /**
  88555. * May need to be overridden by children
  88556. * @hidden
  88557. */
  88558. _updateRigCameras(): void;
  88559. /** @hidden */
  88560. _setupInputs(): void;
  88561. /**
  88562. * Serialiaze the camera setup to a json represention
  88563. * @returns the JSON representation
  88564. */
  88565. serialize(): any;
  88566. /**
  88567. * Clones the current camera.
  88568. * @param name The cloned camera name
  88569. * @returns the cloned camera
  88570. */
  88571. clone(name: string): Camera;
  88572. /**
  88573. * Gets the direction of the camera relative to a given local axis.
  88574. * @param localAxis Defines the reference axis to provide a relative direction.
  88575. * @return the direction
  88576. */
  88577. getDirection(localAxis: Vector3): Vector3;
  88578. /**
  88579. * Gets the direction of the camera relative to a given local axis into a passed vector.
  88580. * @param localAxis Defines the reference axis to provide a relative direction.
  88581. * @param result Defines the vector to store the result in
  88582. */
  88583. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  88584. /**
  88585. * Gets a camera constructor for a given camera type
  88586. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  88587. * @param name The name of the camera the result will be able to instantiate
  88588. * @param scene The scene the result will construct the camera in
  88589. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  88590. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  88591. * @returns a factory method to construc the camera
  88592. */
  88593. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  88594. /**
  88595. * Compute the world matrix of the camera.
  88596. * @returns the camera workd matrix
  88597. */
  88598. computeWorldMatrix(): Matrix;
  88599. /**
  88600. * Parse a JSON and creates the camera from the parsed information
  88601. * @param parsedCamera The JSON to parse
  88602. * @param scene The scene to instantiate the camera in
  88603. * @returns the newly constructed camera
  88604. */
  88605. static Parse(parsedCamera: any, scene: Scene): Camera;
  88606. }
  88607. }
  88608. declare module BABYLON {
  88609. /**
  88610. * Class containing static functions to help procedurally build meshes
  88611. */
  88612. export class DiscBuilder {
  88613. /**
  88614. * Creates a plane polygonal mesh. By default, this is a disc
  88615. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88616. * * 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
  88617. * * 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
  88618. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88619. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  88620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88621. * @param name defines the name of the mesh
  88622. * @param options defines the options used to create the mesh
  88623. * @param scene defines the hosting scene
  88624. * @returns the plane polygonal mesh
  88625. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88626. */
  88627. static CreateDisc(name: string, options: {
  88628. radius?: number;
  88629. tessellation?: number;
  88630. arc?: number;
  88631. updatable?: boolean;
  88632. sideOrientation?: number;
  88633. frontUVs?: Vector4;
  88634. backUVs?: Vector4;
  88635. }, scene?: Nullable<Scene>): Mesh;
  88636. }
  88637. }
  88638. declare module BABYLON {
  88639. /**
  88640. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  88641. *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.
  88642. * The SPS is also a particle system. It provides some methods to manage the particles.
  88643. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  88644. *
  88645. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  88646. */
  88647. export class SolidParticleSystem implements IDisposable {
  88648. /**
  88649. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  88650. * Example : var p = SPS.particles[i];
  88651. */
  88652. particles: SolidParticle[];
  88653. /**
  88654. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  88655. */
  88656. nbParticles: number;
  88657. /**
  88658. * If the particles must ever face the camera (default false). Useful for planar particles.
  88659. */
  88660. billboard: boolean;
  88661. /**
  88662. * Recompute normals when adding a shape
  88663. */
  88664. recomputeNormals: boolean;
  88665. /**
  88666. * This a counter ofr your own usage. It's not set by any SPS functions.
  88667. */
  88668. counter: number;
  88669. /**
  88670. * The SPS name. This name is also given to the underlying mesh.
  88671. */
  88672. name: string;
  88673. /**
  88674. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  88675. */
  88676. mesh: Mesh;
  88677. /**
  88678. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  88679. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  88680. */
  88681. vars: any;
  88682. /**
  88683. * This array is populated when the SPS is set as 'pickable'.
  88684. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  88685. * Each element of this array is an object `{idx: int, faceId: int}`.
  88686. * `idx` is the picked particle index in the `SPS.particles` array
  88687. * `faceId` is the picked face index counted within this particle.
  88688. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  88689. */
  88690. pickedParticles: {
  88691. idx: number;
  88692. faceId: number;
  88693. }[];
  88694. /**
  88695. * This array is populated when `enableDepthSort` is set to true.
  88696. * Each element of this array is an instance of the class DepthSortedParticle.
  88697. */
  88698. depthSortedParticles: DepthSortedParticle[];
  88699. /**
  88700. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  88701. * @hidden
  88702. */
  88703. _bSphereOnly: boolean;
  88704. /**
  88705. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  88706. * @hidden
  88707. */
  88708. _bSphereRadiusFactor: number;
  88709. private _scene;
  88710. private _positions;
  88711. private _indices;
  88712. private _normals;
  88713. private _colors;
  88714. private _uvs;
  88715. private _indices32;
  88716. private _positions32;
  88717. private _normals32;
  88718. private _fixedNormal32;
  88719. private _colors32;
  88720. private _uvs32;
  88721. private _index;
  88722. private _updatable;
  88723. private _pickable;
  88724. private _isVisibilityBoxLocked;
  88725. private _alwaysVisible;
  88726. private _depthSort;
  88727. private _shapeCounter;
  88728. private _copy;
  88729. private _color;
  88730. private _computeParticleColor;
  88731. private _computeParticleTexture;
  88732. private _computeParticleRotation;
  88733. private _computeParticleVertex;
  88734. private _computeBoundingBox;
  88735. private _depthSortParticles;
  88736. private _camera;
  88737. private _mustUnrotateFixedNormals;
  88738. private _particlesIntersect;
  88739. private _needs32Bits;
  88740. /**
  88741. * Creates a SPS (Solid Particle System) object.
  88742. * @param name (String) is the SPS name, this will be the underlying mesh name.
  88743. * @param scene (Scene) is the scene in which the SPS is added.
  88744. * @param options defines the options of the sps e.g.
  88745. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  88746. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  88747. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  88748. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  88749. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  88750. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  88751. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  88752. */
  88753. constructor(name: string, scene: Scene, options?: {
  88754. updatable?: boolean;
  88755. isPickable?: boolean;
  88756. enableDepthSort?: boolean;
  88757. particleIntersection?: boolean;
  88758. boundingSphereOnly?: boolean;
  88759. bSphereRadiusFactor?: number;
  88760. });
  88761. /**
  88762. * Builds the SPS underlying mesh. Returns a standard Mesh.
  88763. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  88764. * @returns the created mesh
  88765. */
  88766. buildMesh(): Mesh;
  88767. /**
  88768. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  88769. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  88770. * Thus the particles generated from `digest()` have their property `position` set yet.
  88771. * @param mesh ( Mesh ) is the mesh to be digested
  88772. * @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
  88773. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  88774. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  88775. * @returns the current SPS
  88776. */
  88777. digest(mesh: Mesh, options?: {
  88778. facetNb?: number;
  88779. number?: number;
  88780. delta?: number;
  88781. }): SolidParticleSystem;
  88782. private _unrotateFixedNormals;
  88783. private _resetCopy;
  88784. private _meshBuilder;
  88785. private _posToShape;
  88786. private _uvsToShapeUV;
  88787. private _addParticle;
  88788. /**
  88789. * Adds some particles to the SPS from the model shape. Returns the shape id.
  88790. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  88791. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  88792. * @param nb (positive integer) the number of particles to be created from this model
  88793. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  88794. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  88795. * @returns the number of shapes in the system
  88796. */
  88797. addShape(mesh: Mesh, nb: number, options?: {
  88798. positionFunction?: any;
  88799. vertexFunction?: any;
  88800. }): number;
  88801. private _rebuildParticle;
  88802. /**
  88803. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  88804. * @returns the SPS.
  88805. */
  88806. rebuildMesh(): SolidParticleSystem;
  88807. /**
  88808. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  88809. * This method calls `updateParticle()` for each particle of the SPS.
  88810. * For an animated SPS, it is usually called within the render loop.
  88811. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  88812. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  88813. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  88814. * @returns the SPS.
  88815. */
  88816. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  88817. /**
  88818. * Disposes the SPS.
  88819. */
  88820. dispose(): void;
  88821. /**
  88822. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  88823. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88824. * @returns the SPS.
  88825. */
  88826. refreshVisibleSize(): SolidParticleSystem;
  88827. /**
  88828. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  88829. * @param size the size (float) of the visibility box
  88830. * note : this doesn't lock the SPS mesh bounding box.
  88831. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88832. */
  88833. setVisibilityBox(size: number): void;
  88834. /**
  88835. * Gets whether the SPS as always visible or not
  88836. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88837. */
  88838. /**
  88839. * Sets the SPS as always visible or not
  88840. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88841. */
  88842. isAlwaysVisible: boolean;
  88843. /**
  88844. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88845. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88846. */
  88847. /**
  88848. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  88849. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  88850. */
  88851. isVisibilityBoxLocked: boolean;
  88852. /**
  88853. * Tells to `setParticles()` to compute the particle rotations or not.
  88854. * Default value : true. The SPS is faster when it's set to false.
  88855. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88856. */
  88857. /**
  88858. * Gets if `setParticles()` computes the particle rotations or not.
  88859. * Default value : true. The SPS is faster when it's set to false.
  88860. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  88861. */
  88862. computeParticleRotation: boolean;
  88863. /**
  88864. * Tells to `setParticles()` to compute the particle colors or not.
  88865. * Default value : true. The SPS is faster when it's set to false.
  88866. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88867. */
  88868. /**
  88869. * Gets if `setParticles()` computes the particle colors or not.
  88870. * Default value : true. The SPS is faster when it's set to false.
  88871. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  88872. */
  88873. computeParticleColor: boolean;
  88874. /**
  88875. * Gets if `setParticles()` computes the particle textures or not.
  88876. * Default value : true. The SPS is faster when it's set to false.
  88877. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  88878. */
  88879. computeParticleTexture: boolean;
  88880. /**
  88881. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  88882. * Default value : false. The SPS is faster when it's set to false.
  88883. * Note : the particle custom vertex positions aren't stored values.
  88884. */
  88885. /**
  88886. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  88887. * Default value : false. The SPS is faster when it's set to false.
  88888. * Note : the particle custom vertex positions aren't stored values.
  88889. */
  88890. computeParticleVertex: boolean;
  88891. /**
  88892. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  88893. */
  88894. /**
  88895. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  88896. */
  88897. computeBoundingBox: boolean;
  88898. /**
  88899. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  88900. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88901. * Default : `true`
  88902. */
  88903. /**
  88904. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  88905. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  88906. * Default : `true`
  88907. */
  88908. depthSortParticles: boolean;
  88909. /**
  88910. * This function does nothing. It may be overwritten to set all the particle first values.
  88911. * The SPS doesn't call this function, you may have to call it by your own.
  88912. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88913. */
  88914. initParticles(): void;
  88915. /**
  88916. * This function does nothing. It may be overwritten to recycle a particle.
  88917. * The SPS doesn't call this function, you may have to call it by your own.
  88918. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88919. * @param particle The particle to recycle
  88920. * @returns the recycled particle
  88921. */
  88922. recycleParticle(particle: SolidParticle): SolidParticle;
  88923. /**
  88924. * Updates a particle : this function should be overwritten by the user.
  88925. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  88926. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  88927. * @example : just set a particle position or velocity and recycle conditions
  88928. * @param particle The particle to update
  88929. * @returns the updated particle
  88930. */
  88931. updateParticle(particle: SolidParticle): SolidParticle;
  88932. /**
  88933. * Updates a vertex of a particle : it can be overwritten by the user.
  88934. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  88935. * @param particle the current particle
  88936. * @param vertex the current index of the current particle
  88937. * @param pt the index of the current vertex in the particle shape
  88938. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  88939. * @example : just set a vertex particle position
  88940. * @returns the updated vertex
  88941. */
  88942. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  88943. /**
  88944. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  88945. * This does nothing and may be overwritten by the user.
  88946. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88947. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88948. * @param update the boolean update value actually passed to setParticles()
  88949. */
  88950. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88951. /**
  88952. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  88953. * This will be passed three parameters.
  88954. * This does nothing and may be overwritten by the user.
  88955. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88956. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  88957. * @param update the boolean update value actually passed to setParticles()
  88958. */
  88959. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  88960. }
  88961. }
  88962. declare module BABYLON {
  88963. /**
  88964. * Represents one particle of a solid particle system.
  88965. */
  88966. export class SolidParticle {
  88967. /**
  88968. * particle global index
  88969. */
  88970. idx: number;
  88971. /**
  88972. * The color of the particle
  88973. */
  88974. color: Nullable<Color4>;
  88975. /**
  88976. * The world space position of the particle.
  88977. */
  88978. position: Vector3;
  88979. /**
  88980. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  88981. */
  88982. rotation: Vector3;
  88983. /**
  88984. * The world space rotation quaternion of the particle.
  88985. */
  88986. rotationQuaternion: Nullable<Quaternion>;
  88987. /**
  88988. * The scaling of the particle.
  88989. */
  88990. scaling: Vector3;
  88991. /**
  88992. * The uvs of the particle.
  88993. */
  88994. uvs: Vector4;
  88995. /**
  88996. * The current speed of the particle.
  88997. */
  88998. velocity: Vector3;
  88999. /**
  89000. * The pivot point in the particle local space.
  89001. */
  89002. pivot: Vector3;
  89003. /**
  89004. * Must the particle be translated from its pivot point in its local space ?
  89005. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  89006. * Default : false
  89007. */
  89008. translateFromPivot: boolean;
  89009. /**
  89010. * Is the particle active or not ?
  89011. */
  89012. alive: boolean;
  89013. /**
  89014. * Is the particle visible or not ?
  89015. */
  89016. isVisible: boolean;
  89017. /**
  89018. * Index of this particle in the global "positions" array (Internal use)
  89019. * @hidden
  89020. */
  89021. _pos: number;
  89022. /**
  89023. * @hidden Index of this particle in the global "indices" array (Internal use)
  89024. */
  89025. _ind: number;
  89026. /**
  89027. * @hidden ModelShape of this particle (Internal use)
  89028. */
  89029. _model: ModelShape;
  89030. /**
  89031. * ModelShape id of this particle
  89032. */
  89033. shapeId: number;
  89034. /**
  89035. * Index of the particle in its shape id (Internal use)
  89036. */
  89037. idxInShape: number;
  89038. /**
  89039. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  89040. */
  89041. _modelBoundingInfo: BoundingInfo;
  89042. /**
  89043. * @hidden Particle BoundingInfo object (Internal use)
  89044. */
  89045. _boundingInfo: BoundingInfo;
  89046. /**
  89047. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  89048. */
  89049. _sps: SolidParticleSystem;
  89050. /**
  89051. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  89052. */
  89053. _stillInvisible: boolean;
  89054. /**
  89055. * @hidden Last computed particle rotation matrix
  89056. */
  89057. _rotationMatrix: number[];
  89058. /**
  89059. * Parent particle Id, if any.
  89060. * Default null.
  89061. */
  89062. parentId: Nullable<number>;
  89063. /**
  89064. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  89065. * The possible values are :
  89066. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89067. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89068. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89069. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89070. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89071. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  89072. * */
  89073. cullingStrategy: number;
  89074. /**
  89075. * @hidden Internal global position in the SPS.
  89076. */
  89077. _globalPosition: Vector3;
  89078. /**
  89079. * Creates a Solid Particle object.
  89080. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  89081. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  89082. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  89083. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  89084. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  89085. * @param shapeId (integer) is the model shape identifier in the SPS.
  89086. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  89087. * @param sps defines the sps it is associated to
  89088. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  89089. */
  89090. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  89091. /**
  89092. * Legacy support, changed scale to scaling
  89093. */
  89094. /**
  89095. * Legacy support, changed scale to scaling
  89096. */
  89097. scale: Vector3;
  89098. /**
  89099. * Legacy support, changed quaternion to rotationQuaternion
  89100. */
  89101. /**
  89102. * Legacy support, changed quaternion to rotationQuaternion
  89103. */
  89104. quaternion: Nullable<Quaternion>;
  89105. /**
  89106. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  89107. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  89108. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  89109. * @returns true if it intersects
  89110. */
  89111. intersectsMesh(target: Mesh | SolidParticle): boolean;
  89112. /**
  89113. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  89114. * A particle is in the frustum if its bounding box intersects the frustum
  89115. * @param frustumPlanes defines the frustum to test
  89116. * @returns true if the particle is in the frustum planes
  89117. */
  89118. isInFrustum(frustumPlanes: Plane[]): boolean;
  89119. /**
  89120. * get the rotation matrix of the particle
  89121. * @hidden
  89122. */
  89123. getRotationMatrix(m: Matrix): void;
  89124. }
  89125. /**
  89126. * Represents the shape of the model used by one particle of a solid particle system.
  89127. * SPS internal tool, don't use it manually.
  89128. */
  89129. export class ModelShape {
  89130. /**
  89131. * The shape id
  89132. * @hidden
  89133. */
  89134. shapeID: number;
  89135. /**
  89136. * flat array of model positions (internal use)
  89137. * @hidden
  89138. */
  89139. _shape: Vector3[];
  89140. /**
  89141. * flat array of model UVs (internal use)
  89142. * @hidden
  89143. */
  89144. _shapeUV: number[];
  89145. /**
  89146. * length of the shape in the model indices array (internal use)
  89147. * @hidden
  89148. */
  89149. _indicesLength: number;
  89150. /**
  89151. * Custom position function (internal use)
  89152. * @hidden
  89153. */
  89154. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  89155. /**
  89156. * Custom vertex function (internal use)
  89157. * @hidden
  89158. */
  89159. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  89160. /**
  89161. * 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.
  89162. * SPS internal tool, don't use it manually.
  89163. * @hidden
  89164. */
  89165. 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>);
  89166. }
  89167. /**
  89168. * Represents a Depth Sorted Particle in the solid particle system.
  89169. */
  89170. export class DepthSortedParticle {
  89171. /**
  89172. * Index of the particle in the "indices" array
  89173. */
  89174. ind: number;
  89175. /**
  89176. * Length of the particle shape in the "indices" array
  89177. */
  89178. indicesLength: number;
  89179. /**
  89180. * Squared distance from the particle to the camera
  89181. */
  89182. sqDistance: number;
  89183. }
  89184. }
  89185. declare module BABYLON {
  89186. /**
  89187. * @hidden
  89188. */
  89189. export class _MeshCollisionData {
  89190. _checkCollisions: boolean;
  89191. _collisionMask: number;
  89192. _collisionGroup: number;
  89193. _collider: Nullable<Collider>;
  89194. _oldPositionForCollisions: Vector3;
  89195. _diffPositionForCollisions: Vector3;
  89196. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  89197. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  89198. }
  89199. }
  89200. declare module BABYLON {
  89201. /** @hidden */
  89202. class _FacetDataStorage {
  89203. facetPositions: Vector3[];
  89204. facetNormals: Vector3[];
  89205. facetPartitioning: number[][];
  89206. facetNb: number;
  89207. partitioningSubdivisions: number;
  89208. partitioningBBoxRatio: number;
  89209. facetDataEnabled: boolean;
  89210. facetParameters: any;
  89211. bbSize: Vector3;
  89212. subDiv: {
  89213. max: number;
  89214. X: number;
  89215. Y: number;
  89216. Z: number;
  89217. };
  89218. facetDepthSort: boolean;
  89219. facetDepthSortEnabled: boolean;
  89220. depthSortedIndices: IndicesArray;
  89221. depthSortedFacets: {
  89222. ind: number;
  89223. sqDistance: number;
  89224. }[];
  89225. facetDepthSortFunction: (f1: {
  89226. ind: number;
  89227. sqDistance: number;
  89228. }, f2: {
  89229. ind: number;
  89230. sqDistance: number;
  89231. }) => number;
  89232. facetDepthSortFrom: Vector3;
  89233. facetDepthSortOrigin: Vector3;
  89234. invertedMatrix: Matrix;
  89235. }
  89236. /**
  89237. * @hidden
  89238. **/
  89239. class _InternalAbstractMeshDataInfo {
  89240. _hasVertexAlpha: boolean;
  89241. _useVertexColors: boolean;
  89242. _numBoneInfluencers: number;
  89243. _applyFog: boolean;
  89244. _receiveShadows: boolean;
  89245. _facetData: _FacetDataStorage;
  89246. _visibility: number;
  89247. _skeleton: Nullable<Skeleton>;
  89248. _layerMask: number;
  89249. _computeBonesUsingShaders: boolean;
  89250. _isActive: boolean;
  89251. _onlyForInstances: boolean;
  89252. _isActiveIntermediate: boolean;
  89253. _onlyForInstancesIntermediate: boolean;
  89254. }
  89255. /**
  89256. * Class used to store all common mesh properties
  89257. */
  89258. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  89259. /** No occlusion */
  89260. static OCCLUSION_TYPE_NONE: number;
  89261. /** Occlusion set to optimisitic */
  89262. static OCCLUSION_TYPE_OPTIMISTIC: number;
  89263. /** Occlusion set to strict */
  89264. static OCCLUSION_TYPE_STRICT: number;
  89265. /** Use an accurante occlusion algorithm */
  89266. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  89267. /** Use a conservative occlusion algorithm */
  89268. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  89269. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  89270. * Test order :
  89271. * Is the bounding sphere outside the frustum ?
  89272. * If not, are the bounding box vertices outside the frustum ?
  89273. * It not, then the cullable object is in the frustum.
  89274. */
  89275. static readonly CULLINGSTRATEGY_STANDARD: number;
  89276. /** Culling strategy : Bounding Sphere Only.
  89277. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  89278. * It's also less accurate than the standard because some not visible objects can still be selected.
  89279. * Test : is the bounding sphere outside the frustum ?
  89280. * If not, then the cullable object is in the frustum.
  89281. */
  89282. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  89283. /** Culling strategy : Optimistic Inclusion.
  89284. * This in an inclusion test first, then the standard exclusion test.
  89285. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  89286. * 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.
  89287. * Anyway, it's as accurate as the standard strategy.
  89288. * Test :
  89289. * Is the cullable object bounding sphere center in the frustum ?
  89290. * If not, apply the default culling strategy.
  89291. */
  89292. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  89293. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  89294. * This in an inclusion test first, then the bounding sphere only exclusion test.
  89295. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  89296. * 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.
  89297. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  89298. * Test :
  89299. * Is the cullable object bounding sphere center in the frustum ?
  89300. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  89301. */
  89302. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  89303. /**
  89304. * No billboard
  89305. */
  89306. static readonly BILLBOARDMODE_NONE: number;
  89307. /** Billboard on X axis */
  89308. static readonly BILLBOARDMODE_X: number;
  89309. /** Billboard on Y axis */
  89310. static readonly BILLBOARDMODE_Y: number;
  89311. /** Billboard on Z axis */
  89312. static readonly BILLBOARDMODE_Z: number;
  89313. /** Billboard on all axes */
  89314. static readonly BILLBOARDMODE_ALL: number;
  89315. /** @hidden */
  89316. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  89317. /**
  89318. * The culling strategy to use to check whether the mesh must be rendered or not.
  89319. * This value can be changed at any time and will be used on the next render mesh selection.
  89320. * The possible values are :
  89321. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  89322. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  89323. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  89324. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  89325. * Please read each static variable documentation to get details about the culling process.
  89326. * */
  89327. cullingStrategy: number;
  89328. /**
  89329. * Gets the number of facets in the mesh
  89330. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89331. */
  89332. readonly facetNb: number;
  89333. /**
  89334. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  89335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89336. */
  89337. partitioningSubdivisions: number;
  89338. /**
  89339. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  89340. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  89341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  89342. */
  89343. partitioningBBoxRatio: number;
  89344. /**
  89345. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  89346. * Works only for updatable meshes.
  89347. * Doesn't work with multi-materials
  89348. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89349. */
  89350. mustDepthSortFacets: boolean;
  89351. /**
  89352. * The location (Vector3) where the facet depth sort must be computed from.
  89353. * By default, the active camera position.
  89354. * Used only when facet depth sort is enabled
  89355. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  89356. */
  89357. facetDepthSortFrom: Vector3;
  89358. /**
  89359. * gets a boolean indicating if facetData is enabled
  89360. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  89361. */
  89362. readonly isFacetDataEnabled: boolean;
  89363. /** @hidden */
  89364. _updateNonUniformScalingState(value: boolean): boolean;
  89365. /**
  89366. * An event triggered when this mesh collides with another one
  89367. */
  89368. onCollideObservable: Observable<AbstractMesh>;
  89369. /** Set a function to call when this mesh collides with another one */
  89370. onCollide: () => void;
  89371. /**
  89372. * An event triggered when the collision's position changes
  89373. */
  89374. onCollisionPositionChangeObservable: Observable<Vector3>;
  89375. /** Set a function to call when the collision's position changes */
  89376. onCollisionPositionChange: () => void;
  89377. /**
  89378. * An event triggered when material is changed
  89379. */
  89380. onMaterialChangedObservable: Observable<AbstractMesh>;
  89381. /**
  89382. * Gets or sets the orientation for POV movement & rotation
  89383. */
  89384. definedFacingForward: boolean;
  89385. /** @hidden */
  89386. _occlusionQuery: Nullable<WebGLQuery>;
  89387. /** @hidden */
  89388. _renderingGroup: Nullable<RenderingGroup>;
  89389. /**
  89390. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89391. */
  89392. /**
  89393. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  89394. */
  89395. visibility: number;
  89396. /** Gets or sets the alpha index used to sort transparent meshes
  89397. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  89398. */
  89399. alphaIndex: number;
  89400. /**
  89401. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  89402. */
  89403. isVisible: boolean;
  89404. /**
  89405. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89406. */
  89407. isPickable: boolean;
  89408. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  89409. showSubMeshesBoundingBox: boolean;
  89410. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  89411. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  89412. */
  89413. isBlocker: boolean;
  89414. /**
  89415. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  89416. */
  89417. enablePointerMoveEvents: boolean;
  89418. /**
  89419. * Specifies the rendering group id for this mesh (0 by default)
  89420. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89421. */
  89422. renderingGroupId: number;
  89423. private _material;
  89424. /** Gets or sets current material */
  89425. material: Nullable<Material>;
  89426. /**
  89427. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  89428. * @see http://doc.babylonjs.com/babylon101/shadows
  89429. */
  89430. receiveShadows: boolean;
  89431. /** Defines color to use when rendering outline */
  89432. outlineColor: Color3;
  89433. /** Define width to use when rendering outline */
  89434. outlineWidth: number;
  89435. /** Defines color to use when rendering overlay */
  89436. overlayColor: Color3;
  89437. /** Defines alpha to use when rendering overlay */
  89438. overlayAlpha: number;
  89439. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  89440. hasVertexAlpha: boolean;
  89441. /** 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) */
  89442. useVertexColors: boolean;
  89443. /**
  89444. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  89445. */
  89446. computeBonesUsingShaders: boolean;
  89447. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  89448. numBoneInfluencers: number;
  89449. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  89450. applyFog: boolean;
  89451. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  89452. useOctreeForRenderingSelection: boolean;
  89453. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  89454. useOctreeForPicking: boolean;
  89455. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  89456. useOctreeForCollisions: boolean;
  89457. /**
  89458. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  89459. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  89460. */
  89461. layerMask: number;
  89462. /**
  89463. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  89464. */
  89465. alwaysSelectAsActiveMesh: boolean;
  89466. /**
  89467. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  89468. */
  89469. doNotSyncBoundingInfo: boolean;
  89470. /**
  89471. * Gets or sets the current action manager
  89472. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89473. */
  89474. actionManager: Nullable<AbstractActionManager>;
  89475. private _meshCollisionData;
  89476. /**
  89477. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  89478. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89479. */
  89480. ellipsoid: Vector3;
  89481. /**
  89482. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  89483. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89484. */
  89485. ellipsoidOffset: Vector3;
  89486. /**
  89487. * Gets or sets a collision mask used to mask collisions (default is -1).
  89488. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89489. */
  89490. collisionMask: number;
  89491. /**
  89492. * Gets or sets the current collision group mask (-1 by default).
  89493. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  89494. */
  89495. collisionGroup: number;
  89496. /**
  89497. * Defines edge width used when edgesRenderer is enabled
  89498. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89499. */
  89500. edgesWidth: number;
  89501. /**
  89502. * Defines edge color used when edgesRenderer is enabled
  89503. * @see https://www.babylonjs-playground.com/#10OJSG#13
  89504. */
  89505. edgesColor: Color4;
  89506. /** @hidden */
  89507. _edgesRenderer: Nullable<IEdgesRenderer>;
  89508. /** @hidden */
  89509. _masterMesh: Nullable<AbstractMesh>;
  89510. /** @hidden */
  89511. _boundingInfo: Nullable<BoundingInfo>;
  89512. /** @hidden */
  89513. _renderId: number;
  89514. /**
  89515. * Gets or sets the list of subMeshes
  89516. * @see http://doc.babylonjs.com/how_to/multi_materials
  89517. */
  89518. subMeshes: SubMesh[];
  89519. /** @hidden */
  89520. _intersectionsInProgress: AbstractMesh[];
  89521. /** @hidden */
  89522. _unIndexed: boolean;
  89523. /** @hidden */
  89524. _lightSources: Light[];
  89525. /** Gets the list of lights affecting that mesh */
  89526. readonly lightSources: Light[];
  89527. /** @hidden */
  89528. readonly _positions: Nullable<Vector3[]>;
  89529. /** @hidden */
  89530. _waitingData: {
  89531. lods: Nullable<any>;
  89532. actions: Nullable<any>;
  89533. freezeWorldMatrix: Nullable<boolean>;
  89534. };
  89535. /** @hidden */
  89536. _bonesTransformMatrices: Nullable<Float32Array>;
  89537. /** @hidden */
  89538. _transformMatrixTexture: Nullable<RawTexture>;
  89539. /**
  89540. * Gets or sets a skeleton to apply skining transformations
  89541. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89542. */
  89543. skeleton: Nullable<Skeleton>;
  89544. /**
  89545. * An event triggered when the mesh is rebuilt.
  89546. */
  89547. onRebuildObservable: Observable<AbstractMesh>;
  89548. /**
  89549. * Creates a new AbstractMesh
  89550. * @param name defines the name of the mesh
  89551. * @param scene defines the hosting scene
  89552. */
  89553. constructor(name: string, scene?: Nullable<Scene>);
  89554. /**
  89555. * Returns the string "AbstractMesh"
  89556. * @returns "AbstractMesh"
  89557. */
  89558. getClassName(): string;
  89559. /**
  89560. * Gets a string representation of the current mesh
  89561. * @param fullDetails defines a boolean indicating if full details must be included
  89562. * @returns a string representation of the current mesh
  89563. */
  89564. toString(fullDetails?: boolean): string;
  89565. /**
  89566. * @hidden
  89567. */
  89568. protected _getEffectiveParent(): Nullable<Node>;
  89569. /** @hidden */
  89570. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  89571. /** @hidden */
  89572. _rebuild(): void;
  89573. /** @hidden */
  89574. _resyncLightSources(): void;
  89575. /** @hidden */
  89576. _resyncLighSource(light: Light): void;
  89577. /** @hidden */
  89578. _unBindEffect(): void;
  89579. /** @hidden */
  89580. _removeLightSource(light: Light): void;
  89581. private _markSubMeshesAsDirty;
  89582. /** @hidden */
  89583. _markSubMeshesAsLightDirty(): void;
  89584. /** @hidden */
  89585. _markSubMeshesAsAttributesDirty(): void;
  89586. /** @hidden */
  89587. _markSubMeshesAsMiscDirty(): void;
  89588. /**
  89589. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  89590. */
  89591. scaling: Vector3;
  89592. /**
  89593. * Returns true if the mesh is blocked. Implemented by child classes
  89594. */
  89595. readonly isBlocked: boolean;
  89596. /**
  89597. * Returns the mesh itself by default. Implemented by child classes
  89598. * @param camera defines the camera to use to pick the right LOD level
  89599. * @returns the currentAbstractMesh
  89600. */
  89601. getLOD(camera: Camera): Nullable<AbstractMesh>;
  89602. /**
  89603. * Returns 0 by default. Implemented by child classes
  89604. * @returns an integer
  89605. */
  89606. getTotalVertices(): number;
  89607. /**
  89608. * Returns a positive integer : the total number of indices in this mesh geometry.
  89609. * @returns the numner of indices or zero if the mesh has no geometry.
  89610. */
  89611. getTotalIndices(): number;
  89612. /**
  89613. * Returns null by default. Implemented by child classes
  89614. * @returns null
  89615. */
  89616. getIndices(): Nullable<IndicesArray>;
  89617. /**
  89618. * Returns the array of the requested vertex data kind. Implemented by child classes
  89619. * @param kind defines the vertex data kind to use
  89620. * @returns null
  89621. */
  89622. getVerticesData(kind: string): Nullable<FloatArray>;
  89623. /**
  89624. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89625. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89626. * Note that a new underlying VertexBuffer object is created each call.
  89627. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89628. * @param kind defines vertex data kind:
  89629. * * VertexBuffer.PositionKind
  89630. * * VertexBuffer.UVKind
  89631. * * VertexBuffer.UV2Kind
  89632. * * VertexBuffer.UV3Kind
  89633. * * VertexBuffer.UV4Kind
  89634. * * VertexBuffer.UV5Kind
  89635. * * VertexBuffer.UV6Kind
  89636. * * VertexBuffer.ColorKind
  89637. * * VertexBuffer.MatricesIndicesKind
  89638. * * VertexBuffer.MatricesIndicesExtraKind
  89639. * * VertexBuffer.MatricesWeightsKind
  89640. * * VertexBuffer.MatricesWeightsExtraKind
  89641. * @param data defines the data source
  89642. * @param updatable defines if the data must be flagged as updatable (or static)
  89643. * @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
  89644. * @returns the current mesh
  89645. */
  89646. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89647. /**
  89648. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89649. * If the mesh has no geometry, it is simply returned as it is.
  89650. * @param kind defines vertex data kind:
  89651. * * VertexBuffer.PositionKind
  89652. * * VertexBuffer.UVKind
  89653. * * VertexBuffer.UV2Kind
  89654. * * VertexBuffer.UV3Kind
  89655. * * VertexBuffer.UV4Kind
  89656. * * VertexBuffer.UV5Kind
  89657. * * VertexBuffer.UV6Kind
  89658. * * VertexBuffer.ColorKind
  89659. * * VertexBuffer.MatricesIndicesKind
  89660. * * VertexBuffer.MatricesIndicesExtraKind
  89661. * * VertexBuffer.MatricesWeightsKind
  89662. * * VertexBuffer.MatricesWeightsExtraKind
  89663. * @param data defines the data source
  89664. * @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
  89665. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  89666. * @returns the current mesh
  89667. */
  89668. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  89669. /**
  89670. * Sets the mesh indices,
  89671. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89672. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  89673. * @param totalVertices Defines the total number of vertices
  89674. * @returns the current mesh
  89675. */
  89676. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  89677. /**
  89678. * Gets a boolean indicating if specific vertex data is present
  89679. * @param kind defines the vertex data kind to use
  89680. * @returns true is data kind is present
  89681. */
  89682. isVerticesDataPresent(kind: string): boolean;
  89683. /**
  89684. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  89685. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  89686. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  89687. * @returns a BoundingInfo
  89688. */
  89689. getBoundingInfo(): BoundingInfo;
  89690. /**
  89691. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  89692. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  89693. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  89694. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  89695. * @returns the current mesh
  89696. */
  89697. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  89698. /**
  89699. * Overwrite the current bounding info
  89700. * @param boundingInfo defines the new bounding info
  89701. * @returns the current mesh
  89702. */
  89703. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  89704. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  89705. readonly useBones: boolean;
  89706. /** @hidden */
  89707. _preActivate(): void;
  89708. /** @hidden */
  89709. _preActivateForIntermediateRendering(renderId: number): void;
  89710. /** @hidden */
  89711. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89712. /** @hidden */
  89713. _postActivate(): void;
  89714. /** @hidden */
  89715. _freeze(): void;
  89716. /** @hidden */
  89717. _unFreeze(): void;
  89718. /**
  89719. * Gets the current world matrix
  89720. * @returns a Matrix
  89721. */
  89722. getWorldMatrix(): Matrix;
  89723. /** @hidden */
  89724. _getWorldMatrixDeterminant(): number;
  89725. /**
  89726. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  89727. */
  89728. readonly isAnInstance: boolean;
  89729. /**
  89730. * Perform relative position change from the point of view of behind the front of the mesh.
  89731. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89732. * Supports definition of mesh facing forward or backward
  89733. * @param amountRight defines the distance on the right axis
  89734. * @param amountUp defines the distance on the up axis
  89735. * @param amountForward defines the distance on the forward axis
  89736. * @returns the current mesh
  89737. */
  89738. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  89739. /**
  89740. * Calculate relative position change from the point of view of behind the front of the mesh.
  89741. * This is performed taking into account the meshes current rotation, so you do not have to care.
  89742. * Supports definition of mesh facing forward or backward
  89743. * @param amountRight defines the distance on the right axis
  89744. * @param amountUp defines the distance on the up axis
  89745. * @param amountForward defines the distance on the forward axis
  89746. * @returns the new displacement vector
  89747. */
  89748. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  89749. /**
  89750. * Perform relative rotation change from the point of view of behind the front of the mesh.
  89751. * Supports definition of mesh facing forward or backward
  89752. * @param flipBack defines the flip
  89753. * @param twirlClockwise defines the twirl
  89754. * @param tiltRight defines the tilt
  89755. * @returns the current mesh
  89756. */
  89757. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  89758. /**
  89759. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  89760. * Supports definition of mesh facing forward or backward.
  89761. * @param flipBack defines the flip
  89762. * @param twirlClockwise defines the twirl
  89763. * @param tiltRight defines the tilt
  89764. * @returns the new rotation vector
  89765. */
  89766. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  89767. /**
  89768. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89769. * This means the mesh underlying bounding box and sphere are recomputed.
  89770. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89771. * @returns the current mesh
  89772. */
  89773. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  89774. /** @hidden */
  89775. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  89776. /** @hidden */
  89777. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  89778. /** @hidden */
  89779. _updateBoundingInfo(): AbstractMesh;
  89780. /** @hidden */
  89781. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  89782. /** @hidden */
  89783. protected _afterComputeWorldMatrix(): void;
  89784. /** @hidden */
  89785. readonly _effectiveMesh: AbstractMesh;
  89786. /**
  89787. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  89788. * A mesh is in the frustum if its bounding box intersects the frustum
  89789. * @param frustumPlanes defines the frustum to test
  89790. * @returns true if the mesh is in the frustum planes
  89791. */
  89792. isInFrustum(frustumPlanes: Plane[]): boolean;
  89793. /**
  89794. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  89795. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  89796. * @param frustumPlanes defines the frustum to test
  89797. * @returns true if the mesh is completely in the frustum planes
  89798. */
  89799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  89800. /**
  89801. * True if the mesh intersects another mesh or a SolidParticle object
  89802. * @param mesh defines a target mesh or SolidParticle to test
  89803. * @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)
  89804. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  89805. * @returns true if there is an intersection
  89806. */
  89807. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  89808. /**
  89809. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  89810. * @param point defines the point to test
  89811. * @returns true if there is an intersection
  89812. */
  89813. intersectsPoint(point: Vector3): boolean;
  89814. /**
  89815. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  89816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89817. */
  89818. checkCollisions: boolean;
  89819. /**
  89820. * Gets Collider object used to compute collisions (not physics)
  89821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89822. */
  89823. readonly collider: Nullable<Collider>;
  89824. /**
  89825. * Move the mesh using collision engine
  89826. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  89827. * @param displacement defines the requested displacement vector
  89828. * @returns the current mesh
  89829. */
  89830. moveWithCollisions(displacement: Vector3): AbstractMesh;
  89831. private _onCollisionPositionChange;
  89832. /** @hidden */
  89833. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  89834. /** @hidden */
  89835. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  89836. /** @hidden */
  89837. _checkCollision(collider: Collider): AbstractMesh;
  89838. /** @hidden */
  89839. _generatePointsArray(): boolean;
  89840. /**
  89841. * Checks if the passed Ray intersects with the mesh
  89842. * @param ray defines the ray to use
  89843. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  89844. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  89845. * @returns the picking info
  89846. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  89847. */
  89848. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  89849. /**
  89850. * Clones the current mesh
  89851. * @param name defines the mesh name
  89852. * @param newParent defines the new mesh parent
  89853. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  89854. * @returns the new mesh
  89855. */
  89856. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  89857. /**
  89858. * Disposes all the submeshes of the current meshnp
  89859. * @returns the current mesh
  89860. */
  89861. releaseSubMeshes(): AbstractMesh;
  89862. /**
  89863. * Releases resources associated with this abstract mesh.
  89864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89866. */
  89867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89868. /**
  89869. * Adds the passed mesh as a child to the current mesh
  89870. * @param mesh defines the child mesh
  89871. * @returns the current mesh
  89872. */
  89873. addChild(mesh: AbstractMesh): AbstractMesh;
  89874. /**
  89875. * Removes the passed mesh from the current mesh children list
  89876. * @param mesh defines the child mesh
  89877. * @returns the current mesh
  89878. */
  89879. removeChild(mesh: AbstractMesh): AbstractMesh;
  89880. /** @hidden */
  89881. private _initFacetData;
  89882. /**
  89883. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  89884. * This method can be called within the render loop.
  89885. * 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
  89886. * @returns the current mesh
  89887. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89888. */
  89889. updateFacetData(): AbstractMesh;
  89890. /**
  89891. * Returns the facetLocalNormals array.
  89892. * The normals are expressed in the mesh local spac
  89893. * @returns an array of Vector3
  89894. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89895. */
  89896. getFacetLocalNormals(): Vector3[];
  89897. /**
  89898. * Returns the facetLocalPositions array.
  89899. * The facet positions are expressed in the mesh local space
  89900. * @returns an array of Vector3
  89901. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89902. */
  89903. getFacetLocalPositions(): Vector3[];
  89904. /**
  89905. * Returns the facetLocalPartioning array
  89906. * @returns an array of array of numbers
  89907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89908. */
  89909. getFacetLocalPartitioning(): number[][];
  89910. /**
  89911. * Returns the i-th facet position in the world system.
  89912. * This method allocates a new Vector3 per call
  89913. * @param i defines the facet index
  89914. * @returns a new Vector3
  89915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89916. */
  89917. getFacetPosition(i: number): Vector3;
  89918. /**
  89919. * Sets the reference Vector3 with the i-th facet position in the world system
  89920. * @param i defines the facet index
  89921. * @param ref defines the target vector
  89922. * @returns the current mesh
  89923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89924. */
  89925. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  89926. /**
  89927. * Returns the i-th facet normal in the world system.
  89928. * This method allocates a new Vector3 per call
  89929. * @param i defines the facet index
  89930. * @returns a new Vector3
  89931. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89932. */
  89933. getFacetNormal(i: number): Vector3;
  89934. /**
  89935. * Sets the reference Vector3 with the i-th facet normal in the world system
  89936. * @param i defines the facet index
  89937. * @param ref defines the target vector
  89938. * @returns the current mesh
  89939. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89940. */
  89941. getFacetNormalToRef(i: number, ref: Vector3): this;
  89942. /**
  89943. * 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)
  89944. * @param x defines x coordinate
  89945. * @param y defines y coordinate
  89946. * @param z defines z coordinate
  89947. * @returns the array of facet indexes
  89948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89949. */
  89950. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  89951. /**
  89952. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  89953. * @param projected sets as the (x,y,z) world projection on the facet
  89954. * @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
  89955. * @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
  89956. * @param x defines x coordinate
  89957. * @param y defines y coordinate
  89958. * @param z defines z coordinate
  89959. * @returns the face index if found (or null instead)
  89960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89961. */
  89962. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89963. /**
  89964. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  89965. * @param projected sets as the (x,y,z) local projection on the facet
  89966. * @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
  89967. * @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
  89968. * @param x defines x coordinate
  89969. * @param y defines y coordinate
  89970. * @param z defines z coordinate
  89971. * @returns the face index if found (or null instead)
  89972. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89973. */
  89974. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  89975. /**
  89976. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  89977. * @returns the parameters
  89978. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89979. */
  89980. getFacetDataParameters(): any;
  89981. /**
  89982. * Disables the feature FacetData and frees the related memory
  89983. * @returns the current mesh
  89984. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  89985. */
  89986. disableFacetData(): AbstractMesh;
  89987. /**
  89988. * Updates the AbstractMesh indices array
  89989. * @param indices defines the data source
  89990. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  89991. * @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)
  89992. * @returns the current mesh
  89993. */
  89994. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  89995. /**
  89996. * Creates new normals data for the mesh
  89997. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  89998. * @returns the current mesh
  89999. */
  90000. createNormals(updatable: boolean): AbstractMesh;
  90001. /**
  90002. * Align the mesh with a normal
  90003. * @param normal defines the normal to use
  90004. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  90005. * @returns the current mesh
  90006. */
  90007. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  90008. /** @hidden */
  90009. _checkOcclusionQuery(): boolean;
  90010. /**
  90011. * Disables the mesh edge rendering mode
  90012. * @returns the currentAbstractMesh
  90013. */
  90014. disableEdgesRendering(): AbstractMesh;
  90015. /**
  90016. * Enables the edge rendering mode on the mesh.
  90017. * This mode makes the mesh edges visible
  90018. * @param epsilon defines the maximal distance between two angles to detect a face
  90019. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90020. * @returns the currentAbstractMesh
  90021. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90022. */
  90023. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90024. }
  90025. }
  90026. declare module BABYLON {
  90027. /**
  90028. * Interface used to define ActionEvent
  90029. */
  90030. export interface IActionEvent {
  90031. /** The mesh or sprite that triggered the action */
  90032. source: any;
  90033. /** The X mouse cursor position at the time of the event */
  90034. pointerX: number;
  90035. /** The Y mouse cursor position at the time of the event */
  90036. pointerY: number;
  90037. /** The mesh that is currently pointed at (can be null) */
  90038. meshUnderPointer: Nullable<AbstractMesh>;
  90039. /** the original (browser) event that triggered the ActionEvent */
  90040. sourceEvent?: any;
  90041. /** additional data for the event */
  90042. additionalData?: any;
  90043. }
  90044. /**
  90045. * ActionEvent is the event being sent when an action is triggered.
  90046. */
  90047. export class ActionEvent implements IActionEvent {
  90048. /** The mesh or sprite that triggered the action */
  90049. source: any;
  90050. /** The X mouse cursor position at the time of the event */
  90051. pointerX: number;
  90052. /** The Y mouse cursor position at the time of the event */
  90053. pointerY: number;
  90054. /** The mesh that is currently pointed at (can be null) */
  90055. meshUnderPointer: Nullable<AbstractMesh>;
  90056. /** the original (browser) event that triggered the ActionEvent */
  90057. sourceEvent?: any;
  90058. /** additional data for the event */
  90059. additionalData?: any;
  90060. /**
  90061. * Creates a new ActionEvent
  90062. * @param source The mesh or sprite that triggered the action
  90063. * @param pointerX The X mouse cursor position at the time of the event
  90064. * @param pointerY The Y mouse cursor position at the time of the event
  90065. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  90066. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  90067. * @param additionalData additional data for the event
  90068. */
  90069. constructor(
  90070. /** The mesh or sprite that triggered the action */
  90071. source: any,
  90072. /** The X mouse cursor position at the time of the event */
  90073. pointerX: number,
  90074. /** The Y mouse cursor position at the time of the event */
  90075. pointerY: number,
  90076. /** The mesh that is currently pointed at (can be null) */
  90077. meshUnderPointer: Nullable<AbstractMesh>,
  90078. /** the original (browser) event that triggered the ActionEvent */
  90079. sourceEvent?: any,
  90080. /** additional data for the event */
  90081. additionalData?: any);
  90082. /**
  90083. * Helper function to auto-create an ActionEvent from a source mesh.
  90084. * @param source The source mesh that triggered the event
  90085. * @param evt The original (browser) event
  90086. * @param additionalData additional data for the event
  90087. * @returns the new ActionEvent
  90088. */
  90089. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  90090. /**
  90091. * Helper function to auto-create an ActionEvent from a source sprite
  90092. * @param source The source sprite that triggered the event
  90093. * @param scene Scene associated with the sprite
  90094. * @param evt The original (browser) event
  90095. * @param additionalData additional data for the event
  90096. * @returns the new ActionEvent
  90097. */
  90098. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  90099. /**
  90100. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  90101. * @param scene the scene where the event occurred
  90102. * @param evt The original (browser) event
  90103. * @returns the new ActionEvent
  90104. */
  90105. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  90106. /**
  90107. * Helper function to auto-create an ActionEvent from a primitive
  90108. * @param prim defines the target primitive
  90109. * @param pointerPos defines the pointer position
  90110. * @param evt The original (browser) event
  90111. * @param additionalData additional data for the event
  90112. * @returns the new ActionEvent
  90113. */
  90114. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  90115. }
  90116. }
  90117. declare module BABYLON {
  90118. /**
  90119. * Abstract class used to decouple action Manager from scene and meshes.
  90120. * Do not instantiate.
  90121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90122. */
  90123. export abstract class AbstractActionManager implements IDisposable {
  90124. /** Gets the list of active triggers */
  90125. static Triggers: {
  90126. [key: string]: number;
  90127. };
  90128. /** Gets the cursor to use when hovering items */
  90129. hoverCursor: string;
  90130. /** Gets the list of actions */
  90131. actions: IAction[];
  90132. /**
  90133. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  90134. */
  90135. isRecursive: boolean;
  90136. /**
  90137. * Releases all associated resources
  90138. */
  90139. abstract dispose(): void;
  90140. /**
  90141. * Does this action manager has pointer triggers
  90142. */
  90143. abstract readonly hasPointerTriggers: boolean;
  90144. /**
  90145. * Does this action manager has pick triggers
  90146. */
  90147. abstract readonly hasPickTriggers: boolean;
  90148. /**
  90149. * Process a specific trigger
  90150. * @param trigger defines the trigger to process
  90151. * @param evt defines the event details to be processed
  90152. */
  90153. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  90154. /**
  90155. * Does this action manager handles actions of any of the given triggers
  90156. * @param triggers defines the triggers to be tested
  90157. * @return a boolean indicating whether one (or more) of the triggers is handled
  90158. */
  90159. abstract hasSpecificTriggers(triggers: number[]): boolean;
  90160. /**
  90161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90162. * speed.
  90163. * @param triggerA defines the trigger to be tested
  90164. * @param triggerB defines the trigger to be tested
  90165. * @return a boolean indicating whether one (or more) of the triggers is handled
  90166. */
  90167. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90168. /**
  90169. * Does this action manager handles actions of a given trigger
  90170. * @param trigger defines the trigger to be tested
  90171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90172. * @return whether the trigger is handled
  90173. */
  90174. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90175. /**
  90176. * Serialize this manager to a JSON object
  90177. * @param name defines the property name to store this manager
  90178. * @returns a JSON representation of this manager
  90179. */
  90180. abstract serialize(name: string): any;
  90181. /**
  90182. * Registers an action to this action manager
  90183. * @param action defines the action to be registered
  90184. * @return the action amended (prepared) after registration
  90185. */
  90186. abstract registerAction(action: IAction): Nullable<IAction>;
  90187. /**
  90188. * Unregisters an action to this action manager
  90189. * @param action defines the action to be unregistered
  90190. * @return a boolean indicating whether the action has been unregistered
  90191. */
  90192. abstract unregisterAction(action: IAction): Boolean;
  90193. /**
  90194. * Does exist one action manager with at least one trigger
  90195. **/
  90196. static readonly HasTriggers: boolean;
  90197. /**
  90198. * Does exist one action manager with at least one pick trigger
  90199. **/
  90200. static readonly HasPickTriggers: boolean;
  90201. /**
  90202. * Does exist one action manager that handles actions of a given trigger
  90203. * @param trigger defines the trigger to be tested
  90204. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  90205. **/
  90206. static HasSpecificTrigger(trigger: number): boolean;
  90207. }
  90208. }
  90209. declare module BABYLON {
  90210. /**
  90211. * Defines how a node can be built from a string name.
  90212. */
  90213. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  90214. /**
  90215. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  90216. */
  90217. export class Node implements IBehaviorAware<Node> {
  90218. /** @hidden */
  90219. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  90220. private static _NodeConstructors;
  90221. /**
  90222. * Add a new node constructor
  90223. * @param type defines the type name of the node to construct
  90224. * @param constructorFunc defines the constructor function
  90225. */
  90226. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  90227. /**
  90228. * Returns a node constructor based on type name
  90229. * @param type defines the type name
  90230. * @param name defines the new node name
  90231. * @param scene defines the hosting scene
  90232. * @param options defines optional options to transmit to constructors
  90233. * @returns the new constructor or null
  90234. */
  90235. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  90236. /**
  90237. * Gets or sets the name of the node
  90238. */
  90239. name: string;
  90240. /**
  90241. * Gets or sets the id of the node
  90242. */
  90243. id: string;
  90244. /**
  90245. * Gets or sets the unique id of the node
  90246. */
  90247. uniqueId: number;
  90248. /**
  90249. * Gets or sets a string used to store user defined state for the node
  90250. */
  90251. state: string;
  90252. /**
  90253. * Gets or sets an object used to store user defined information for the node
  90254. */
  90255. metadata: any;
  90256. /**
  90257. * For internal use only. Please do not use.
  90258. */
  90259. reservedDataStore: any;
  90260. /**
  90261. * List of inspectable custom properties (used by the Inspector)
  90262. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  90263. */
  90264. inspectableCustomProperties: IInspectable[];
  90265. /**
  90266. * Gets or sets a boolean used to define if the node must be serialized
  90267. */
  90268. doNotSerialize: boolean;
  90269. /** @hidden */
  90270. _isDisposed: boolean;
  90271. /**
  90272. * Gets a list of Animations associated with the node
  90273. */
  90274. animations: Animation[];
  90275. protected _ranges: {
  90276. [name: string]: Nullable<AnimationRange>;
  90277. };
  90278. /**
  90279. * Callback raised when the node is ready to be used
  90280. */
  90281. onReady: Nullable<(node: Node) => void>;
  90282. private _isEnabled;
  90283. private _isParentEnabled;
  90284. private _isReady;
  90285. /** @hidden */
  90286. _currentRenderId: number;
  90287. private _parentUpdateId;
  90288. /** @hidden */
  90289. _childUpdateId: number;
  90290. /** @hidden */
  90291. _waitingParentId: Nullable<string>;
  90292. /** @hidden */
  90293. _scene: Scene;
  90294. /** @hidden */
  90295. _cache: any;
  90296. private _parentNode;
  90297. private _children;
  90298. /** @hidden */
  90299. _worldMatrix: Matrix;
  90300. /** @hidden */
  90301. _worldMatrixDeterminant: number;
  90302. /** @hidden */
  90303. _worldMatrixDeterminantIsDirty: boolean;
  90304. /** @hidden */
  90305. private _sceneRootNodesIndex;
  90306. /**
  90307. * Gets a boolean indicating if the node has been disposed
  90308. * @returns true if the node was disposed
  90309. */
  90310. isDisposed(): boolean;
  90311. /**
  90312. * Gets or sets the parent of the node (without keeping the current position in the scene)
  90313. * @see https://doc.babylonjs.com/how_to/parenting
  90314. */
  90315. parent: Nullable<Node>;
  90316. private addToSceneRootNodes;
  90317. private removeFromSceneRootNodes;
  90318. private _animationPropertiesOverride;
  90319. /**
  90320. * Gets or sets the animation properties override
  90321. */
  90322. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  90323. /**
  90324. * Gets a string idenfifying the name of the class
  90325. * @returns "Node" string
  90326. */
  90327. getClassName(): string;
  90328. /** @hidden */
  90329. readonly _isNode: boolean;
  90330. /**
  90331. * An event triggered when the mesh is disposed
  90332. */
  90333. onDisposeObservable: Observable<Node>;
  90334. private _onDisposeObserver;
  90335. /**
  90336. * Sets a callback that will be raised when the node will be disposed
  90337. */
  90338. onDispose: () => void;
  90339. /**
  90340. * Creates a new Node
  90341. * @param name the name and id to be given to this node
  90342. * @param scene the scene this node will be added to
  90343. * @param addToRootNodes the node will be added to scene.rootNodes
  90344. */
  90345. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  90346. /**
  90347. * Gets the scene of the node
  90348. * @returns a scene
  90349. */
  90350. getScene(): Scene;
  90351. /**
  90352. * Gets the engine of the node
  90353. * @returns a Engine
  90354. */
  90355. getEngine(): Engine;
  90356. private _behaviors;
  90357. /**
  90358. * Attach a behavior to the node
  90359. * @see http://doc.babylonjs.com/features/behaviour
  90360. * @param behavior defines the behavior to attach
  90361. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  90362. * @returns the current Node
  90363. */
  90364. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  90365. /**
  90366. * Remove an attached behavior
  90367. * @see http://doc.babylonjs.com/features/behaviour
  90368. * @param behavior defines the behavior to attach
  90369. * @returns the current Node
  90370. */
  90371. removeBehavior(behavior: Behavior<Node>): Node;
  90372. /**
  90373. * Gets the list of attached behaviors
  90374. * @see http://doc.babylonjs.com/features/behaviour
  90375. */
  90376. readonly behaviors: Behavior<Node>[];
  90377. /**
  90378. * Gets an attached behavior by name
  90379. * @param name defines the name of the behavior to look for
  90380. * @see http://doc.babylonjs.com/features/behaviour
  90381. * @returns null if behavior was not found else the requested behavior
  90382. */
  90383. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  90384. /**
  90385. * Returns the latest update of the World matrix
  90386. * @returns a Matrix
  90387. */
  90388. getWorldMatrix(): Matrix;
  90389. /** @hidden */
  90390. _getWorldMatrixDeterminant(): number;
  90391. /**
  90392. * Returns directly the latest state of the mesh World matrix.
  90393. * A Matrix is returned.
  90394. */
  90395. readonly worldMatrixFromCache: Matrix;
  90396. /** @hidden */
  90397. _initCache(): void;
  90398. /** @hidden */
  90399. updateCache(force?: boolean): void;
  90400. /** @hidden */
  90401. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  90402. /** @hidden */
  90403. _updateCache(ignoreParentClass?: boolean): void;
  90404. /** @hidden */
  90405. _isSynchronized(): boolean;
  90406. /** @hidden */
  90407. _markSyncedWithParent(): void;
  90408. /** @hidden */
  90409. isSynchronizedWithParent(): boolean;
  90410. /** @hidden */
  90411. isSynchronized(): boolean;
  90412. /**
  90413. * Is this node ready to be used/rendered
  90414. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90415. * @return true if the node is ready
  90416. */
  90417. isReady(completeCheck?: boolean): boolean;
  90418. /**
  90419. * Is this node enabled?
  90420. * 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
  90421. * @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
  90422. * @return whether this node (and its parent) is enabled
  90423. */
  90424. isEnabled(checkAncestors?: boolean): boolean;
  90425. /** @hidden */
  90426. protected _syncParentEnabledState(): void;
  90427. /**
  90428. * Set the enabled state of this node
  90429. * @param value defines the new enabled state
  90430. */
  90431. setEnabled(value: boolean): void;
  90432. /**
  90433. * Is this node a descendant of the given node?
  90434. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  90435. * @param ancestor defines the parent node to inspect
  90436. * @returns a boolean indicating if this node is a descendant of the given node
  90437. */
  90438. isDescendantOf(ancestor: Node): boolean;
  90439. /** @hidden */
  90440. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  90441. /**
  90442. * Will return all nodes that have this node as ascendant
  90443. * @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
  90444. * @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
  90445. * @return all children nodes of all types
  90446. */
  90447. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  90448. /**
  90449. * Get all child-meshes of this node
  90450. * @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)
  90451. * @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
  90452. * @returns an array of AbstractMesh
  90453. */
  90454. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  90455. /**
  90456. * Get all direct children of this node
  90457. * @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
  90458. * @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)
  90459. * @returns an array of Node
  90460. */
  90461. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  90462. /** @hidden */
  90463. _setReady(state: boolean): void;
  90464. /**
  90465. * Get an animation by name
  90466. * @param name defines the name of the animation to look for
  90467. * @returns null if not found else the requested animation
  90468. */
  90469. getAnimationByName(name: string): Nullable<Animation>;
  90470. /**
  90471. * Creates an animation range for this node
  90472. * @param name defines the name of the range
  90473. * @param from defines the starting key
  90474. * @param to defines the end key
  90475. */
  90476. createAnimationRange(name: string, from: number, to: number): void;
  90477. /**
  90478. * Delete a specific animation range
  90479. * @param name defines the name of the range to delete
  90480. * @param deleteFrames defines if animation frames from the range must be deleted as well
  90481. */
  90482. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  90483. /**
  90484. * Get an animation range by name
  90485. * @param name defines the name of the animation range to look for
  90486. * @returns null if not found else the requested animation range
  90487. */
  90488. getAnimationRange(name: string): Nullable<AnimationRange>;
  90489. /**
  90490. * Gets the list of all animation ranges defined on this node
  90491. * @returns an array
  90492. */
  90493. getAnimationRanges(): Nullable<AnimationRange>[];
  90494. /**
  90495. * Will start the animation sequence
  90496. * @param name defines the range frames for animation sequence
  90497. * @param loop defines if the animation should loop (false by default)
  90498. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  90499. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  90500. * @returns the object created for this animation. If range does not exist, it will return null
  90501. */
  90502. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  90503. /**
  90504. * Serialize animation ranges into a JSON compatible object
  90505. * @returns serialization object
  90506. */
  90507. serializeAnimationRanges(): any;
  90508. /**
  90509. * Computes the world matrix of the node
  90510. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90511. * @returns the world matrix
  90512. */
  90513. computeWorldMatrix(force?: boolean): Matrix;
  90514. /**
  90515. * Releases resources associated with this node.
  90516. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90517. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90518. */
  90519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90520. /**
  90521. * Parse animation range data from a serialization object and store them into a given node
  90522. * @param node defines where to store the animation ranges
  90523. * @param parsedNode defines the serialization object to read data from
  90524. * @param scene defines the hosting scene
  90525. */
  90526. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  90527. /**
  90528. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  90529. * @param includeDescendants Include bounding info from descendants as well (true by default)
  90530. * @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
  90531. * @returns the new bounding vectors
  90532. */
  90533. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  90534. min: Vector3;
  90535. max: Vector3;
  90536. };
  90537. }
  90538. }
  90539. declare module BABYLON {
  90540. /**
  90541. * @hidden
  90542. */
  90543. export class _IAnimationState {
  90544. key: number;
  90545. repeatCount: number;
  90546. workValue?: any;
  90547. loopMode?: number;
  90548. offsetValue?: any;
  90549. highLimitValue?: any;
  90550. }
  90551. /**
  90552. * Class used to store any kind of animation
  90553. */
  90554. export class Animation {
  90555. /**Name of the animation */
  90556. name: string;
  90557. /**Property to animate */
  90558. targetProperty: string;
  90559. /**The frames per second of the animation */
  90560. framePerSecond: number;
  90561. /**The data type of the animation */
  90562. dataType: number;
  90563. /**The loop mode of the animation */
  90564. loopMode?: number | undefined;
  90565. /**Specifies if blending should be enabled */
  90566. enableBlending?: boolean | undefined;
  90567. /**
  90568. * Use matrix interpolation instead of using direct key value when animating matrices
  90569. */
  90570. static AllowMatricesInterpolation: boolean;
  90571. /**
  90572. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  90573. */
  90574. static AllowMatrixDecomposeForInterpolation: boolean;
  90575. /**
  90576. * Stores the key frames of the animation
  90577. */
  90578. private _keys;
  90579. /**
  90580. * Stores the easing function of the animation
  90581. */
  90582. private _easingFunction;
  90583. /**
  90584. * @hidden Internal use only
  90585. */
  90586. _runtimeAnimations: RuntimeAnimation[];
  90587. /**
  90588. * The set of event that will be linked to this animation
  90589. */
  90590. private _events;
  90591. /**
  90592. * Stores an array of target property paths
  90593. */
  90594. targetPropertyPath: string[];
  90595. /**
  90596. * Stores the blending speed of the animation
  90597. */
  90598. blendingSpeed: number;
  90599. /**
  90600. * Stores the animation ranges for the animation
  90601. */
  90602. private _ranges;
  90603. /**
  90604. * @hidden Internal use
  90605. */
  90606. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  90607. /**
  90608. * Sets up an animation
  90609. * @param property The property to animate
  90610. * @param animationType The animation type to apply
  90611. * @param framePerSecond The frames per second of the animation
  90612. * @param easingFunction The easing function used in the animation
  90613. * @returns The created animation
  90614. */
  90615. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  90616. /**
  90617. * Create and start an animation on a node
  90618. * @param name defines the name of the global animation that will be run on all nodes
  90619. * @param node defines the root node where the animation will take place
  90620. * @param targetProperty defines property to animate
  90621. * @param framePerSecond defines the number of frame per second yo use
  90622. * @param totalFrame defines the number of frames in total
  90623. * @param from defines the initial value
  90624. * @param to defines the final value
  90625. * @param loopMode defines which loop mode you want to use (off by default)
  90626. * @param easingFunction defines the easing function to use (linear by default)
  90627. * @param onAnimationEnd defines the callback to call when animation end
  90628. * @returns the animatable created for this animation
  90629. */
  90630. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90631. /**
  90632. * Create and start an animation on a node and its descendants
  90633. * @param name defines the name of the global animation that will be run on all nodes
  90634. * @param node defines the root node where the animation will take place
  90635. * @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
  90636. * @param targetProperty defines property to animate
  90637. * @param framePerSecond defines the number of frame per second to use
  90638. * @param totalFrame defines the number of frames in total
  90639. * @param from defines the initial value
  90640. * @param to defines the final value
  90641. * @param loopMode defines which loop mode you want to use (off by default)
  90642. * @param easingFunction defines the easing function to use (linear by default)
  90643. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  90644. * @returns the list of animatables created for all nodes
  90645. * @example https://www.babylonjs-playground.com/#MH0VLI
  90646. */
  90647. 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[]>;
  90648. /**
  90649. * Creates a new animation, merges it with the existing animations and starts it
  90650. * @param name Name of the animation
  90651. * @param node Node which contains the scene that begins the animations
  90652. * @param targetProperty Specifies which property to animate
  90653. * @param framePerSecond The frames per second of the animation
  90654. * @param totalFrame The total number of frames
  90655. * @param from The frame at the beginning of the animation
  90656. * @param to The frame at the end of the animation
  90657. * @param loopMode Specifies the loop mode of the animation
  90658. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  90659. * @param onAnimationEnd Callback to run once the animation is complete
  90660. * @returns Nullable animation
  90661. */
  90662. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  90663. /**
  90664. * Transition property of an host to the target Value
  90665. * @param property The property to transition
  90666. * @param targetValue The target Value of the property
  90667. * @param host The object where the property to animate belongs
  90668. * @param scene Scene used to run the animation
  90669. * @param frameRate Framerate (in frame/s) to use
  90670. * @param transition The transition type we want to use
  90671. * @param duration The duration of the animation, in milliseconds
  90672. * @param onAnimationEnd Callback trigger at the end of the animation
  90673. * @returns Nullable animation
  90674. */
  90675. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  90676. /**
  90677. * Return the array of runtime animations currently using this animation
  90678. */
  90679. readonly runtimeAnimations: RuntimeAnimation[];
  90680. /**
  90681. * Specifies if any of the runtime animations are currently running
  90682. */
  90683. readonly hasRunningRuntimeAnimations: boolean;
  90684. /**
  90685. * Initializes the animation
  90686. * @param name Name of the animation
  90687. * @param targetProperty Property to animate
  90688. * @param framePerSecond The frames per second of the animation
  90689. * @param dataType The data type of the animation
  90690. * @param loopMode The loop mode of the animation
  90691. * @param enableBlending Specifies if blending should be enabled
  90692. */
  90693. constructor(
  90694. /**Name of the animation */
  90695. name: string,
  90696. /**Property to animate */
  90697. targetProperty: string,
  90698. /**The frames per second of the animation */
  90699. framePerSecond: number,
  90700. /**The data type of the animation */
  90701. dataType: number,
  90702. /**The loop mode of the animation */
  90703. loopMode?: number | undefined,
  90704. /**Specifies if blending should be enabled */
  90705. enableBlending?: boolean | undefined);
  90706. /**
  90707. * Converts the animation to a string
  90708. * @param fullDetails support for multiple levels of logging within scene loading
  90709. * @returns String form of the animation
  90710. */
  90711. toString(fullDetails?: boolean): string;
  90712. /**
  90713. * Add an event to this animation
  90714. * @param event Event to add
  90715. */
  90716. addEvent(event: AnimationEvent): void;
  90717. /**
  90718. * Remove all events found at the given frame
  90719. * @param frame The frame to remove events from
  90720. */
  90721. removeEvents(frame: number): void;
  90722. /**
  90723. * Retrieves all the events from the animation
  90724. * @returns Events from the animation
  90725. */
  90726. getEvents(): AnimationEvent[];
  90727. /**
  90728. * Creates an animation range
  90729. * @param name Name of the animation range
  90730. * @param from Starting frame of the animation range
  90731. * @param to Ending frame of the animation
  90732. */
  90733. createRange(name: string, from: number, to: number): void;
  90734. /**
  90735. * Deletes an animation range by name
  90736. * @param name Name of the animation range to delete
  90737. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  90738. */
  90739. deleteRange(name: string, deleteFrames?: boolean): void;
  90740. /**
  90741. * Gets the animation range by name, or null if not defined
  90742. * @param name Name of the animation range
  90743. * @returns Nullable animation range
  90744. */
  90745. getRange(name: string): Nullable<AnimationRange>;
  90746. /**
  90747. * Gets the key frames from the animation
  90748. * @returns The key frames of the animation
  90749. */
  90750. getKeys(): Array<IAnimationKey>;
  90751. /**
  90752. * Gets the highest frame rate of the animation
  90753. * @returns Highest frame rate of the animation
  90754. */
  90755. getHighestFrame(): number;
  90756. /**
  90757. * Gets the easing function of the animation
  90758. * @returns Easing function of the animation
  90759. */
  90760. getEasingFunction(): IEasingFunction;
  90761. /**
  90762. * Sets the easing function of the animation
  90763. * @param easingFunction A custom mathematical formula for animation
  90764. */
  90765. setEasingFunction(easingFunction: EasingFunction): void;
  90766. /**
  90767. * Interpolates a scalar linearly
  90768. * @param startValue Start value of the animation curve
  90769. * @param endValue End value of the animation curve
  90770. * @param gradient Scalar amount to interpolate
  90771. * @returns Interpolated scalar value
  90772. */
  90773. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  90774. /**
  90775. * Interpolates a scalar cubically
  90776. * @param startValue Start value of the animation curve
  90777. * @param outTangent End tangent of the animation
  90778. * @param endValue End value of the animation curve
  90779. * @param inTangent Start tangent of the animation curve
  90780. * @param gradient Scalar amount to interpolate
  90781. * @returns Interpolated scalar value
  90782. */
  90783. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  90784. /**
  90785. * Interpolates a quaternion using a spherical linear interpolation
  90786. * @param startValue Start value of the animation curve
  90787. * @param endValue End value of the animation curve
  90788. * @param gradient Scalar amount to interpolate
  90789. * @returns Interpolated quaternion value
  90790. */
  90791. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  90792. /**
  90793. * Interpolates a quaternion cubically
  90794. * @param startValue Start value of the animation curve
  90795. * @param outTangent End tangent of the animation curve
  90796. * @param endValue End value of the animation curve
  90797. * @param inTangent Start tangent of the animation curve
  90798. * @param gradient Scalar amount to interpolate
  90799. * @returns Interpolated quaternion value
  90800. */
  90801. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  90802. /**
  90803. * Interpolates a Vector3 linearl
  90804. * @param startValue Start value of the animation curve
  90805. * @param endValue End value of the animation curve
  90806. * @param gradient Scalar amount to interpolate
  90807. * @returns Interpolated scalar value
  90808. */
  90809. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  90810. /**
  90811. * Interpolates a Vector3 cubically
  90812. * @param startValue Start value of the animation curve
  90813. * @param outTangent End tangent of the animation
  90814. * @param endValue End value of the animation curve
  90815. * @param inTangent Start tangent of the animation curve
  90816. * @param gradient Scalar amount to interpolate
  90817. * @returns InterpolatedVector3 value
  90818. */
  90819. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  90820. /**
  90821. * Interpolates a Vector2 linearly
  90822. * @param startValue Start value of the animation curve
  90823. * @param endValue End value of the animation curve
  90824. * @param gradient Scalar amount to interpolate
  90825. * @returns Interpolated Vector2 value
  90826. */
  90827. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  90828. /**
  90829. * Interpolates a Vector2 cubically
  90830. * @param startValue Start value of the animation curve
  90831. * @param outTangent End tangent of the animation
  90832. * @param endValue End value of the animation curve
  90833. * @param inTangent Start tangent of the animation curve
  90834. * @param gradient Scalar amount to interpolate
  90835. * @returns Interpolated Vector2 value
  90836. */
  90837. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  90838. /**
  90839. * Interpolates a size linearly
  90840. * @param startValue Start value of the animation curve
  90841. * @param endValue End value of the animation curve
  90842. * @param gradient Scalar amount to interpolate
  90843. * @returns Interpolated Size value
  90844. */
  90845. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  90846. /**
  90847. * Interpolates a Color3 linearly
  90848. * @param startValue Start value of the animation curve
  90849. * @param endValue End value of the animation curve
  90850. * @param gradient Scalar amount to interpolate
  90851. * @returns Interpolated Color3 value
  90852. */
  90853. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  90854. /**
  90855. * @hidden Internal use only
  90856. */
  90857. _getKeyValue(value: any): any;
  90858. /**
  90859. * @hidden Internal use only
  90860. */
  90861. _interpolate(currentFrame: number, state: _IAnimationState): any;
  90862. /**
  90863. * Defines the function to use to interpolate matrices
  90864. * @param startValue defines the start matrix
  90865. * @param endValue defines the end matrix
  90866. * @param gradient defines the gradient between both matrices
  90867. * @param result defines an optional target matrix where to store the interpolation
  90868. * @returns the interpolated matrix
  90869. */
  90870. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  90871. /**
  90872. * Makes a copy of the animation
  90873. * @returns Cloned animation
  90874. */
  90875. clone(): Animation;
  90876. /**
  90877. * Sets the key frames of the animation
  90878. * @param values The animation key frames to set
  90879. */
  90880. setKeys(values: Array<IAnimationKey>): void;
  90881. /**
  90882. * Serializes the animation to an object
  90883. * @returns Serialized object
  90884. */
  90885. serialize(): any;
  90886. /**
  90887. * Float animation type
  90888. */
  90889. private static _ANIMATIONTYPE_FLOAT;
  90890. /**
  90891. * Vector3 animation type
  90892. */
  90893. private static _ANIMATIONTYPE_VECTOR3;
  90894. /**
  90895. * Quaternion animation type
  90896. */
  90897. private static _ANIMATIONTYPE_QUATERNION;
  90898. /**
  90899. * Matrix animation type
  90900. */
  90901. private static _ANIMATIONTYPE_MATRIX;
  90902. /**
  90903. * Color3 animation type
  90904. */
  90905. private static _ANIMATIONTYPE_COLOR3;
  90906. /**
  90907. * Vector2 animation type
  90908. */
  90909. private static _ANIMATIONTYPE_VECTOR2;
  90910. /**
  90911. * Size animation type
  90912. */
  90913. private static _ANIMATIONTYPE_SIZE;
  90914. /**
  90915. * Relative Loop Mode
  90916. */
  90917. private static _ANIMATIONLOOPMODE_RELATIVE;
  90918. /**
  90919. * Cycle Loop Mode
  90920. */
  90921. private static _ANIMATIONLOOPMODE_CYCLE;
  90922. /**
  90923. * Constant Loop Mode
  90924. */
  90925. private static _ANIMATIONLOOPMODE_CONSTANT;
  90926. /**
  90927. * Get the float animation type
  90928. */
  90929. static readonly ANIMATIONTYPE_FLOAT: number;
  90930. /**
  90931. * Get the Vector3 animation type
  90932. */
  90933. static readonly ANIMATIONTYPE_VECTOR3: number;
  90934. /**
  90935. * Get the Vector2 animation type
  90936. */
  90937. static readonly ANIMATIONTYPE_VECTOR2: number;
  90938. /**
  90939. * Get the Size animation type
  90940. */
  90941. static readonly ANIMATIONTYPE_SIZE: number;
  90942. /**
  90943. * Get the Quaternion animation type
  90944. */
  90945. static readonly ANIMATIONTYPE_QUATERNION: number;
  90946. /**
  90947. * Get the Matrix animation type
  90948. */
  90949. static readonly ANIMATIONTYPE_MATRIX: number;
  90950. /**
  90951. * Get the Color3 animation type
  90952. */
  90953. static readonly ANIMATIONTYPE_COLOR3: number;
  90954. /**
  90955. * Get the Relative Loop Mode
  90956. */
  90957. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  90958. /**
  90959. * Get the Cycle Loop Mode
  90960. */
  90961. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  90962. /**
  90963. * Get the Constant Loop Mode
  90964. */
  90965. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  90966. /** @hidden */
  90967. static _UniversalLerp(left: any, right: any, amount: number): any;
  90968. /**
  90969. * Parses an animation object and creates an animation
  90970. * @param parsedAnimation Parsed animation object
  90971. * @returns Animation object
  90972. */
  90973. static Parse(parsedAnimation: any): Animation;
  90974. /**
  90975. * Appends the serialized animations from the source animations
  90976. * @param source Source containing the animations
  90977. * @param destination Target to store the animations
  90978. */
  90979. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  90980. }
  90981. }
  90982. declare module BABYLON {
  90983. /**
  90984. * Interface containing an array of animations
  90985. */
  90986. export interface IAnimatable {
  90987. /**
  90988. * Array of animations
  90989. */
  90990. animations: Nullable<Array<Animation>>;
  90991. }
  90992. }
  90993. declare module BABYLON {
  90994. /**
  90995. * This represents all the required information to add a fresnel effect on a material:
  90996. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  90997. */
  90998. export class FresnelParameters {
  90999. private _isEnabled;
  91000. /**
  91001. * Define if the fresnel effect is enable or not.
  91002. */
  91003. isEnabled: boolean;
  91004. /**
  91005. * Define the color used on edges (grazing angle)
  91006. */
  91007. leftColor: Color3;
  91008. /**
  91009. * Define the color used on center
  91010. */
  91011. rightColor: Color3;
  91012. /**
  91013. * Define bias applied to computed fresnel term
  91014. */
  91015. bias: number;
  91016. /**
  91017. * Defined the power exponent applied to fresnel term
  91018. */
  91019. power: number;
  91020. /**
  91021. * Clones the current fresnel and its valuues
  91022. * @returns a clone fresnel configuration
  91023. */
  91024. clone(): FresnelParameters;
  91025. /**
  91026. * Serializes the current fresnel parameters to a JSON representation.
  91027. * @return the JSON serialization
  91028. */
  91029. serialize(): any;
  91030. /**
  91031. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  91032. * @param parsedFresnelParameters Define the JSON representation
  91033. * @returns the parsed parameters
  91034. */
  91035. static Parse(parsedFresnelParameters: any): FresnelParameters;
  91036. }
  91037. }
  91038. declare module BABYLON {
  91039. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  91040. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91041. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91042. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91043. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91044. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91045. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91046. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91047. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91048. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91049. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91050. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91051. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91052. /**
  91053. * Decorator used to define property that can be serialized as reference to a camera
  91054. * @param sourceName defines the name of the property to decorate
  91055. */
  91056. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  91057. /**
  91058. * Class used to help serialization objects
  91059. */
  91060. export class SerializationHelper {
  91061. /** @hidden */
  91062. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  91063. /** @hidden */
  91064. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  91065. /** @hidden */
  91066. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  91067. /** @hidden */
  91068. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  91069. /**
  91070. * Appends the serialized animations from the source animations
  91071. * @param source Source containing the animations
  91072. * @param destination Target to store the animations
  91073. */
  91074. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  91075. /**
  91076. * Static function used to serialized a specific entity
  91077. * @param entity defines the entity to serialize
  91078. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  91079. * @returns a JSON compatible object representing the serialization of the entity
  91080. */
  91081. static Serialize<T>(entity: T, serializationObject?: any): any;
  91082. /**
  91083. * Creates a new entity from a serialization data object
  91084. * @param creationFunction defines a function used to instanciated the new entity
  91085. * @param source defines the source serialization data
  91086. * @param scene defines the hosting scene
  91087. * @param rootUrl defines the root url for resources
  91088. * @returns a new entity
  91089. */
  91090. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  91091. /**
  91092. * Clones an object
  91093. * @param creationFunction defines the function used to instanciate the new object
  91094. * @param source defines the source object
  91095. * @returns the cloned object
  91096. */
  91097. static Clone<T>(creationFunction: () => T, source: T): T;
  91098. /**
  91099. * Instanciates a new object based on a source one (some data will be shared between both object)
  91100. * @param creationFunction defines the function used to instanciate the new object
  91101. * @param source defines the source object
  91102. * @returns the new object
  91103. */
  91104. static Instanciate<T>(creationFunction: () => T, source: T): T;
  91105. }
  91106. }
  91107. declare module BABYLON {
  91108. /**
  91109. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  91110. */
  91111. export interface CubeMapInfo {
  91112. /**
  91113. * The pixel array for the front face.
  91114. * This is stored in format, left to right, up to down format.
  91115. */
  91116. front: Nullable<ArrayBufferView>;
  91117. /**
  91118. * The pixel array for the back face.
  91119. * This is stored in format, left to right, up to down format.
  91120. */
  91121. back: Nullable<ArrayBufferView>;
  91122. /**
  91123. * The pixel array for the left face.
  91124. * This is stored in format, left to right, up to down format.
  91125. */
  91126. left: Nullable<ArrayBufferView>;
  91127. /**
  91128. * The pixel array for the right face.
  91129. * This is stored in format, left to right, up to down format.
  91130. */
  91131. right: Nullable<ArrayBufferView>;
  91132. /**
  91133. * The pixel array for the up face.
  91134. * This is stored in format, left to right, up to down format.
  91135. */
  91136. up: Nullable<ArrayBufferView>;
  91137. /**
  91138. * The pixel array for the down face.
  91139. * This is stored in format, left to right, up to down format.
  91140. */
  91141. down: Nullable<ArrayBufferView>;
  91142. /**
  91143. * The size of the cubemap stored.
  91144. *
  91145. * Each faces will be size * size pixels.
  91146. */
  91147. size: number;
  91148. /**
  91149. * The format of the texture.
  91150. *
  91151. * RGBA, RGB.
  91152. */
  91153. format: number;
  91154. /**
  91155. * The type of the texture data.
  91156. *
  91157. * UNSIGNED_INT, FLOAT.
  91158. */
  91159. type: number;
  91160. /**
  91161. * Specifies whether the texture is in gamma space.
  91162. */
  91163. gammaSpace: boolean;
  91164. }
  91165. /**
  91166. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  91167. */
  91168. export class PanoramaToCubeMapTools {
  91169. private static FACE_FRONT;
  91170. private static FACE_BACK;
  91171. private static FACE_RIGHT;
  91172. private static FACE_LEFT;
  91173. private static FACE_DOWN;
  91174. private static FACE_UP;
  91175. /**
  91176. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  91177. *
  91178. * @param float32Array The source data.
  91179. * @param inputWidth The width of the input panorama.
  91180. * @param inputHeight The height of the input panorama.
  91181. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  91182. * @return The cubemap data
  91183. */
  91184. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  91185. private static CreateCubemapTexture;
  91186. private static CalcProjectionSpherical;
  91187. }
  91188. }
  91189. declare module BABYLON {
  91190. /**
  91191. * Helper class dealing with the extraction of spherical polynomial dataArray
  91192. * from a cube map.
  91193. */
  91194. export class CubeMapToSphericalPolynomialTools {
  91195. private static FileFaces;
  91196. /**
  91197. * Converts a texture to the according Spherical Polynomial data.
  91198. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91199. *
  91200. * @param texture The texture to extract the information from.
  91201. * @return The Spherical Polynomial data.
  91202. */
  91203. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  91204. /**
  91205. * Converts a cubemap to the according Spherical Polynomial data.
  91206. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91207. *
  91208. * @param cubeInfo The Cube map to extract the information from.
  91209. * @return The Spherical Polynomial data.
  91210. */
  91211. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  91212. }
  91213. }
  91214. declare module BABYLON {
  91215. /**
  91216. * Class used to manipulate GUIDs
  91217. */
  91218. export class GUID {
  91219. /**
  91220. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  91221. * Be aware Math.random() could cause collisions, but:
  91222. * "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"
  91223. * @returns a pseudo random id
  91224. */
  91225. static RandomId(): string;
  91226. }
  91227. }
  91228. declare module BABYLON {
  91229. /**
  91230. * Base class of all the textures in babylon.
  91231. * It groups all the common properties the materials, post process, lights... might need
  91232. * in order to make a correct use of the texture.
  91233. */
  91234. export class BaseTexture implements IAnimatable {
  91235. /**
  91236. * Default anisotropic filtering level for the application.
  91237. * It is set to 4 as a good tradeoff between perf and quality.
  91238. */
  91239. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  91240. /**
  91241. * Gets or sets the unique id of the texture
  91242. */
  91243. uniqueId: number;
  91244. /**
  91245. * Define the name of the texture.
  91246. */
  91247. name: string;
  91248. /**
  91249. * Gets or sets an object used to store user defined information.
  91250. */
  91251. metadata: any;
  91252. /**
  91253. * For internal use only. Please do not use.
  91254. */
  91255. reservedDataStore: any;
  91256. private _hasAlpha;
  91257. /**
  91258. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  91259. */
  91260. hasAlpha: boolean;
  91261. /**
  91262. * Defines if the alpha value should be determined via the rgb values.
  91263. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  91264. */
  91265. getAlphaFromRGB: boolean;
  91266. /**
  91267. * Intensity or strength of the texture.
  91268. * It is commonly used by materials to fine tune the intensity of the texture
  91269. */
  91270. level: number;
  91271. /**
  91272. * Define the UV chanel to use starting from 0 and defaulting to 0.
  91273. * This is part of the texture as textures usually maps to one uv set.
  91274. */
  91275. coordinatesIndex: number;
  91276. private _coordinatesMode;
  91277. /**
  91278. * How a texture is mapped.
  91279. *
  91280. * | Value | Type | Description |
  91281. * | ----- | ----------------------------------- | ----------- |
  91282. * | 0 | EXPLICIT_MODE | |
  91283. * | 1 | SPHERICAL_MODE | |
  91284. * | 2 | PLANAR_MODE | |
  91285. * | 3 | CUBIC_MODE | |
  91286. * | 4 | PROJECTION_MODE | |
  91287. * | 5 | SKYBOX_MODE | |
  91288. * | 6 | INVCUBIC_MODE | |
  91289. * | 7 | EQUIRECTANGULAR_MODE | |
  91290. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  91291. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  91292. */
  91293. coordinatesMode: number;
  91294. /**
  91295. * | Value | Type | Description |
  91296. * | ----- | ------------------ | ----------- |
  91297. * | 0 | CLAMP_ADDRESSMODE | |
  91298. * | 1 | WRAP_ADDRESSMODE | |
  91299. * | 2 | MIRROR_ADDRESSMODE | |
  91300. */
  91301. wrapU: number;
  91302. /**
  91303. * | Value | Type | Description |
  91304. * | ----- | ------------------ | ----------- |
  91305. * | 0 | CLAMP_ADDRESSMODE | |
  91306. * | 1 | WRAP_ADDRESSMODE | |
  91307. * | 2 | MIRROR_ADDRESSMODE | |
  91308. */
  91309. wrapV: number;
  91310. /**
  91311. * | Value | Type | Description |
  91312. * | ----- | ------------------ | ----------- |
  91313. * | 0 | CLAMP_ADDRESSMODE | |
  91314. * | 1 | WRAP_ADDRESSMODE | |
  91315. * | 2 | MIRROR_ADDRESSMODE | |
  91316. */
  91317. wrapR: number;
  91318. /**
  91319. * With compliant hardware and browser (supporting anisotropic filtering)
  91320. * this defines the level of anisotropic filtering in the texture.
  91321. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  91322. */
  91323. anisotropicFilteringLevel: number;
  91324. /**
  91325. * Define if the texture is a cube texture or if false a 2d texture.
  91326. */
  91327. isCube: boolean;
  91328. /**
  91329. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  91330. */
  91331. is3D: boolean;
  91332. /**
  91333. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  91334. * HDR texture are usually stored in linear space.
  91335. * This only impacts the PBR and Background materials
  91336. */
  91337. gammaSpace: boolean;
  91338. /**
  91339. * Gets whether or not the texture contains RGBD data.
  91340. */
  91341. readonly isRGBD: boolean;
  91342. /**
  91343. * Is Z inverted in the texture (useful in a cube texture).
  91344. */
  91345. invertZ: boolean;
  91346. /**
  91347. * Are mip maps generated for this texture or not.
  91348. */
  91349. readonly noMipmap: boolean;
  91350. /**
  91351. * @hidden
  91352. */
  91353. lodLevelInAlpha: boolean;
  91354. /**
  91355. * With prefiltered texture, defined the offset used during the prefiltering steps.
  91356. */
  91357. lodGenerationOffset: number;
  91358. /**
  91359. * With prefiltered texture, defined the scale used during the prefiltering steps.
  91360. */
  91361. lodGenerationScale: number;
  91362. /**
  91363. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  91364. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  91365. * average roughness values.
  91366. */
  91367. linearSpecularLOD: boolean;
  91368. /**
  91369. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  91370. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  91371. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  91372. */
  91373. irradianceTexture: Nullable<BaseTexture>;
  91374. /**
  91375. * Define if the texture is a render target.
  91376. */
  91377. isRenderTarget: boolean;
  91378. /**
  91379. * Define the unique id of the texture in the scene.
  91380. */
  91381. readonly uid: string;
  91382. /**
  91383. * Return a string representation of the texture.
  91384. * @returns the texture as a string
  91385. */
  91386. toString(): string;
  91387. /**
  91388. * Get the class name of the texture.
  91389. * @returns "BaseTexture"
  91390. */
  91391. getClassName(): string;
  91392. /**
  91393. * Define the list of animation attached to the texture.
  91394. */
  91395. animations: Animation[];
  91396. /**
  91397. * An event triggered when the texture is disposed.
  91398. */
  91399. onDisposeObservable: Observable<BaseTexture>;
  91400. private _onDisposeObserver;
  91401. /**
  91402. * Callback triggered when the texture has been disposed.
  91403. * Kept for back compatibility, you can use the onDisposeObservable instead.
  91404. */
  91405. onDispose: () => void;
  91406. /**
  91407. * Define the current state of the loading sequence when in delayed load mode.
  91408. */
  91409. delayLoadState: number;
  91410. private _scene;
  91411. /** @hidden */
  91412. _texture: Nullable<InternalTexture>;
  91413. private _uid;
  91414. /**
  91415. * Define if the texture is preventinga material to render or not.
  91416. * If not and the texture is not ready, the engine will use a default black texture instead.
  91417. */
  91418. readonly isBlocking: boolean;
  91419. /**
  91420. * Instantiates a new BaseTexture.
  91421. * Base class of all the textures in babylon.
  91422. * It groups all the common properties the materials, post process, lights... might need
  91423. * in order to make a correct use of the texture.
  91424. * @param scene Define the scene the texture blongs to
  91425. */
  91426. constructor(scene: Nullable<Scene>);
  91427. /**
  91428. * Get the scene the texture belongs to.
  91429. * @returns the scene or null if undefined
  91430. */
  91431. getScene(): Nullable<Scene>;
  91432. /**
  91433. * Get the texture transform matrix used to offset tile the texture for istance.
  91434. * @returns the transformation matrix
  91435. */
  91436. getTextureMatrix(): Matrix;
  91437. /**
  91438. * Get the texture reflection matrix used to rotate/transform the reflection.
  91439. * @returns the reflection matrix
  91440. */
  91441. getReflectionTextureMatrix(): Matrix;
  91442. /**
  91443. * Get the underlying lower level texture from Babylon.
  91444. * @returns the insternal texture
  91445. */
  91446. getInternalTexture(): Nullable<InternalTexture>;
  91447. /**
  91448. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  91449. * @returns true if ready or not blocking
  91450. */
  91451. isReadyOrNotBlocking(): boolean;
  91452. /**
  91453. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  91454. * @returns true if fully ready
  91455. */
  91456. isReady(): boolean;
  91457. private _cachedSize;
  91458. /**
  91459. * Get the size of the texture.
  91460. * @returns the texture size.
  91461. */
  91462. getSize(): ISize;
  91463. /**
  91464. * Get the base size of the texture.
  91465. * It can be different from the size if the texture has been resized for POT for instance
  91466. * @returns the base size
  91467. */
  91468. getBaseSize(): ISize;
  91469. /**
  91470. * Update the sampling mode of the texture.
  91471. * Default is Trilinear mode.
  91472. *
  91473. * | Value | Type | Description |
  91474. * | ----- | ------------------ | ----------- |
  91475. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  91476. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  91477. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  91478. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  91479. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  91480. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  91481. * | 7 | NEAREST_LINEAR | |
  91482. * | 8 | NEAREST_NEAREST | |
  91483. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  91484. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  91485. * | 11 | LINEAR_LINEAR | |
  91486. * | 12 | LINEAR_NEAREST | |
  91487. *
  91488. * > _mag_: magnification filter (close to the viewer)
  91489. * > _min_: minification filter (far from the viewer)
  91490. * > _mip_: filter used between mip map levels
  91491. *@param samplingMode Define the new sampling mode of the texture
  91492. */
  91493. updateSamplingMode(samplingMode: number): void;
  91494. /**
  91495. * Scales the texture if is `canRescale()`
  91496. * @param ratio the resize factor we want to use to rescale
  91497. */
  91498. scale(ratio: number): void;
  91499. /**
  91500. * Get if the texture can rescale.
  91501. */
  91502. readonly canRescale: boolean;
  91503. /** @hidden */
  91504. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  91505. /** @hidden */
  91506. _rebuild(): void;
  91507. /**
  91508. * Triggers the load sequence in delayed load mode.
  91509. */
  91510. delayLoad(): void;
  91511. /**
  91512. * Clones the texture.
  91513. * @returns the cloned texture
  91514. */
  91515. clone(): Nullable<BaseTexture>;
  91516. /**
  91517. * Get the texture underlying type (INT, FLOAT...)
  91518. */
  91519. readonly textureType: number;
  91520. /**
  91521. * Get the texture underlying format (RGB, RGBA...)
  91522. */
  91523. readonly textureFormat: number;
  91524. /**
  91525. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  91526. * This will returns an RGBA array buffer containing either in values (0-255) or
  91527. * float values (0-1) depending of the underlying buffer type.
  91528. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  91529. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  91530. * @param buffer defines a user defined buffer to fill with data (can be null)
  91531. * @returns The Array buffer containing the pixels data.
  91532. */
  91533. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  91534. /**
  91535. * Release and destroy the underlying lower level texture aka internalTexture.
  91536. */
  91537. releaseInternalTexture(): void;
  91538. /**
  91539. * Get the polynomial representation of the texture data.
  91540. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  91541. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  91542. */
  91543. sphericalPolynomial: Nullable<SphericalPolynomial>;
  91544. /** @hidden */
  91545. readonly _lodTextureHigh: Nullable<BaseTexture>;
  91546. /** @hidden */
  91547. readonly _lodTextureMid: Nullable<BaseTexture>;
  91548. /** @hidden */
  91549. readonly _lodTextureLow: Nullable<BaseTexture>;
  91550. /**
  91551. * Dispose the texture and release its associated resources.
  91552. */
  91553. dispose(): void;
  91554. /**
  91555. * Serialize the texture into a JSON representation that can be parsed later on.
  91556. * @returns the JSON representation of the texture
  91557. */
  91558. serialize(): any;
  91559. /**
  91560. * Helper function to be called back once a list of texture contains only ready textures.
  91561. * @param textures Define the list of textures to wait for
  91562. * @param callback Define the callback triggered once the entire list will be ready
  91563. */
  91564. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  91565. }
  91566. }
  91567. declare module BABYLON {
  91568. /**
  91569. * Class used to store data associated with WebGL texture data for the engine
  91570. * This class should not be used directly
  91571. */
  91572. export class InternalTexture {
  91573. /** @hidden */
  91574. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  91575. /**
  91576. * The source of the texture data is unknown
  91577. */
  91578. static DATASOURCE_UNKNOWN: number;
  91579. /**
  91580. * Texture data comes from an URL
  91581. */
  91582. static DATASOURCE_URL: number;
  91583. /**
  91584. * Texture data is only used for temporary storage
  91585. */
  91586. static DATASOURCE_TEMP: number;
  91587. /**
  91588. * Texture data comes from raw data (ArrayBuffer)
  91589. */
  91590. static DATASOURCE_RAW: number;
  91591. /**
  91592. * Texture content is dynamic (video or dynamic texture)
  91593. */
  91594. static DATASOURCE_DYNAMIC: number;
  91595. /**
  91596. * Texture content is generated by rendering to it
  91597. */
  91598. static DATASOURCE_RENDERTARGET: number;
  91599. /**
  91600. * Texture content is part of a multi render target process
  91601. */
  91602. static DATASOURCE_MULTIRENDERTARGET: number;
  91603. /**
  91604. * Texture data comes from a cube data file
  91605. */
  91606. static DATASOURCE_CUBE: number;
  91607. /**
  91608. * Texture data comes from a raw cube data
  91609. */
  91610. static DATASOURCE_CUBERAW: number;
  91611. /**
  91612. * Texture data come from a prefiltered cube data file
  91613. */
  91614. static DATASOURCE_CUBEPREFILTERED: number;
  91615. /**
  91616. * Texture content is raw 3D data
  91617. */
  91618. static DATASOURCE_RAW3D: number;
  91619. /**
  91620. * Texture content is a depth texture
  91621. */
  91622. static DATASOURCE_DEPTHTEXTURE: number;
  91623. /**
  91624. * Texture data comes from a raw cube data encoded with RGBD
  91625. */
  91626. static DATASOURCE_CUBERAW_RGBD: number;
  91627. /**
  91628. * Defines if the texture is ready
  91629. */
  91630. isReady: boolean;
  91631. /**
  91632. * Defines if the texture is a cube texture
  91633. */
  91634. isCube: boolean;
  91635. /**
  91636. * Defines if the texture contains 3D data
  91637. */
  91638. is3D: boolean;
  91639. /**
  91640. * Defines if the texture contains multiview data
  91641. */
  91642. isMultiview: boolean;
  91643. /**
  91644. * Gets the URL used to load this texture
  91645. */
  91646. url: string;
  91647. /**
  91648. * Gets the sampling mode of the texture
  91649. */
  91650. samplingMode: number;
  91651. /**
  91652. * Gets a boolean indicating if the texture needs mipmaps generation
  91653. */
  91654. generateMipMaps: boolean;
  91655. /**
  91656. * Gets the number of samples used by the texture (WebGL2+ only)
  91657. */
  91658. samples: number;
  91659. /**
  91660. * Gets the type of the texture (int, float...)
  91661. */
  91662. type: number;
  91663. /**
  91664. * Gets the format of the texture (RGB, RGBA...)
  91665. */
  91666. format: number;
  91667. /**
  91668. * Observable called when the texture is loaded
  91669. */
  91670. onLoadedObservable: Observable<InternalTexture>;
  91671. /**
  91672. * Gets the width of the texture
  91673. */
  91674. width: number;
  91675. /**
  91676. * Gets the height of the texture
  91677. */
  91678. height: number;
  91679. /**
  91680. * Gets the depth of the texture
  91681. */
  91682. depth: number;
  91683. /**
  91684. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  91685. */
  91686. baseWidth: number;
  91687. /**
  91688. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  91689. */
  91690. baseHeight: number;
  91691. /**
  91692. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  91693. */
  91694. baseDepth: number;
  91695. /**
  91696. * Gets a boolean indicating if the texture is inverted on Y axis
  91697. */
  91698. invertY: boolean;
  91699. /** @hidden */
  91700. _invertVScale: boolean;
  91701. /** @hidden */
  91702. _associatedChannel: number;
  91703. /** @hidden */
  91704. _dataSource: number;
  91705. /** @hidden */
  91706. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  91707. /** @hidden */
  91708. _bufferView: Nullable<ArrayBufferView>;
  91709. /** @hidden */
  91710. _bufferViewArray: Nullable<ArrayBufferView[]>;
  91711. /** @hidden */
  91712. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  91713. /** @hidden */
  91714. _size: number;
  91715. /** @hidden */
  91716. _extension: string;
  91717. /** @hidden */
  91718. _files: Nullable<string[]>;
  91719. /** @hidden */
  91720. _workingCanvas: Nullable<HTMLCanvasElement>;
  91721. /** @hidden */
  91722. _workingContext: Nullable<CanvasRenderingContext2D>;
  91723. /** @hidden */
  91724. _framebuffer: Nullable<WebGLFramebuffer>;
  91725. /** @hidden */
  91726. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  91727. /** @hidden */
  91728. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  91729. /** @hidden */
  91730. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  91731. /** @hidden */
  91732. _attachments: Nullable<number[]>;
  91733. /** @hidden */
  91734. _cachedCoordinatesMode: Nullable<number>;
  91735. /** @hidden */
  91736. _cachedWrapU: Nullable<number>;
  91737. /** @hidden */
  91738. _cachedWrapV: Nullable<number>;
  91739. /** @hidden */
  91740. _cachedWrapR: Nullable<number>;
  91741. /** @hidden */
  91742. _cachedAnisotropicFilteringLevel: Nullable<number>;
  91743. /** @hidden */
  91744. _isDisabled: boolean;
  91745. /** @hidden */
  91746. _compression: Nullable<string>;
  91747. /** @hidden */
  91748. _generateStencilBuffer: boolean;
  91749. /** @hidden */
  91750. _generateDepthBuffer: boolean;
  91751. /** @hidden */
  91752. _comparisonFunction: number;
  91753. /** @hidden */
  91754. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  91755. /** @hidden */
  91756. _lodGenerationScale: number;
  91757. /** @hidden */
  91758. _lodGenerationOffset: number;
  91759. /** @hidden */
  91760. _colorTextureArray: Nullable<WebGLTexture>;
  91761. /** @hidden */
  91762. _depthStencilTextureArray: Nullable<WebGLTexture>;
  91763. /** @hidden */
  91764. _lodTextureHigh: Nullable<BaseTexture>;
  91765. /** @hidden */
  91766. _lodTextureMid: Nullable<BaseTexture>;
  91767. /** @hidden */
  91768. _lodTextureLow: Nullable<BaseTexture>;
  91769. /** @hidden */
  91770. _isRGBD: boolean;
  91771. /** @hidden */
  91772. _linearSpecularLOD: boolean;
  91773. /** @hidden */
  91774. _irradianceTexture: Nullable<BaseTexture>;
  91775. /** @hidden */
  91776. _webGLTexture: Nullable<WebGLTexture>;
  91777. /** @hidden */
  91778. _references: number;
  91779. private _engine;
  91780. /**
  91781. * Gets the Engine the texture belongs to.
  91782. * @returns The babylon engine
  91783. */
  91784. getEngine(): Engine;
  91785. /**
  91786. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  91787. */
  91788. readonly dataSource: number;
  91789. /**
  91790. * Creates a new InternalTexture
  91791. * @param engine defines the engine to use
  91792. * @param dataSource defines the type of data that will be used
  91793. * @param delayAllocation if the texture allocation should be delayed (default: false)
  91794. */
  91795. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  91796. /**
  91797. * Increments the number of references (ie. the number of Texture that point to it)
  91798. */
  91799. incrementReferences(): void;
  91800. /**
  91801. * Change the size of the texture (not the size of the content)
  91802. * @param width defines the new width
  91803. * @param height defines the new height
  91804. * @param depth defines the new depth (1 by default)
  91805. */
  91806. updateSize(width: int, height: int, depth?: int): void;
  91807. /** @hidden */
  91808. _rebuild(): void;
  91809. /** @hidden */
  91810. _swapAndDie(target: InternalTexture): void;
  91811. /**
  91812. * Dispose the current allocated resources
  91813. */
  91814. dispose(): void;
  91815. }
  91816. }
  91817. declare module BABYLON {
  91818. /**
  91819. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91820. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91821. */
  91822. export class EffectFallbacks {
  91823. private _defines;
  91824. private _currentRank;
  91825. private _maxRank;
  91826. private _mesh;
  91827. /**
  91828. * Removes the fallback from the bound mesh.
  91829. */
  91830. unBindMesh(): void;
  91831. /**
  91832. * Adds a fallback on the specified property.
  91833. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91834. * @param define The name of the define in the shader
  91835. */
  91836. addFallback(rank: number, define: string): void;
  91837. /**
  91838. * Sets the mesh to use CPU skinning when needing to fallback.
  91839. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91840. * @param mesh The mesh to use the fallbacks.
  91841. */
  91842. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91843. /**
  91844. * Checks to see if more fallbacks are still availible.
  91845. */
  91846. readonly isMoreFallbacks: boolean;
  91847. /**
  91848. * Removes the defines that should be removed when falling back.
  91849. * @param currentDefines defines the current define statements for the shader.
  91850. * @param effect defines the current effect we try to compile
  91851. * @returns The resulting defines with defines of the current rank removed.
  91852. */
  91853. reduce(currentDefines: string, effect: Effect): string;
  91854. }
  91855. /**
  91856. * Options to be used when creating an effect.
  91857. */
  91858. export class EffectCreationOptions {
  91859. /**
  91860. * Atrributes that will be used in the shader.
  91861. */
  91862. attributes: string[];
  91863. /**
  91864. * Uniform varible names that will be set in the shader.
  91865. */
  91866. uniformsNames: string[];
  91867. /**
  91868. * Uniform buffer varible names that will be set in the shader.
  91869. */
  91870. uniformBuffersNames: string[];
  91871. /**
  91872. * Sampler texture variable names that will be set in the shader.
  91873. */
  91874. samplers: string[];
  91875. /**
  91876. * Define statements that will be set in the shader.
  91877. */
  91878. defines: any;
  91879. /**
  91880. * Possible fallbacks for this effect to improve performance when needed.
  91881. */
  91882. fallbacks: Nullable<EffectFallbacks>;
  91883. /**
  91884. * Callback that will be called when the shader is compiled.
  91885. */
  91886. onCompiled: Nullable<(effect: Effect) => void>;
  91887. /**
  91888. * Callback that will be called if an error occurs during shader compilation.
  91889. */
  91890. onError: Nullable<(effect: Effect, errors: string) => void>;
  91891. /**
  91892. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91893. */
  91894. indexParameters: any;
  91895. /**
  91896. * Max number of lights that can be used in the shader.
  91897. */
  91898. maxSimultaneousLights: number;
  91899. /**
  91900. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91901. */
  91902. transformFeedbackVaryings: Nullable<string[]>;
  91903. }
  91904. /**
  91905. * Effect containing vertex and fragment shader that can be executed on an object.
  91906. */
  91907. export class Effect implements IDisposable {
  91908. /**
  91909. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91910. */
  91911. static ShadersRepository: string;
  91912. /**
  91913. * Name of the effect.
  91914. */
  91915. name: any;
  91916. /**
  91917. * String container all the define statements that should be set on the shader.
  91918. */
  91919. defines: string;
  91920. /**
  91921. * Callback that will be called when the shader is compiled.
  91922. */
  91923. onCompiled: Nullable<(effect: Effect) => void>;
  91924. /**
  91925. * Callback that will be called if an error occurs during shader compilation.
  91926. */
  91927. onError: Nullable<(effect: Effect, errors: string) => void>;
  91928. /**
  91929. * Callback that will be called when effect is bound.
  91930. */
  91931. onBind: Nullable<(effect: Effect) => void>;
  91932. /**
  91933. * Unique ID of the effect.
  91934. */
  91935. uniqueId: number;
  91936. /**
  91937. * Observable that will be called when the shader is compiled.
  91938. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91939. */
  91940. onCompileObservable: Observable<Effect>;
  91941. /**
  91942. * Observable that will be called if an error occurs during shader compilation.
  91943. */
  91944. onErrorObservable: Observable<Effect>;
  91945. /** @hidden */
  91946. _onBindObservable: Nullable<Observable<Effect>>;
  91947. /**
  91948. * Observable that will be called when effect is bound.
  91949. */
  91950. readonly onBindObservable: Observable<Effect>;
  91951. /** @hidden */
  91952. _bonesComputationForcedToCPU: boolean;
  91953. private static _uniqueIdSeed;
  91954. private _engine;
  91955. private _uniformBuffersNames;
  91956. private _uniformsNames;
  91957. private _samplerList;
  91958. private _samplers;
  91959. private _isReady;
  91960. private _compilationError;
  91961. private _attributesNames;
  91962. private _attributes;
  91963. private _uniforms;
  91964. /**
  91965. * Key for the effect.
  91966. * @hidden
  91967. */
  91968. _key: string;
  91969. private _indexParameters;
  91970. private _fallbacks;
  91971. private _vertexSourceCode;
  91972. private _fragmentSourceCode;
  91973. private _vertexSourceCodeOverride;
  91974. private _fragmentSourceCodeOverride;
  91975. private _transformFeedbackVaryings;
  91976. /**
  91977. * Compiled shader to webGL program.
  91978. * @hidden
  91979. */
  91980. _pipelineContext: Nullable<IPipelineContext>;
  91981. private _valueCache;
  91982. private static _baseCache;
  91983. /**
  91984. * Instantiates an effect.
  91985. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91986. * @param baseName Name of the effect.
  91987. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91988. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91989. * @param samplers List of sampler variables that will be passed to the shader.
  91990. * @param engine Engine to be used to render the effect
  91991. * @param defines Define statements to be added to the shader.
  91992. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91993. * @param onCompiled Callback that will be called when the shader is compiled.
  91994. * @param onError Callback that will be called if an error occurs during shader compilation.
  91995. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91996. */
  91997. 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);
  91998. private _useFinalCode;
  91999. /**
  92000. * Unique key for this effect
  92001. */
  92002. readonly key: string;
  92003. /**
  92004. * If the effect has been compiled and prepared.
  92005. * @returns if the effect is compiled and prepared.
  92006. */
  92007. isReady(): boolean;
  92008. /**
  92009. * The engine the effect was initialized with.
  92010. * @returns the engine.
  92011. */
  92012. getEngine(): Engine;
  92013. /**
  92014. * The pipeline context for this effect
  92015. * @returns the associated pipeline context
  92016. */
  92017. getPipelineContext(): Nullable<IPipelineContext>;
  92018. /**
  92019. * The set of names of attribute variables for the shader.
  92020. * @returns An array of attribute names.
  92021. */
  92022. getAttributesNames(): string[];
  92023. /**
  92024. * Returns the attribute at the given index.
  92025. * @param index The index of the attribute.
  92026. * @returns The location of the attribute.
  92027. */
  92028. getAttributeLocation(index: number): number;
  92029. /**
  92030. * Returns the attribute based on the name of the variable.
  92031. * @param name of the attribute to look up.
  92032. * @returns the attribute location.
  92033. */
  92034. getAttributeLocationByName(name: string): number;
  92035. /**
  92036. * The number of attributes.
  92037. * @returns the numnber of attributes.
  92038. */
  92039. getAttributesCount(): number;
  92040. /**
  92041. * Gets the index of a uniform variable.
  92042. * @param uniformName of the uniform to look up.
  92043. * @returns the index.
  92044. */
  92045. getUniformIndex(uniformName: string): number;
  92046. /**
  92047. * Returns the attribute based on the name of the variable.
  92048. * @param uniformName of the uniform to look up.
  92049. * @returns the location of the uniform.
  92050. */
  92051. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92052. /**
  92053. * Returns an array of sampler variable names
  92054. * @returns The array of sampler variable neames.
  92055. */
  92056. getSamplers(): string[];
  92057. /**
  92058. * The error from the last compilation.
  92059. * @returns the error string.
  92060. */
  92061. getCompilationError(): string;
  92062. /**
  92063. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92064. * @param func The callback to be used.
  92065. */
  92066. executeWhenCompiled(func: (effect: Effect) => void): void;
  92067. private _checkIsReady;
  92068. /** @hidden */
  92069. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92070. /** @hidden */
  92071. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92072. /** @hidden */
  92073. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92074. /**
  92075. * Recompiles the webGL program
  92076. * @param vertexSourceCode The source code for the vertex shader.
  92077. * @param fragmentSourceCode The source code for the fragment shader.
  92078. * @param onCompiled Callback called when completed.
  92079. * @param onError Callback called on error.
  92080. * @hidden
  92081. */
  92082. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92083. /**
  92084. * Prepares the effect
  92085. * @hidden
  92086. */
  92087. _prepareEffect(): void;
  92088. /**
  92089. * Checks if the effect is supported. (Must be called after compilation)
  92090. */
  92091. readonly isSupported: boolean;
  92092. /**
  92093. * Binds a texture to the engine to be used as output of the shader.
  92094. * @param channel Name of the output variable.
  92095. * @param texture Texture to bind.
  92096. * @hidden
  92097. */
  92098. _bindTexture(channel: string, texture: InternalTexture): void;
  92099. /**
  92100. * Sets a texture on the engine to be used in the shader.
  92101. * @param channel Name of the sampler variable.
  92102. * @param texture Texture to set.
  92103. */
  92104. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92105. /**
  92106. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92107. * @param channel Name of the sampler variable.
  92108. * @param texture Texture to set.
  92109. */
  92110. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92111. /**
  92112. * Sets an array of textures on the engine to be used in the shader.
  92113. * @param channel Name of the variable.
  92114. * @param textures Textures to set.
  92115. */
  92116. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92117. /**
  92118. * 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)
  92119. * @param channel Name of the sampler variable.
  92120. * @param postProcess Post process to get the input texture from.
  92121. */
  92122. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92123. /**
  92124. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92125. * 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)
  92126. * @param channel Name of the sampler variable.
  92127. * @param postProcess Post process to get the output texture from.
  92128. */
  92129. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92130. /** @hidden */
  92131. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  92132. /** @hidden */
  92133. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92134. /** @hidden */
  92135. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92136. /** @hidden */
  92137. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92138. /**
  92139. * Binds a buffer to a uniform.
  92140. * @param buffer Buffer to bind.
  92141. * @param name Name of the uniform variable to bind to.
  92142. */
  92143. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92144. /**
  92145. * Binds block to a uniform.
  92146. * @param blockName Name of the block to bind.
  92147. * @param index Index to bind.
  92148. */
  92149. bindUniformBlock(blockName: string, index: number): void;
  92150. /**
  92151. * Sets an interger value on a uniform variable.
  92152. * @param uniformName Name of the variable.
  92153. * @param value Value to be set.
  92154. * @returns this effect.
  92155. */
  92156. setInt(uniformName: string, value: number): Effect;
  92157. /**
  92158. * Sets an int array on a uniform variable.
  92159. * @param uniformName Name of the variable.
  92160. * @param array array to be set.
  92161. * @returns this effect.
  92162. */
  92163. setIntArray(uniformName: string, array: Int32Array): Effect;
  92164. /**
  92165. * 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)
  92166. * @param uniformName Name of the variable.
  92167. * @param array array to be set.
  92168. * @returns this effect.
  92169. */
  92170. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92171. /**
  92172. * 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)
  92173. * @param uniformName Name of the variable.
  92174. * @param array array to be set.
  92175. * @returns this effect.
  92176. */
  92177. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92178. /**
  92179. * 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)
  92180. * @param uniformName Name of the variable.
  92181. * @param array array to be set.
  92182. * @returns this effect.
  92183. */
  92184. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92185. /**
  92186. * Sets an float array on a uniform variable.
  92187. * @param uniformName Name of the variable.
  92188. * @param array array to be set.
  92189. * @returns this effect.
  92190. */
  92191. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92192. /**
  92193. * 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)
  92194. * @param uniformName Name of the variable.
  92195. * @param array array to be set.
  92196. * @returns this effect.
  92197. */
  92198. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92199. /**
  92200. * 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)
  92201. * @param uniformName Name of the variable.
  92202. * @param array array to be set.
  92203. * @returns this effect.
  92204. */
  92205. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92206. /**
  92207. * 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)
  92208. * @param uniformName Name of the variable.
  92209. * @param array array to be set.
  92210. * @returns this effect.
  92211. */
  92212. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92213. /**
  92214. * Sets an array on a uniform variable.
  92215. * @param uniformName Name of the variable.
  92216. * @param array array to be set.
  92217. * @returns this effect.
  92218. */
  92219. setArray(uniformName: string, array: number[]): Effect;
  92220. /**
  92221. * 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)
  92222. * @param uniformName Name of the variable.
  92223. * @param array array to be set.
  92224. * @returns this effect.
  92225. */
  92226. setArray2(uniformName: string, array: number[]): Effect;
  92227. /**
  92228. * 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)
  92229. * @param uniformName Name of the variable.
  92230. * @param array array to be set.
  92231. * @returns this effect.
  92232. */
  92233. setArray3(uniformName: string, array: number[]): Effect;
  92234. /**
  92235. * 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)
  92236. * @param uniformName Name of the variable.
  92237. * @param array array to be set.
  92238. * @returns this effect.
  92239. */
  92240. setArray4(uniformName: string, array: number[]): Effect;
  92241. /**
  92242. * Sets matrices on a uniform variable.
  92243. * @param uniformName Name of the variable.
  92244. * @param matrices matrices to be set.
  92245. * @returns this effect.
  92246. */
  92247. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92248. /**
  92249. * Sets matrix on a uniform variable.
  92250. * @param uniformName Name of the variable.
  92251. * @param matrix matrix to be set.
  92252. * @returns this effect.
  92253. */
  92254. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  92255. /**
  92256. * 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)
  92257. * @param uniformName Name of the variable.
  92258. * @param matrix matrix to be set.
  92259. * @returns this effect.
  92260. */
  92261. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92262. /**
  92263. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92264. * @param uniformName Name of the variable.
  92265. * @param matrix matrix to be set.
  92266. * @returns this effect.
  92267. */
  92268. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92269. /**
  92270. * Sets a float on a uniform variable.
  92271. * @param uniformName Name of the variable.
  92272. * @param value value to be set.
  92273. * @returns this effect.
  92274. */
  92275. setFloat(uniformName: string, value: number): Effect;
  92276. /**
  92277. * Sets a boolean on a uniform variable.
  92278. * @param uniformName Name of the variable.
  92279. * @param bool value to be set.
  92280. * @returns this effect.
  92281. */
  92282. setBool(uniformName: string, bool: boolean): Effect;
  92283. /**
  92284. * Sets a Vector2 on a uniform variable.
  92285. * @param uniformName Name of the variable.
  92286. * @param vector2 vector2 to be set.
  92287. * @returns this effect.
  92288. */
  92289. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  92290. /**
  92291. * Sets a float2 on a uniform variable.
  92292. * @param uniformName Name of the variable.
  92293. * @param x First float in float2.
  92294. * @param y Second float in float2.
  92295. * @returns this effect.
  92296. */
  92297. setFloat2(uniformName: string, x: number, y: number): Effect;
  92298. /**
  92299. * Sets a Vector3 on a uniform variable.
  92300. * @param uniformName Name of the variable.
  92301. * @param vector3 Value to be set.
  92302. * @returns this effect.
  92303. */
  92304. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  92305. /**
  92306. * Sets a float3 on a uniform variable.
  92307. * @param uniformName Name of the variable.
  92308. * @param x First float in float3.
  92309. * @param y Second float in float3.
  92310. * @param z Third float in float3.
  92311. * @returns this effect.
  92312. */
  92313. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92314. /**
  92315. * Sets a Vector4 on a uniform variable.
  92316. * @param uniformName Name of the variable.
  92317. * @param vector4 Value to be set.
  92318. * @returns this effect.
  92319. */
  92320. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  92321. /**
  92322. * Sets a float4 on a uniform variable.
  92323. * @param uniformName Name of the variable.
  92324. * @param x First float in float4.
  92325. * @param y Second float in float4.
  92326. * @param z Third float in float4.
  92327. * @param w Fourth float in float4.
  92328. * @returns this effect.
  92329. */
  92330. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92331. /**
  92332. * Sets a Color3 on a uniform variable.
  92333. * @param uniformName Name of the variable.
  92334. * @param color3 Value to be set.
  92335. * @returns this effect.
  92336. */
  92337. setColor3(uniformName: string, color3: IColor3Like): Effect;
  92338. /**
  92339. * Sets a Color4 on a uniform variable.
  92340. * @param uniformName Name of the variable.
  92341. * @param color3 Value to be set.
  92342. * @param alpha Alpha value to be set.
  92343. * @returns this effect.
  92344. */
  92345. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  92346. /**
  92347. * Sets a Color4 on a uniform variable
  92348. * @param uniformName defines the name of the variable
  92349. * @param color4 defines the value to be set
  92350. * @returns this effect.
  92351. */
  92352. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  92353. /** Release all associated resources */
  92354. dispose(): void;
  92355. /**
  92356. * This function will add a new shader to the shader store
  92357. * @param name the name of the shader
  92358. * @param pixelShader optional pixel shader content
  92359. * @param vertexShader optional vertex shader content
  92360. */
  92361. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92362. /**
  92363. * Store of each shader (The can be looked up using effect.key)
  92364. */
  92365. static ShadersStore: {
  92366. [key: string]: string;
  92367. };
  92368. /**
  92369. * Store of each included file for a shader (The can be looked up using effect.key)
  92370. */
  92371. static IncludesShadersStore: {
  92372. [key: string]: string;
  92373. };
  92374. /**
  92375. * Resets the cache of effects.
  92376. */
  92377. static ResetCache(): void;
  92378. }
  92379. }
  92380. declare module BABYLON {
  92381. /**
  92382. * Uniform buffer objects.
  92383. *
  92384. * Handles blocks of uniform on the GPU.
  92385. *
  92386. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92387. *
  92388. * For more information, please refer to :
  92389. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92390. */
  92391. export class UniformBuffer {
  92392. private _engine;
  92393. private _buffer;
  92394. private _data;
  92395. private _bufferData;
  92396. private _dynamic?;
  92397. private _uniformLocations;
  92398. private _uniformSizes;
  92399. private _uniformLocationPointer;
  92400. private _needSync;
  92401. private _noUBO;
  92402. private _currentEffect;
  92403. private static _MAX_UNIFORM_SIZE;
  92404. private static _tempBuffer;
  92405. /**
  92406. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  92407. * This is dynamic to allow compat with webgl 1 and 2.
  92408. * You will need to pass the name of the uniform as well as the value.
  92409. */
  92410. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  92411. /**
  92412. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  92413. * This is dynamic to allow compat with webgl 1 and 2.
  92414. * You will need to pass the name of the uniform as well as the value.
  92415. */
  92416. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  92417. /**
  92418. * Lambda to Update a single float in a uniform buffer.
  92419. * This is dynamic to allow compat with webgl 1 and 2.
  92420. * You will need to pass the name of the uniform as well as the value.
  92421. */
  92422. updateFloat: (name: string, x: number) => void;
  92423. /**
  92424. * Lambda to Update a vec2 of float in a uniform buffer.
  92425. * This is dynamic to allow compat with webgl 1 and 2.
  92426. * You will need to pass the name of the uniform as well as the value.
  92427. */
  92428. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  92429. /**
  92430. * Lambda to Update a vec3 of float in a uniform buffer.
  92431. * This is dynamic to allow compat with webgl 1 and 2.
  92432. * You will need to pass the name of the uniform as well as the value.
  92433. */
  92434. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  92435. /**
  92436. * Lambda to Update a vec4 of float in a uniform buffer.
  92437. * This is dynamic to allow compat with webgl 1 and 2.
  92438. * You will need to pass the name of the uniform as well as the value.
  92439. */
  92440. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  92441. /**
  92442. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  92443. * This is dynamic to allow compat with webgl 1 and 2.
  92444. * You will need to pass the name of the uniform as well as the value.
  92445. */
  92446. updateMatrix: (name: string, mat: Matrix) => void;
  92447. /**
  92448. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  92449. * This is dynamic to allow compat with webgl 1 and 2.
  92450. * You will need to pass the name of the uniform as well as the value.
  92451. */
  92452. updateVector3: (name: string, vector: Vector3) => void;
  92453. /**
  92454. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  92455. * This is dynamic to allow compat with webgl 1 and 2.
  92456. * You will need to pass the name of the uniform as well as the value.
  92457. */
  92458. updateVector4: (name: string, vector: Vector4) => void;
  92459. /**
  92460. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  92461. * This is dynamic to allow compat with webgl 1 and 2.
  92462. * You will need to pass the name of the uniform as well as the value.
  92463. */
  92464. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  92465. /**
  92466. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  92467. * This is dynamic to allow compat with webgl 1 and 2.
  92468. * You will need to pass the name of the uniform as well as the value.
  92469. */
  92470. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  92471. /**
  92472. * Instantiates a new Uniform buffer objects.
  92473. *
  92474. * Handles blocks of uniform on the GPU.
  92475. *
  92476. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  92477. *
  92478. * For more information, please refer to :
  92479. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  92480. * @param engine Define the engine the buffer is associated with
  92481. * @param data Define the data contained in the buffer
  92482. * @param dynamic Define if the buffer is updatable
  92483. */
  92484. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  92485. /**
  92486. * Indicates if the buffer is using the WebGL2 UBO implementation,
  92487. * or just falling back on setUniformXXX calls.
  92488. */
  92489. readonly useUbo: boolean;
  92490. /**
  92491. * Indicates if the WebGL underlying uniform buffer is in sync
  92492. * with the javascript cache data.
  92493. */
  92494. readonly isSync: boolean;
  92495. /**
  92496. * Indicates if the WebGL underlying uniform buffer is dynamic.
  92497. * Also, a dynamic UniformBuffer will disable cache verification and always
  92498. * update the underlying WebGL uniform buffer to the GPU.
  92499. * @returns if Dynamic, otherwise false
  92500. */
  92501. isDynamic(): boolean;
  92502. /**
  92503. * The data cache on JS side.
  92504. * @returns the underlying data as a float array
  92505. */
  92506. getData(): Float32Array;
  92507. /**
  92508. * The underlying WebGL Uniform buffer.
  92509. * @returns the webgl buffer
  92510. */
  92511. getBuffer(): Nullable<DataBuffer>;
  92512. /**
  92513. * std140 layout specifies how to align data within an UBO structure.
  92514. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  92515. * for specs.
  92516. */
  92517. private _fillAlignment;
  92518. /**
  92519. * Adds an uniform in the buffer.
  92520. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  92521. * for the layout to be correct !
  92522. * @param name Name of the uniform, as used in the uniform block in the shader.
  92523. * @param size Data size, or data directly.
  92524. */
  92525. addUniform(name: string, size: number | number[]): void;
  92526. /**
  92527. * Adds a Matrix 4x4 to the uniform buffer.
  92528. * @param name Name of the uniform, as used in the uniform block in the shader.
  92529. * @param mat A 4x4 matrix.
  92530. */
  92531. addMatrix(name: string, mat: Matrix): void;
  92532. /**
  92533. * Adds a vec2 to the uniform buffer.
  92534. * @param name Name of the uniform, as used in the uniform block in the shader.
  92535. * @param x Define the x component value of the vec2
  92536. * @param y Define the y component value of the vec2
  92537. */
  92538. addFloat2(name: string, x: number, y: number): void;
  92539. /**
  92540. * Adds a vec3 to the uniform buffer.
  92541. * @param name Name of the uniform, as used in the uniform block in the shader.
  92542. * @param x Define the x component value of the vec3
  92543. * @param y Define the y component value of the vec3
  92544. * @param z Define the z component value of the vec3
  92545. */
  92546. addFloat3(name: string, x: number, y: number, z: number): void;
  92547. /**
  92548. * Adds a vec3 to the uniform buffer.
  92549. * @param name Name of the uniform, as used in the uniform block in the shader.
  92550. * @param color Define the vec3 from a Color
  92551. */
  92552. addColor3(name: string, color: Color3): void;
  92553. /**
  92554. * Adds a vec4 to the uniform buffer.
  92555. * @param name Name of the uniform, as used in the uniform block in the shader.
  92556. * @param color Define the rgb components from a Color
  92557. * @param alpha Define the a component of the vec4
  92558. */
  92559. addColor4(name: string, color: Color3, alpha: number): void;
  92560. /**
  92561. * Adds a vec3 to the uniform buffer.
  92562. * @param name Name of the uniform, as used in the uniform block in the shader.
  92563. * @param vector Define the vec3 components from a Vector
  92564. */
  92565. addVector3(name: string, vector: Vector3): void;
  92566. /**
  92567. * Adds a Matrix 3x3 to the uniform buffer.
  92568. * @param name Name of the uniform, as used in the uniform block in the shader.
  92569. */
  92570. addMatrix3x3(name: string): void;
  92571. /**
  92572. * Adds a Matrix 2x2 to the uniform buffer.
  92573. * @param name Name of the uniform, as used in the uniform block in the shader.
  92574. */
  92575. addMatrix2x2(name: string): void;
  92576. /**
  92577. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  92578. */
  92579. create(): void;
  92580. /** @hidden */
  92581. _rebuild(): void;
  92582. /**
  92583. * Updates the WebGL Uniform Buffer on the GPU.
  92584. * If the `dynamic` flag is set to true, no cache comparison is done.
  92585. * Otherwise, the buffer will be updated only if the cache differs.
  92586. */
  92587. update(): void;
  92588. /**
  92589. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  92590. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92591. * @param data Define the flattened data
  92592. * @param size Define the size of the data.
  92593. */
  92594. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  92595. private _updateMatrix3x3ForUniform;
  92596. private _updateMatrix3x3ForEffect;
  92597. private _updateMatrix2x2ForEffect;
  92598. private _updateMatrix2x2ForUniform;
  92599. private _updateFloatForEffect;
  92600. private _updateFloatForUniform;
  92601. private _updateFloat2ForEffect;
  92602. private _updateFloat2ForUniform;
  92603. private _updateFloat3ForEffect;
  92604. private _updateFloat3ForUniform;
  92605. private _updateFloat4ForEffect;
  92606. private _updateFloat4ForUniform;
  92607. private _updateMatrixForEffect;
  92608. private _updateMatrixForUniform;
  92609. private _updateVector3ForEffect;
  92610. private _updateVector3ForUniform;
  92611. private _updateVector4ForEffect;
  92612. private _updateVector4ForUniform;
  92613. private _updateColor3ForEffect;
  92614. private _updateColor3ForUniform;
  92615. private _updateColor4ForEffect;
  92616. private _updateColor4ForUniform;
  92617. /**
  92618. * Sets a sampler uniform on the effect.
  92619. * @param name Define the name of the sampler.
  92620. * @param texture Define the texture to set in the sampler
  92621. */
  92622. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  92623. /**
  92624. * Directly updates the value of the uniform in the cache AND on the GPU.
  92625. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  92626. * @param data Define the flattened data
  92627. */
  92628. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  92629. /**
  92630. * Binds this uniform buffer to an effect.
  92631. * @param effect Define the effect to bind the buffer to
  92632. * @param name Name of the uniform block in the shader.
  92633. */
  92634. bindToEffect(effect: Effect, name: string): void;
  92635. /**
  92636. * Disposes the uniform buffer.
  92637. */
  92638. dispose(): void;
  92639. }
  92640. }
  92641. declare module BABYLON {
  92642. /**
  92643. * Class used to work with sound analyzer using fast fourier transform (FFT)
  92644. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92645. */
  92646. export class Analyser {
  92647. /**
  92648. * Gets or sets the smoothing
  92649. * @ignorenaming
  92650. */
  92651. SMOOTHING: number;
  92652. /**
  92653. * Gets or sets the FFT table size
  92654. * @ignorenaming
  92655. */
  92656. FFT_SIZE: number;
  92657. /**
  92658. * Gets or sets the bar graph amplitude
  92659. * @ignorenaming
  92660. */
  92661. BARGRAPHAMPLITUDE: number;
  92662. /**
  92663. * Gets or sets the position of the debug canvas
  92664. * @ignorenaming
  92665. */
  92666. DEBUGCANVASPOS: {
  92667. x: number;
  92668. y: number;
  92669. };
  92670. /**
  92671. * Gets or sets the debug canvas size
  92672. * @ignorenaming
  92673. */
  92674. DEBUGCANVASSIZE: {
  92675. width: number;
  92676. height: number;
  92677. };
  92678. private _byteFreqs;
  92679. private _byteTime;
  92680. private _floatFreqs;
  92681. private _webAudioAnalyser;
  92682. private _debugCanvas;
  92683. private _debugCanvasContext;
  92684. private _scene;
  92685. private _registerFunc;
  92686. private _audioEngine;
  92687. /**
  92688. * Creates a new analyser
  92689. * @param scene defines hosting scene
  92690. */
  92691. constructor(scene: Scene);
  92692. /**
  92693. * Get the number of data values you will have to play with for the visualization
  92694. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  92695. * @returns a number
  92696. */
  92697. getFrequencyBinCount(): number;
  92698. /**
  92699. * Gets the current frequency data as a byte array
  92700. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92701. * @returns a Uint8Array
  92702. */
  92703. getByteFrequencyData(): Uint8Array;
  92704. /**
  92705. * Gets the current waveform as a byte array
  92706. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  92707. * @returns a Uint8Array
  92708. */
  92709. getByteTimeDomainData(): Uint8Array;
  92710. /**
  92711. * Gets the current frequency data as a float array
  92712. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  92713. * @returns a Float32Array
  92714. */
  92715. getFloatFrequencyData(): Float32Array;
  92716. /**
  92717. * Renders the debug canvas
  92718. */
  92719. drawDebugCanvas(): void;
  92720. /**
  92721. * Stops rendering the debug canvas and removes it
  92722. */
  92723. stopDebugCanvas(): void;
  92724. /**
  92725. * Connects two audio nodes
  92726. * @param inputAudioNode defines first node to connect
  92727. * @param outputAudioNode defines second node to connect
  92728. */
  92729. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  92730. /**
  92731. * Releases all associated resources
  92732. */
  92733. dispose(): void;
  92734. }
  92735. }
  92736. declare module BABYLON {
  92737. /**
  92738. * This represents an audio engine and it is responsible
  92739. * to play, synchronize and analyse sounds throughout the application.
  92740. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92741. */
  92742. export interface IAudioEngine extends IDisposable {
  92743. /**
  92744. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92745. */
  92746. readonly canUseWebAudio: boolean;
  92747. /**
  92748. * Gets the current AudioContext if available.
  92749. */
  92750. readonly audioContext: Nullable<AudioContext>;
  92751. /**
  92752. * The master gain node defines the global audio volume of your audio engine.
  92753. */
  92754. readonly masterGain: GainNode;
  92755. /**
  92756. * Gets whether or not mp3 are supported by your browser.
  92757. */
  92758. readonly isMP3supported: boolean;
  92759. /**
  92760. * Gets whether or not ogg are supported by your browser.
  92761. */
  92762. readonly isOGGsupported: boolean;
  92763. /**
  92764. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92765. * @ignoreNaming
  92766. */
  92767. WarnedWebAudioUnsupported: boolean;
  92768. /**
  92769. * Defines if the audio engine relies on a custom unlocked button.
  92770. * In this case, the embedded button will not be displayed.
  92771. */
  92772. useCustomUnlockedButton: boolean;
  92773. /**
  92774. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  92775. */
  92776. readonly unlocked: boolean;
  92777. /**
  92778. * Event raised when audio has been unlocked on the browser.
  92779. */
  92780. onAudioUnlockedObservable: Observable<AudioEngine>;
  92781. /**
  92782. * Event raised when audio has been locked on the browser.
  92783. */
  92784. onAudioLockedObservable: Observable<AudioEngine>;
  92785. /**
  92786. * Flags the audio engine in Locked state.
  92787. * This happens due to new browser policies preventing audio to autoplay.
  92788. */
  92789. lock(): void;
  92790. /**
  92791. * Unlocks the audio engine once a user action has been done on the dom.
  92792. * This is helpful to resume play once browser policies have been satisfied.
  92793. */
  92794. unlock(): void;
  92795. }
  92796. /**
  92797. * This represents the default audio engine used in babylon.
  92798. * It is responsible to play, synchronize and analyse sounds throughout the application.
  92799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  92800. */
  92801. export class AudioEngine implements IAudioEngine {
  92802. private _audioContext;
  92803. private _audioContextInitialized;
  92804. private _muteButton;
  92805. private _hostElement;
  92806. /**
  92807. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  92808. */
  92809. canUseWebAudio: boolean;
  92810. /**
  92811. * The master gain node defines the global audio volume of your audio engine.
  92812. */
  92813. masterGain: GainNode;
  92814. /**
  92815. * Defines if Babylon should emit a warning if WebAudio is not supported.
  92816. * @ignoreNaming
  92817. */
  92818. WarnedWebAudioUnsupported: boolean;
  92819. /**
  92820. * Gets whether or not mp3 are supported by your browser.
  92821. */
  92822. isMP3supported: boolean;
  92823. /**
  92824. * Gets whether or not ogg are supported by your browser.
  92825. */
  92826. isOGGsupported: boolean;
  92827. /**
  92828. * Gets whether audio has been unlocked on the device.
  92829. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  92830. * a user interaction has happened.
  92831. */
  92832. unlocked: boolean;
  92833. /**
  92834. * Defines if the audio engine relies on a custom unlocked button.
  92835. * In this case, the embedded button will not be displayed.
  92836. */
  92837. useCustomUnlockedButton: boolean;
  92838. /**
  92839. * Event raised when audio has been unlocked on the browser.
  92840. */
  92841. onAudioUnlockedObservable: Observable<AudioEngine>;
  92842. /**
  92843. * Event raised when audio has been locked on the browser.
  92844. */
  92845. onAudioLockedObservable: Observable<AudioEngine>;
  92846. /**
  92847. * Gets the current AudioContext if available.
  92848. */
  92849. readonly audioContext: Nullable<AudioContext>;
  92850. private _connectedAnalyser;
  92851. /**
  92852. * Instantiates a new audio engine.
  92853. *
  92854. * There should be only one per page as some browsers restrict the number
  92855. * of audio contexts you can create.
  92856. * @param hostElement defines the host element where to display the mute icon if necessary
  92857. */
  92858. constructor(hostElement?: Nullable<HTMLElement>);
  92859. /**
  92860. * Flags the audio engine in Locked state.
  92861. * This happens due to new browser policies preventing audio to autoplay.
  92862. */
  92863. lock(): void;
  92864. /**
  92865. * Unlocks the audio engine once a user action has been done on the dom.
  92866. * This is helpful to resume play once browser policies have been satisfied.
  92867. */
  92868. unlock(): void;
  92869. private _resumeAudioContext;
  92870. private _initializeAudioContext;
  92871. private _tryToRun;
  92872. private _triggerRunningState;
  92873. private _triggerSuspendedState;
  92874. private _displayMuteButton;
  92875. private _moveButtonToTopLeft;
  92876. private _onResize;
  92877. private _hideMuteButton;
  92878. /**
  92879. * Destroy and release the resources associated with the audio ccontext.
  92880. */
  92881. dispose(): void;
  92882. /**
  92883. * Gets the global volume sets on the master gain.
  92884. * @returns the global volume if set or -1 otherwise
  92885. */
  92886. getGlobalVolume(): number;
  92887. /**
  92888. * Sets the global volume of your experience (sets on the master gain).
  92889. * @param newVolume Defines the new global volume of the application
  92890. */
  92891. setGlobalVolume(newVolume: number): void;
  92892. /**
  92893. * Connect the audio engine to an audio analyser allowing some amazing
  92894. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  92895. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  92896. * @param analyser The analyser to connect to the engine
  92897. */
  92898. connectToAnalyser(analyser: Analyser): void;
  92899. }
  92900. }
  92901. declare module BABYLON {
  92902. /**
  92903. * Interface used to present a loading screen while loading a scene
  92904. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92905. */
  92906. export interface ILoadingScreen {
  92907. /**
  92908. * Function called to display the loading screen
  92909. */
  92910. displayLoadingUI: () => void;
  92911. /**
  92912. * Function called to hide the loading screen
  92913. */
  92914. hideLoadingUI: () => void;
  92915. /**
  92916. * Gets or sets the color to use for the background
  92917. */
  92918. loadingUIBackgroundColor: string;
  92919. /**
  92920. * Gets or sets the text to display while loading
  92921. */
  92922. loadingUIText: string;
  92923. }
  92924. /**
  92925. * Class used for the default loading screen
  92926. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  92927. */
  92928. export class DefaultLoadingScreen implements ILoadingScreen {
  92929. private _renderingCanvas;
  92930. private _loadingText;
  92931. private _loadingDivBackgroundColor;
  92932. private _loadingDiv;
  92933. private _loadingTextDiv;
  92934. /** Gets or sets the logo url to use for the default loading screen */
  92935. static DefaultLogoUrl: string;
  92936. /** Gets or sets the spinner url to use for the default loading screen */
  92937. static DefaultSpinnerUrl: string;
  92938. /**
  92939. * Creates a new default loading screen
  92940. * @param _renderingCanvas defines the canvas used to render the scene
  92941. * @param _loadingText defines the default text to display
  92942. * @param _loadingDivBackgroundColor defines the default background color
  92943. */
  92944. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  92945. /**
  92946. * Function called to display the loading screen
  92947. */
  92948. displayLoadingUI(): void;
  92949. /**
  92950. * Function called to hide the loading screen
  92951. */
  92952. hideLoadingUI(): void;
  92953. /**
  92954. * Gets or sets the text to display while loading
  92955. */
  92956. loadingUIText: string;
  92957. /**
  92958. * Gets or sets the color to use for the background
  92959. */
  92960. loadingUIBackgroundColor: string;
  92961. private _resizeLoadingUI;
  92962. }
  92963. }
  92964. declare module BABYLON {
  92965. /** @hidden */
  92966. export class WebGLPipelineContext implements IPipelineContext {
  92967. engine: Engine;
  92968. program: Nullable<WebGLProgram>;
  92969. context?: WebGLRenderingContext;
  92970. vertexShader?: WebGLShader;
  92971. fragmentShader?: WebGLShader;
  92972. isParallelCompiled: boolean;
  92973. onCompiled?: () => void;
  92974. transformFeedback?: WebGLTransformFeedback | null;
  92975. readonly isAsync: boolean;
  92976. readonly isReady: boolean;
  92977. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  92978. }
  92979. }
  92980. declare module BABYLON {
  92981. /** @hidden */
  92982. export class WebGLDataBuffer extends DataBuffer {
  92983. private _buffer;
  92984. constructor(resource: WebGLBuffer);
  92985. readonly underlyingResource: any;
  92986. }
  92987. }
  92988. declare module BABYLON {
  92989. /** @hidden */
  92990. export class WebGL2ShaderProcessor implements IShaderProcessor {
  92991. attributeProcessor(attribute: string): string;
  92992. varyingProcessor(varying: string, isFragment: boolean): string;
  92993. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  92994. }
  92995. }
  92996. declare module BABYLON {
  92997. /**
  92998. * This class is used to track a performance counter which is number based.
  92999. * The user has access to many properties which give statistics of different nature.
  93000. *
  93001. * The implementer can track two kinds of Performance Counter: time and count.
  93002. * 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.
  93003. * 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.
  93004. */
  93005. export class PerfCounter {
  93006. /**
  93007. * Gets or sets a global boolean to turn on and off all the counters
  93008. */
  93009. static Enabled: boolean;
  93010. /**
  93011. * Returns the smallest value ever
  93012. */
  93013. readonly min: number;
  93014. /**
  93015. * Returns the biggest value ever
  93016. */
  93017. readonly max: number;
  93018. /**
  93019. * Returns the average value since the performance counter is running
  93020. */
  93021. readonly average: number;
  93022. /**
  93023. * Returns the average value of the last second the counter was monitored
  93024. */
  93025. readonly lastSecAverage: number;
  93026. /**
  93027. * Returns the current value
  93028. */
  93029. readonly current: number;
  93030. /**
  93031. * Gets the accumulated total
  93032. */
  93033. readonly total: number;
  93034. /**
  93035. * Gets the total value count
  93036. */
  93037. readonly count: number;
  93038. /**
  93039. * Creates a new counter
  93040. */
  93041. constructor();
  93042. /**
  93043. * Call this method to start monitoring a new frame.
  93044. * 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.
  93045. */
  93046. fetchNewFrame(): void;
  93047. /**
  93048. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93049. * @param newCount the count value to add to the monitored count
  93050. * @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.
  93051. */
  93052. addCount(newCount: number, fetchResult: boolean): void;
  93053. /**
  93054. * Start monitoring this performance counter
  93055. */
  93056. beginMonitoring(): void;
  93057. /**
  93058. * Compute the time lapsed since the previous beginMonitoring() call.
  93059. * @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
  93060. */
  93061. endMonitoring(newFrame?: boolean): void;
  93062. private _fetchResult;
  93063. private _startMonitoringTime;
  93064. private _min;
  93065. private _max;
  93066. private _average;
  93067. private _current;
  93068. private _totalValueCount;
  93069. private _totalAccumulated;
  93070. private _lastSecAverage;
  93071. private _lastSecAccumulated;
  93072. private _lastSecTime;
  93073. private _lastSecValueCount;
  93074. }
  93075. }
  93076. declare module BABYLON {
  93077. /**
  93078. * Interface for any object that can request an animation frame
  93079. */
  93080. export interface ICustomAnimationFrameRequester {
  93081. /**
  93082. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93083. */
  93084. renderFunction?: Function;
  93085. /**
  93086. * Called to request the next frame to render to
  93087. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93088. */
  93089. requestAnimationFrame: Function;
  93090. /**
  93091. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93092. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93093. */
  93094. requestID?: number;
  93095. }
  93096. }
  93097. declare module BABYLON {
  93098. /**
  93099. * Settings for finer control over video usage
  93100. */
  93101. export interface VideoTextureSettings {
  93102. /**
  93103. * Applies `autoplay` to video, if specified
  93104. */
  93105. autoPlay?: boolean;
  93106. /**
  93107. * Applies `loop` to video, if specified
  93108. */
  93109. loop?: boolean;
  93110. /**
  93111. * Automatically updates internal texture from video at every frame in the render loop
  93112. */
  93113. autoUpdateTexture: boolean;
  93114. /**
  93115. * Image src displayed during the video loading or until the user interacts with the video.
  93116. */
  93117. poster?: string;
  93118. }
  93119. /**
  93120. * If you want to display a video in your scene, this is the special texture for that.
  93121. * This special texture works similar to other textures, with the exception of a few parameters.
  93122. * @see https://doc.babylonjs.com/how_to/video_texture
  93123. */
  93124. export class VideoTexture extends Texture {
  93125. /**
  93126. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  93127. */
  93128. readonly autoUpdateTexture: boolean;
  93129. /**
  93130. * The video instance used by the texture internally
  93131. */
  93132. readonly video: HTMLVideoElement;
  93133. private _onUserActionRequestedObservable;
  93134. /**
  93135. * Event triggerd when a dom action is required by the user to play the video.
  93136. * This happens due to recent changes in browser policies preventing video to auto start.
  93137. */
  93138. readonly onUserActionRequestedObservable: Observable<Texture>;
  93139. private _generateMipMaps;
  93140. private _engine;
  93141. private _stillImageCaptured;
  93142. private _displayingPosterTexture;
  93143. private _settings;
  93144. private _createInternalTextureOnEvent;
  93145. /**
  93146. * Creates a video texture.
  93147. * If you want to display a video in your scene, this is the special texture for that.
  93148. * This special texture works similar to other textures, with the exception of a few parameters.
  93149. * @see https://doc.babylonjs.com/how_to/video_texture
  93150. * @param name optional name, will detect from video source, if not defined
  93151. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  93152. * @param scene is obviously the current scene.
  93153. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  93154. * @param invertY is false by default but can be used to invert video on Y axis
  93155. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  93156. * @param settings allows finer control over video usage
  93157. */
  93158. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  93159. private _getName;
  93160. private _getVideo;
  93161. private _createInternalTexture;
  93162. private reset;
  93163. /**
  93164. * @hidden Internal method to initiate `update`.
  93165. */
  93166. _rebuild(): void;
  93167. /**
  93168. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  93169. */
  93170. update(): void;
  93171. /**
  93172. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  93173. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  93174. */
  93175. updateTexture(isVisible: boolean): void;
  93176. protected _updateInternalTexture: () => void;
  93177. /**
  93178. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  93179. * @param url New url.
  93180. */
  93181. updateURL(url: string): void;
  93182. /**
  93183. * Dispose the texture and release its associated resources.
  93184. */
  93185. dispose(): void;
  93186. /**
  93187. * Creates a video texture straight from a stream.
  93188. * @param scene Define the scene the texture should be created in
  93189. * @param stream Define the stream the texture should be created from
  93190. * @returns The created video texture as a promise
  93191. */
  93192. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  93193. /**
  93194. * Creates a video texture straight from your WebCam video feed.
  93195. * @param scene Define the scene the texture should be created in
  93196. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93197. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93198. * @returns The created video texture as a promise
  93199. */
  93200. static CreateFromWebCamAsync(scene: Scene, constraints: {
  93201. minWidth: number;
  93202. maxWidth: number;
  93203. minHeight: number;
  93204. maxHeight: number;
  93205. deviceId: string;
  93206. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  93207. /**
  93208. * Creates a video texture straight from your WebCam video feed.
  93209. * @param scene Define the scene the texture should be created in
  93210. * @param onReady Define a callback to triggered once the texture will be ready
  93211. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  93212. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  93213. */
  93214. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  93215. minWidth: number;
  93216. maxWidth: number;
  93217. minHeight: number;
  93218. maxHeight: number;
  93219. deviceId: string;
  93220. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  93221. }
  93222. }
  93223. declare module BABYLON {
  93224. /**
  93225. * Defines the interface used by objects containing a viewport (like a camera)
  93226. */
  93227. interface IViewportOwnerLike {
  93228. /**
  93229. * Gets or sets the viewport
  93230. */
  93231. viewport: IViewportLike;
  93232. }
  93233. /**
  93234. * Interface for attribute information associated with buffer instanciation
  93235. */
  93236. export class InstancingAttributeInfo {
  93237. /**
  93238. * Index/offset of the attribute in the vertex shader
  93239. */
  93240. index: number;
  93241. /**
  93242. * size of the attribute, 1, 2, 3 or 4
  93243. */
  93244. attributeSize: number;
  93245. /**
  93246. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  93247. * default is FLOAT
  93248. */
  93249. attribyteType: number;
  93250. /**
  93251. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  93252. */
  93253. normalized: boolean;
  93254. /**
  93255. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  93256. */
  93257. offset: number;
  93258. /**
  93259. * Name of the GLSL attribute, for debugging purpose only
  93260. */
  93261. attributeName: string;
  93262. }
  93263. /**
  93264. * Define options used to create a depth texture
  93265. */
  93266. export class DepthTextureCreationOptions {
  93267. /** Specifies whether or not a stencil should be allocated in the texture */
  93268. generateStencil?: boolean;
  93269. /** Specifies whether or not bilinear filtering is enable on the texture */
  93270. bilinearFiltering?: boolean;
  93271. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  93272. comparisonFunction?: number;
  93273. /** Specifies if the created texture is a cube texture */
  93274. isCube?: boolean;
  93275. }
  93276. /**
  93277. * Class used to describe the capabilities of the engine relatively to the current browser
  93278. */
  93279. export class EngineCapabilities {
  93280. /** Maximum textures units per fragment shader */
  93281. maxTexturesImageUnits: number;
  93282. /** Maximum texture units per vertex shader */
  93283. maxVertexTextureImageUnits: number;
  93284. /** Maximum textures units in the entire pipeline */
  93285. maxCombinedTexturesImageUnits: number;
  93286. /** Maximum texture size */
  93287. maxTextureSize: number;
  93288. /** Maximum cube texture size */
  93289. maxCubemapTextureSize: number;
  93290. /** Maximum render texture size */
  93291. maxRenderTextureSize: number;
  93292. /** Maximum number of vertex attributes */
  93293. maxVertexAttribs: number;
  93294. /** Maximum number of varyings */
  93295. maxVaryingVectors: number;
  93296. /** Maximum number of uniforms per vertex shader */
  93297. maxVertexUniformVectors: number;
  93298. /** Maximum number of uniforms per fragment shader */
  93299. maxFragmentUniformVectors: number;
  93300. /** Defines if standard derivates (dx/dy) are supported */
  93301. standardDerivatives: boolean;
  93302. /** Defines if s3tc texture compression is supported */
  93303. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  93304. /** Defines if pvrtc texture compression is supported */
  93305. pvrtc: any;
  93306. /** Defines if etc1 texture compression is supported */
  93307. etc1: any;
  93308. /** Defines if etc2 texture compression is supported */
  93309. etc2: any;
  93310. /** Defines if astc texture compression is supported */
  93311. astc: any;
  93312. /** Defines if float textures are supported */
  93313. textureFloat: boolean;
  93314. /** Defines if vertex array objects are supported */
  93315. vertexArrayObject: boolean;
  93316. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  93317. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  93318. /** Gets the maximum level of anisotropy supported */
  93319. maxAnisotropy: number;
  93320. /** Defines if instancing is supported */
  93321. instancedArrays: boolean;
  93322. /** Defines if 32 bits indices are supported */
  93323. uintIndices: boolean;
  93324. /** Defines if high precision shaders are supported */
  93325. highPrecisionShaderSupported: boolean;
  93326. /** Defines if depth reading in the fragment shader is supported */
  93327. fragmentDepthSupported: boolean;
  93328. /** Defines if float texture linear filtering is supported*/
  93329. textureFloatLinearFiltering: boolean;
  93330. /** Defines if rendering to float textures is supported */
  93331. textureFloatRender: boolean;
  93332. /** Defines if half float textures are supported*/
  93333. textureHalfFloat: boolean;
  93334. /** Defines if half float texture linear filtering is supported*/
  93335. textureHalfFloatLinearFiltering: boolean;
  93336. /** Defines if rendering to half float textures is supported */
  93337. textureHalfFloatRender: boolean;
  93338. /** Defines if textureLOD shader command is supported */
  93339. textureLOD: boolean;
  93340. /** Defines if draw buffers extension is supported */
  93341. drawBuffersExtension: boolean;
  93342. /** Defines if depth textures are supported */
  93343. depthTextureExtension: boolean;
  93344. /** Defines if float color buffer are supported */
  93345. colorBufferFloat: boolean;
  93346. /** Gets disjoint timer query extension (null if not supported) */
  93347. timerQuery: EXT_disjoint_timer_query;
  93348. /** Defines if timestamp can be used with timer query */
  93349. canUseTimestampForTimerQuery: boolean;
  93350. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  93351. multiview: any;
  93352. /** Function used to let the system compiles shaders in background */
  93353. parallelShaderCompile: {
  93354. COMPLETION_STATUS_KHR: number;
  93355. };
  93356. }
  93357. /** Interface defining initialization parameters for Engine class */
  93358. export interface EngineOptions extends WebGLContextAttributes {
  93359. /**
  93360. * Defines if the engine should no exceed a specified device ratio
  93361. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  93362. */
  93363. limitDeviceRatio?: number;
  93364. /**
  93365. * Defines if webvr should be enabled automatically
  93366. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93367. */
  93368. autoEnableWebVR?: boolean;
  93369. /**
  93370. * Defines if webgl2 should be turned off even if supported
  93371. * @see http://doc.babylonjs.com/features/webgl2
  93372. */
  93373. disableWebGL2Support?: boolean;
  93374. /**
  93375. * Defines if webaudio should be initialized as well
  93376. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93377. */
  93378. audioEngine?: boolean;
  93379. /**
  93380. * Defines if animations should run using a deterministic lock step
  93381. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  93382. */
  93383. deterministicLockstep?: boolean;
  93384. /** Defines the maximum steps to use with deterministic lock step mode */
  93385. lockstepMaxSteps?: number;
  93386. /**
  93387. * Defines that engine should ignore context lost events
  93388. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  93389. */
  93390. doNotHandleContextLost?: boolean;
  93391. /**
  93392. * Defines that engine should ignore modifying touch action attribute and style
  93393. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  93394. */
  93395. doNotHandleTouchAction?: boolean;
  93396. /**
  93397. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  93398. */
  93399. useHighPrecisionFloats?: boolean;
  93400. }
  93401. /**
  93402. * Defines the interface used by display changed events
  93403. */
  93404. export interface IDisplayChangedEventArgs {
  93405. /** Gets the vrDisplay object (if any) */
  93406. vrDisplay: Nullable<any>;
  93407. /** Gets a boolean indicating if webVR is supported */
  93408. vrSupported: boolean;
  93409. }
  93410. /**
  93411. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  93412. */
  93413. export class Engine {
  93414. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  93415. static ExceptionList: ({
  93416. key: string;
  93417. capture: string;
  93418. captureConstraint: number;
  93419. targets: string[];
  93420. } | {
  93421. key: string;
  93422. capture: null;
  93423. captureConstraint: null;
  93424. targets: string[];
  93425. })[];
  93426. /** Gets the list of created engines */
  93427. static readonly Instances: Engine[];
  93428. /**
  93429. * Gets the latest created engine
  93430. */
  93431. static readonly LastCreatedEngine: Nullable<Engine>;
  93432. /**
  93433. * Gets the latest created scene
  93434. */
  93435. static readonly LastCreatedScene: Nullable<Scene>;
  93436. /**
  93437. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  93438. * @param flag defines which part of the materials must be marked as dirty
  93439. * @param predicate defines a predicate used to filter which materials should be affected
  93440. */
  93441. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93442. /** @hidden */
  93443. static _TextureLoaders: IInternalTextureLoader[];
  93444. /** Defines that alpha blending is disabled */
  93445. static readonly ALPHA_DISABLE: number;
  93446. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  93447. static readonly ALPHA_ADD: number;
  93448. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  93449. static readonly ALPHA_COMBINE: number;
  93450. /** Defines that alpha blending to DEST - SRC * DEST */
  93451. static readonly ALPHA_SUBTRACT: number;
  93452. /** Defines that alpha blending to SRC * DEST */
  93453. static readonly ALPHA_MULTIPLY: number;
  93454. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  93455. static readonly ALPHA_MAXIMIZED: number;
  93456. /** Defines that alpha blending to SRC + DEST */
  93457. static readonly ALPHA_ONEONE: number;
  93458. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  93459. static readonly ALPHA_PREMULTIPLIED: number;
  93460. /**
  93461. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  93462. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  93463. */
  93464. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  93465. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  93466. static readonly ALPHA_INTERPOLATE: number;
  93467. /**
  93468. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  93469. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  93470. */
  93471. static readonly ALPHA_SCREENMODE: number;
  93472. /** Defines that the ressource is not delayed*/
  93473. static readonly DELAYLOADSTATE_NONE: number;
  93474. /** Defines that the ressource was successfully delay loaded */
  93475. static readonly DELAYLOADSTATE_LOADED: number;
  93476. /** Defines that the ressource is currently delay loading */
  93477. static readonly DELAYLOADSTATE_LOADING: number;
  93478. /** Defines that the ressource is delayed and has not started loading */
  93479. static readonly DELAYLOADSTATE_NOTLOADED: number;
  93480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  93481. static readonly NEVER: number;
  93482. /** 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 */
  93483. static readonly ALWAYS: number;
  93484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  93485. static readonly LESS: number;
  93486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  93487. static readonly EQUAL: number;
  93488. /** 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 */
  93489. static readonly LEQUAL: number;
  93490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  93491. static readonly GREATER: number;
  93492. /** 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 */
  93493. static readonly GEQUAL: number;
  93494. /** 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 */
  93495. static readonly NOTEQUAL: number;
  93496. /** Passed to stencilOperation to specify that stencil value must be kept */
  93497. static readonly KEEP: number;
  93498. /** Passed to stencilOperation to specify that stencil value must be replaced */
  93499. static readonly REPLACE: number;
  93500. /** Passed to stencilOperation to specify that stencil value must be incremented */
  93501. static readonly INCR: number;
  93502. /** Passed to stencilOperation to specify that stencil value must be decremented */
  93503. static readonly DECR: number;
  93504. /** Passed to stencilOperation to specify that stencil value must be inverted */
  93505. static readonly INVERT: number;
  93506. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  93507. static readonly INCR_WRAP: number;
  93508. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  93509. static readonly DECR_WRAP: number;
  93510. /** Texture is not repeating outside of 0..1 UVs */
  93511. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  93512. /** Texture is repeating outside of 0..1 UVs */
  93513. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  93514. /** Texture is repeating and mirrored */
  93515. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  93516. /** ALPHA */
  93517. static readonly TEXTUREFORMAT_ALPHA: number;
  93518. /** LUMINANCE */
  93519. static readonly TEXTUREFORMAT_LUMINANCE: number;
  93520. /** LUMINANCE_ALPHA */
  93521. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  93522. /** RGB */
  93523. static readonly TEXTUREFORMAT_RGB: number;
  93524. /** RGBA */
  93525. static readonly TEXTUREFORMAT_RGBA: number;
  93526. /** RED */
  93527. static readonly TEXTUREFORMAT_RED: number;
  93528. /** RED (2nd reference) */
  93529. static readonly TEXTUREFORMAT_R: number;
  93530. /** RG */
  93531. static readonly TEXTUREFORMAT_RG: number;
  93532. /** RED_INTEGER */
  93533. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  93534. /** RED_INTEGER (2nd reference) */
  93535. static readonly TEXTUREFORMAT_R_INTEGER: number;
  93536. /** RG_INTEGER */
  93537. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  93538. /** RGB_INTEGER */
  93539. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  93540. /** RGBA_INTEGER */
  93541. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  93542. /** UNSIGNED_BYTE */
  93543. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  93544. /** UNSIGNED_BYTE (2nd reference) */
  93545. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  93546. /** FLOAT */
  93547. static readonly TEXTURETYPE_FLOAT: number;
  93548. /** HALF_FLOAT */
  93549. static readonly TEXTURETYPE_HALF_FLOAT: number;
  93550. /** BYTE */
  93551. static readonly TEXTURETYPE_BYTE: number;
  93552. /** SHORT */
  93553. static readonly TEXTURETYPE_SHORT: number;
  93554. /** UNSIGNED_SHORT */
  93555. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  93556. /** INT */
  93557. static readonly TEXTURETYPE_INT: number;
  93558. /** UNSIGNED_INT */
  93559. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  93560. /** UNSIGNED_SHORT_4_4_4_4 */
  93561. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  93562. /** UNSIGNED_SHORT_5_5_5_1 */
  93563. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  93564. /** UNSIGNED_SHORT_5_6_5 */
  93565. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  93566. /** UNSIGNED_INT_2_10_10_10_REV */
  93567. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  93568. /** UNSIGNED_INT_24_8 */
  93569. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  93570. /** UNSIGNED_INT_10F_11F_11F_REV */
  93571. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  93572. /** UNSIGNED_INT_5_9_9_9_REV */
  93573. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  93574. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  93575. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  93576. /** nearest is mag = nearest and min = nearest and mip = linear */
  93577. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  93578. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93579. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  93580. /** Trilinear is mag = linear and min = linear and mip = linear */
  93581. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  93582. /** nearest is mag = nearest and min = nearest and mip = linear */
  93583. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  93584. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93585. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  93586. /** Trilinear is mag = linear and min = linear and mip = linear */
  93587. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  93588. /** mag = nearest and min = nearest and mip = nearest */
  93589. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  93590. /** mag = nearest and min = linear and mip = nearest */
  93591. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  93592. /** mag = nearest and min = linear and mip = linear */
  93593. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  93594. /** mag = nearest and min = linear and mip = none */
  93595. static readonly TEXTURE_NEAREST_LINEAR: number;
  93596. /** mag = nearest and min = nearest and mip = none */
  93597. static readonly TEXTURE_NEAREST_NEAREST: number;
  93598. /** mag = linear and min = nearest and mip = nearest */
  93599. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  93600. /** mag = linear and min = nearest and mip = linear */
  93601. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  93602. /** mag = linear and min = linear and mip = none */
  93603. static readonly TEXTURE_LINEAR_LINEAR: number;
  93604. /** mag = linear and min = nearest and mip = none */
  93605. static readonly TEXTURE_LINEAR_NEAREST: number;
  93606. /** Explicit coordinates mode */
  93607. static readonly TEXTURE_EXPLICIT_MODE: number;
  93608. /** Spherical coordinates mode */
  93609. static readonly TEXTURE_SPHERICAL_MODE: number;
  93610. /** Planar coordinates mode */
  93611. static readonly TEXTURE_PLANAR_MODE: number;
  93612. /** Cubic coordinates mode */
  93613. static readonly TEXTURE_CUBIC_MODE: number;
  93614. /** Projection coordinates mode */
  93615. static readonly TEXTURE_PROJECTION_MODE: number;
  93616. /** Skybox coordinates mode */
  93617. static readonly TEXTURE_SKYBOX_MODE: number;
  93618. /** Inverse Cubic coordinates mode */
  93619. static readonly TEXTURE_INVCUBIC_MODE: number;
  93620. /** Equirectangular coordinates mode */
  93621. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  93622. /** Equirectangular Fixed coordinates mode */
  93623. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  93624. /** Equirectangular Fixed Mirrored coordinates mode */
  93625. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93626. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  93627. static readonly SCALEMODE_FLOOR: number;
  93628. /** Defines that texture rescaling will look for the nearest power of 2 size */
  93629. static readonly SCALEMODE_NEAREST: number;
  93630. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  93631. static readonly SCALEMODE_CEILING: number;
  93632. /**
  93633. * Returns the current npm package of the sdk
  93634. */
  93635. static readonly NpmPackage: string;
  93636. /**
  93637. * Returns the current version of the framework
  93638. */
  93639. static readonly Version: string;
  93640. /**
  93641. * Returns a string describing the current engine
  93642. */
  93643. readonly description: string;
  93644. /**
  93645. * Gets or sets the epsilon value used by collision engine
  93646. */
  93647. static CollisionsEpsilon: number;
  93648. /**
  93649. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  93650. */
  93651. static ShadersRepository: string;
  93652. /**
  93653. * Method called to create the default loading screen.
  93654. * This can be overriden in your own app.
  93655. * @param canvas The rendering canvas element
  93656. * @returns The loading screen
  93657. */
  93658. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  93659. /**
  93660. * Method called to create the default rescale post process on each engine.
  93661. */
  93662. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  93663. /** @hidden */
  93664. _shaderProcessor: IShaderProcessor;
  93665. /**
  93666. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  93667. */
  93668. forcePOTTextures: boolean;
  93669. /**
  93670. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  93671. */
  93672. isFullscreen: boolean;
  93673. /**
  93674. * Gets a boolean indicating if the pointer is currently locked
  93675. */
  93676. isPointerLock: boolean;
  93677. /**
  93678. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  93679. */
  93680. cullBackFaces: boolean;
  93681. /**
  93682. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  93683. */
  93684. renderEvenInBackground: boolean;
  93685. /**
  93686. * Gets or sets a boolean indicating that cache can be kept between frames
  93687. */
  93688. preventCacheWipeBetweenFrames: boolean;
  93689. /**
  93690. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  93691. **/
  93692. enableOfflineSupport: boolean;
  93693. /**
  93694. * 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)
  93695. **/
  93696. disableManifestCheck: boolean;
  93697. /**
  93698. * Gets the list of created scenes
  93699. */
  93700. scenes: Scene[];
  93701. /**
  93702. * Event raised when a new scene is created
  93703. */
  93704. onNewSceneAddedObservable: Observable<Scene>;
  93705. /**
  93706. * Gets the list of created postprocesses
  93707. */
  93708. postProcesses: PostProcess[];
  93709. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  93710. validateShaderPrograms: boolean;
  93711. /**
  93712. * Observable event triggered each time the rendering canvas is resized
  93713. */
  93714. onResizeObservable: Observable<Engine>;
  93715. /**
  93716. * Observable event triggered each time the canvas loses focus
  93717. */
  93718. onCanvasBlurObservable: Observable<Engine>;
  93719. /**
  93720. * Observable event triggered each time the canvas gains focus
  93721. */
  93722. onCanvasFocusObservable: Observable<Engine>;
  93723. /**
  93724. * Observable event triggered each time the canvas receives pointerout event
  93725. */
  93726. onCanvasPointerOutObservable: Observable<PointerEvent>;
  93727. /**
  93728. * Observable event triggered before each texture is initialized
  93729. */
  93730. onBeforeTextureInitObservable: Observable<Texture>;
  93731. /**
  93732. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  93733. */
  93734. disableUniformBuffers: boolean;
  93735. /** @hidden */
  93736. _uniformBuffers: UniformBuffer[];
  93737. /**
  93738. * Gets a boolean indicating that the engine supports uniform buffers
  93739. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  93740. */
  93741. readonly supportsUniformBuffers: boolean;
  93742. /**
  93743. * Observable raised when the engine begins a new frame
  93744. */
  93745. onBeginFrameObservable: Observable<Engine>;
  93746. /**
  93747. * If set, will be used to request the next animation frame for the render loop
  93748. */
  93749. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  93750. /**
  93751. * Observable raised when the engine ends the current frame
  93752. */
  93753. onEndFrameObservable: Observable<Engine>;
  93754. /**
  93755. * Observable raised when the engine is about to compile a shader
  93756. */
  93757. onBeforeShaderCompilationObservable: Observable<Engine>;
  93758. /**
  93759. * Observable raised when the engine has jsut compiled a shader
  93760. */
  93761. onAfterShaderCompilationObservable: Observable<Engine>;
  93762. /** @hidden */
  93763. _gl: WebGLRenderingContext;
  93764. private _renderingCanvas;
  93765. private _windowIsBackground;
  93766. private _webGLVersion;
  93767. protected _highPrecisionShadersAllowed: boolean;
  93768. /** @hidden */
  93769. readonly _shouldUseHighPrecisionShader: boolean;
  93770. /**
  93771. * Gets a boolean indicating that only power of 2 textures are supported
  93772. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  93773. */
  93774. readonly needPOTTextures: boolean;
  93775. /** @hidden */
  93776. _badOS: boolean;
  93777. /** @hidden */
  93778. _badDesktopOS: boolean;
  93779. /**
  93780. * Gets the audio engine
  93781. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93782. * @ignorenaming
  93783. */
  93784. static audioEngine: IAudioEngine;
  93785. /**
  93786. * Default AudioEngine factory responsible of creating the Audio Engine.
  93787. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  93788. */
  93789. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  93790. /**
  93791. * Default offline support factory responsible of creating a tool used to store data locally.
  93792. * By default, this will create a Database object if the workload has been embedded.
  93793. */
  93794. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  93795. private _onFocus;
  93796. private _onBlur;
  93797. private _onCanvasPointerOut;
  93798. private _onCanvasBlur;
  93799. private _onCanvasFocus;
  93800. private _onFullscreenChange;
  93801. private _onPointerLockChange;
  93802. private _hardwareScalingLevel;
  93803. /** @hidden */
  93804. _caps: EngineCapabilities;
  93805. private _pointerLockRequested;
  93806. private _isStencilEnable;
  93807. private _colorWrite;
  93808. private _loadingScreen;
  93809. /** @hidden */
  93810. _drawCalls: PerfCounter;
  93811. private _glVersion;
  93812. private _glRenderer;
  93813. private _glVendor;
  93814. private _videoTextureSupported;
  93815. private _renderingQueueLaunched;
  93816. private _activeRenderLoops;
  93817. private _deterministicLockstep;
  93818. private _lockstepMaxSteps;
  93819. /**
  93820. * Observable signaled when a context lost event is raised
  93821. */
  93822. onContextLostObservable: Observable<Engine>;
  93823. /**
  93824. * Observable signaled when a context restored event is raised
  93825. */
  93826. onContextRestoredObservable: Observable<Engine>;
  93827. private _onContextLost;
  93828. private _onContextRestored;
  93829. private _contextWasLost;
  93830. /** @hidden */
  93831. _doNotHandleContextLost: boolean;
  93832. /**
  93833. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  93834. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  93835. */
  93836. doNotHandleContextLost: boolean;
  93837. private _performanceMonitor;
  93838. private _fps;
  93839. private _deltaTime;
  93840. /**
  93841. * Turn this value on if you want to pause FPS computation when in background
  93842. */
  93843. disablePerformanceMonitorInBackground: boolean;
  93844. /**
  93845. * Gets the performance monitor attached to this engine
  93846. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  93847. */
  93848. readonly performanceMonitor: PerformanceMonitor;
  93849. /**
  93850. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  93851. */
  93852. disableVertexArrayObjects: boolean;
  93853. /** @hidden */
  93854. protected _depthCullingState: _DepthCullingState;
  93855. /** @hidden */
  93856. protected _stencilState: _StencilState;
  93857. /** @hidden */
  93858. protected _alphaState: _AlphaState;
  93859. /** @hidden */
  93860. protected _alphaMode: number;
  93861. /** @hidden */
  93862. _internalTexturesCache: InternalTexture[];
  93863. /** @hidden */
  93864. protected _activeChannel: number;
  93865. private _currentTextureChannel;
  93866. /** @hidden */
  93867. protected _boundTexturesCache: {
  93868. [key: string]: Nullable<InternalTexture>;
  93869. };
  93870. /** @hidden */
  93871. protected _currentEffect: Nullable<Effect>;
  93872. /** @hidden */
  93873. protected _currentProgram: Nullable<WebGLProgram>;
  93874. private _compiledEffects;
  93875. private _vertexAttribArraysEnabled;
  93876. /** @hidden */
  93877. protected _cachedViewport: Nullable<IViewportLike>;
  93878. private _cachedVertexArrayObject;
  93879. /** @hidden */
  93880. protected _cachedVertexBuffers: any;
  93881. /** @hidden */
  93882. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  93883. /** @hidden */
  93884. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  93885. /** @hidden */
  93886. _currentRenderTarget: Nullable<InternalTexture>;
  93887. private _uintIndicesCurrentlySet;
  93888. private _currentBoundBuffer;
  93889. /** @hidden */
  93890. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  93891. private _currentBufferPointers;
  93892. private _currentInstanceLocations;
  93893. private _currentInstanceBuffers;
  93894. private _textureUnits;
  93895. /** @hidden */
  93896. _workingCanvas: Nullable<HTMLCanvasElement>;
  93897. /** @hidden */
  93898. _workingContext: Nullable<CanvasRenderingContext2D>;
  93899. private _rescalePostProcess;
  93900. private _dummyFramebuffer;
  93901. private _externalData;
  93902. /** @hidden */
  93903. _bindedRenderFunction: any;
  93904. private _vaoRecordInProgress;
  93905. private _mustWipeVertexAttributes;
  93906. private _emptyTexture;
  93907. private _emptyCubeTexture;
  93908. private _emptyTexture3D;
  93909. /** @hidden */
  93910. _frameHandler: number;
  93911. private _nextFreeTextureSlots;
  93912. private _maxSimultaneousTextures;
  93913. private _activeRequests;
  93914. private _texturesSupported;
  93915. /** @hidden */
  93916. _textureFormatInUse: Nullable<string>;
  93917. /**
  93918. * Gets the list of texture formats supported
  93919. */
  93920. readonly texturesSupported: Array<string>;
  93921. /**
  93922. * Gets the list of texture formats in use
  93923. */
  93924. readonly textureFormatInUse: Nullable<string>;
  93925. /**
  93926. * Gets the current viewport
  93927. */
  93928. readonly currentViewport: Nullable<IViewportLike>;
  93929. /**
  93930. * Gets the default empty texture
  93931. */
  93932. readonly emptyTexture: InternalTexture;
  93933. /**
  93934. * Gets the default empty 3D texture
  93935. */
  93936. readonly emptyTexture3D: InternalTexture;
  93937. /**
  93938. * Gets the default empty cube texture
  93939. */
  93940. readonly emptyCubeTexture: InternalTexture;
  93941. /**
  93942. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  93943. */
  93944. readonly premultipliedAlpha: boolean;
  93945. /**
  93946. * Creates a new engine
  93947. * @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
  93948. * @param antialias defines enable antialiasing (default: false)
  93949. * @param options defines further options to be sent to the getContext() function
  93950. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  93951. */
  93952. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  93953. /**
  93954. * Initializes a webVR display and starts listening to display change events
  93955. * The onVRDisplayChangedObservable will be notified upon these changes
  93956. * @returns The onVRDisplayChangedObservable
  93957. */
  93958. initWebVR(): Observable<IDisplayChangedEventArgs>;
  93959. /** @hidden */
  93960. _prepareVRComponent(): void;
  93961. /** @hidden */
  93962. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  93963. /** @hidden */
  93964. _submitVRFrame(): void;
  93965. /**
  93966. * Call this function to leave webVR mode
  93967. * Will do nothing if webVR is not supported or if there is no webVR device
  93968. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93969. */
  93970. disableVR(): void;
  93971. /**
  93972. * Gets a boolean indicating that the system is in VR mode and is presenting
  93973. * @returns true if VR mode is engaged
  93974. */
  93975. isVRPresenting(): boolean;
  93976. /** @hidden */
  93977. _requestVRFrame(): void;
  93978. private _disableTouchAction;
  93979. private _rebuildInternalTextures;
  93980. private _rebuildEffects;
  93981. /**
  93982. * Gets a boolean indicating if all created effects are ready
  93983. * @returns true if all effects are ready
  93984. */
  93985. areAllEffectsReady(): boolean;
  93986. private _rebuildBuffers;
  93987. private _initGLContext;
  93988. /**
  93989. * Gets version of the current webGL context
  93990. */
  93991. readonly webGLVersion: number;
  93992. /**
  93993. * Gets a string idenfifying the name of the class
  93994. * @returns "Engine" string
  93995. */
  93996. getClassName(): string;
  93997. /**
  93998. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  93999. */
  94000. readonly isStencilEnable: boolean;
  94001. /** @hidden */
  94002. _prepareWorkingCanvas(): void;
  94003. /**
  94004. * Reset the texture cache to empty state
  94005. */
  94006. resetTextureCache(): void;
  94007. /**
  94008. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  94009. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94010. * @returns true if engine is in deterministic lock step mode
  94011. */
  94012. isDeterministicLockStep(): boolean;
  94013. /**
  94014. * Gets the max steps when engine is running in deterministic lock step
  94015. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94016. * @returns the max steps
  94017. */
  94018. getLockstepMaxSteps(): number;
  94019. /**
  94020. * Gets an object containing information about the current webGL context
  94021. * @returns an object containing the vender, the renderer and the version of the current webGL context
  94022. */
  94023. getGlInfo(): {
  94024. vendor: string;
  94025. renderer: string;
  94026. version: string;
  94027. };
  94028. /**
  94029. * Gets current aspect ratio
  94030. * @param viewportOwner defines the camera to use to get the aspect ratio
  94031. * @param useScreen defines if screen size must be used (or the current render target if any)
  94032. * @returns a number defining the aspect ratio
  94033. */
  94034. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  94035. /**
  94036. * Gets current screen aspect ratio
  94037. * @returns a number defining the aspect ratio
  94038. */
  94039. getScreenAspectRatio(): number;
  94040. /**
  94041. * Gets the current render width
  94042. * @param useScreen defines if screen size must be used (or the current render target if any)
  94043. * @returns a number defining the current render width
  94044. */
  94045. getRenderWidth(useScreen?: boolean): number;
  94046. /**
  94047. * Gets the current render height
  94048. * @param useScreen defines if screen size must be used (or the current render target if any)
  94049. * @returns a number defining the current render height
  94050. */
  94051. getRenderHeight(useScreen?: boolean): number;
  94052. /**
  94053. * Gets the HTML canvas attached with the current webGL context
  94054. * @returns a HTML canvas
  94055. */
  94056. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  94057. /**
  94058. * Gets the client rect of the HTML canvas attached with the current webGL context
  94059. * @returns a client rectanglee
  94060. */
  94061. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  94062. /**
  94063. * Defines the hardware scaling level.
  94064. * By default the hardware scaling level is computed from the window device ratio.
  94065. * 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.
  94066. * @param level defines the level to use
  94067. */
  94068. setHardwareScalingLevel(level: number): void;
  94069. /**
  94070. * Gets the current hardware scaling level.
  94071. * By default the hardware scaling level is computed from the window device ratio.
  94072. * 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.
  94073. * @returns a number indicating the current hardware scaling level
  94074. */
  94075. getHardwareScalingLevel(): number;
  94076. /**
  94077. * Gets the list of loaded textures
  94078. * @returns an array containing all loaded textures
  94079. */
  94080. getLoadedTexturesCache(): InternalTexture[];
  94081. /**
  94082. * Gets the object containing all engine capabilities
  94083. * @returns the EngineCapabilities object
  94084. */
  94085. getCaps(): EngineCapabilities;
  94086. /**
  94087. * Gets the current depth function
  94088. * @returns a number defining the depth function
  94089. */
  94090. getDepthFunction(): Nullable<number>;
  94091. /**
  94092. * Sets the current depth function
  94093. * @param depthFunc defines the function to use
  94094. */
  94095. setDepthFunction(depthFunc: number): void;
  94096. /**
  94097. * Sets the current depth function to GREATER
  94098. */
  94099. setDepthFunctionToGreater(): void;
  94100. /**
  94101. * Sets the current depth function to GEQUAL
  94102. */
  94103. setDepthFunctionToGreaterOrEqual(): void;
  94104. /**
  94105. * Sets the current depth function to LESS
  94106. */
  94107. setDepthFunctionToLess(): void;
  94108. private _cachedStencilBuffer;
  94109. private _cachedStencilFunction;
  94110. private _cachedStencilMask;
  94111. private _cachedStencilOperationPass;
  94112. private _cachedStencilOperationFail;
  94113. private _cachedStencilOperationDepthFail;
  94114. private _cachedStencilReference;
  94115. /**
  94116. * Caches the the state of the stencil buffer
  94117. */
  94118. cacheStencilState(): void;
  94119. /**
  94120. * Restores the state of the stencil buffer
  94121. */
  94122. restoreStencilState(): void;
  94123. /**
  94124. * Sets the current depth function to LEQUAL
  94125. */
  94126. setDepthFunctionToLessOrEqual(): void;
  94127. /**
  94128. * Gets a boolean indicating if stencil buffer is enabled
  94129. * @returns the current stencil buffer state
  94130. */
  94131. getStencilBuffer(): boolean;
  94132. /**
  94133. * Enable or disable the stencil buffer
  94134. * @param enable defines if the stencil buffer must be enabled or disabled
  94135. */
  94136. setStencilBuffer(enable: boolean): void;
  94137. /**
  94138. * Gets the current stencil mask
  94139. * @returns a number defining the new stencil mask to use
  94140. */
  94141. getStencilMask(): number;
  94142. /**
  94143. * Sets the current stencil mask
  94144. * @param mask defines the new stencil mask to use
  94145. */
  94146. setStencilMask(mask: number): void;
  94147. /**
  94148. * Gets the current stencil function
  94149. * @returns a number defining the stencil function to use
  94150. */
  94151. getStencilFunction(): number;
  94152. /**
  94153. * Gets the current stencil reference value
  94154. * @returns a number defining the stencil reference value to use
  94155. */
  94156. getStencilFunctionReference(): number;
  94157. /**
  94158. * Gets the current stencil mask
  94159. * @returns a number defining the stencil mask to use
  94160. */
  94161. getStencilFunctionMask(): number;
  94162. /**
  94163. * Sets the current stencil function
  94164. * @param stencilFunc defines the new stencil function to use
  94165. */
  94166. setStencilFunction(stencilFunc: number): void;
  94167. /**
  94168. * Sets the current stencil reference
  94169. * @param reference defines the new stencil reference to use
  94170. */
  94171. setStencilFunctionReference(reference: number): void;
  94172. /**
  94173. * Sets the current stencil mask
  94174. * @param mask defines the new stencil mask to use
  94175. */
  94176. setStencilFunctionMask(mask: number): void;
  94177. /**
  94178. * Gets the current stencil operation when stencil fails
  94179. * @returns a number defining stencil operation to use when stencil fails
  94180. */
  94181. getStencilOperationFail(): number;
  94182. /**
  94183. * Gets the current stencil operation when depth fails
  94184. * @returns a number defining stencil operation to use when depth fails
  94185. */
  94186. getStencilOperationDepthFail(): number;
  94187. /**
  94188. * Gets the current stencil operation when stencil passes
  94189. * @returns a number defining stencil operation to use when stencil passes
  94190. */
  94191. getStencilOperationPass(): number;
  94192. /**
  94193. * Sets the stencil operation to use when stencil fails
  94194. * @param operation defines the stencil operation to use when stencil fails
  94195. */
  94196. setStencilOperationFail(operation: number): void;
  94197. /**
  94198. * Sets the stencil operation to use when depth fails
  94199. * @param operation defines the stencil operation to use when depth fails
  94200. */
  94201. setStencilOperationDepthFail(operation: number): void;
  94202. /**
  94203. * Sets the stencil operation to use when stencil passes
  94204. * @param operation defines the stencil operation to use when stencil passes
  94205. */
  94206. setStencilOperationPass(operation: number): void;
  94207. /**
  94208. * Sets a boolean indicating if the dithering state is enabled or disabled
  94209. * @param value defines the dithering state
  94210. */
  94211. setDitheringState(value: boolean): void;
  94212. /**
  94213. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  94214. * @param value defines the rasterizer state
  94215. */
  94216. setRasterizerState(value: boolean): void;
  94217. /**
  94218. * stop executing a render loop function and remove it from the execution array
  94219. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  94220. */
  94221. stopRenderLoop(renderFunction?: () => void): void;
  94222. /** @hidden */
  94223. _renderLoop(): void;
  94224. /**
  94225. * Register and execute a render loop. The engine can have more than one render function
  94226. * @param renderFunction defines the function to continuously execute
  94227. */
  94228. runRenderLoop(renderFunction: () => void): void;
  94229. /**
  94230. * Toggle full screen mode
  94231. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94232. */
  94233. switchFullscreen(requestPointerLock: boolean): void;
  94234. /**
  94235. * Enters full screen mode
  94236. * @param requestPointerLock defines if a pointer lock should be requested from the user
  94237. */
  94238. enterFullscreen(requestPointerLock: boolean): void;
  94239. /**
  94240. * Exits full screen mode
  94241. */
  94242. exitFullscreen(): void;
  94243. /**
  94244. * Enters Pointerlock mode
  94245. */
  94246. enterPointerlock(): void;
  94247. /**
  94248. * Exits Pointerlock mode
  94249. */
  94250. exitPointerlock(): void;
  94251. /**
  94252. * Clear the current render buffer or the current render target (if any is set up)
  94253. * @param color defines the color to use
  94254. * @param backBuffer defines if the back buffer must be cleared
  94255. * @param depth defines if the depth buffer must be cleared
  94256. * @param stencil defines if the stencil buffer must be cleared
  94257. */
  94258. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  94259. /**
  94260. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  94261. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94262. * @param y defines the y-coordinate of the corner of the clear rectangle
  94263. * @param width defines the width of the clear rectangle
  94264. * @param height defines the height of the clear rectangle
  94265. * @param clearColor defines the clear color
  94266. */
  94267. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  94268. /**
  94269. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  94270. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  94271. * @param y defines the y-coordinate of the corner of the clear rectangle
  94272. * @param width defines the width of the clear rectangle
  94273. * @param height defines the height of the clear rectangle
  94274. */
  94275. enableScissor(x: number, y: number, width: number, height: number): void;
  94276. /**
  94277. * Disable previously set scissor test rectangle
  94278. */
  94279. disableScissor(): void;
  94280. private _viewportCached;
  94281. /** @hidden */
  94282. _viewport(x: number, y: number, width: number, height: number): void;
  94283. /**
  94284. * Set the WebGL's viewport
  94285. * @param viewport defines the viewport element to be used
  94286. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  94287. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  94288. */
  94289. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  94290. /**
  94291. * Directly set the WebGL Viewport
  94292. * @param x defines the x coordinate of the viewport (in screen space)
  94293. * @param y defines the y coordinate of the viewport (in screen space)
  94294. * @param width defines the width of the viewport (in screen space)
  94295. * @param height defines the height of the viewport (in screen space)
  94296. * @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
  94297. */
  94298. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  94299. /**
  94300. * Begin a new frame
  94301. */
  94302. beginFrame(): void;
  94303. /**
  94304. * Enf the current frame
  94305. */
  94306. endFrame(): void;
  94307. /**
  94308. * Resize the view according to the canvas' size
  94309. */
  94310. resize(): void;
  94311. /**
  94312. * Force a specific size of the canvas
  94313. * @param width defines the new canvas' width
  94314. * @param height defines the new canvas' height
  94315. */
  94316. setSize(width: number, height: number): void;
  94317. /**
  94318. * Binds the frame buffer to the specified texture.
  94319. * @param texture The texture to render to or null for the default canvas
  94320. * @param faceIndex The face of the texture to render to in case of cube texture
  94321. * @param requiredWidth The width of the target to render to
  94322. * @param requiredHeight The height of the target to render to
  94323. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  94324. * @param depthStencilTexture The depth stencil texture to use to render
  94325. * @param lodLevel defines le lod level to bind to the frame buffer
  94326. */
  94327. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  94328. /** @hidden */
  94329. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  94330. /**
  94331. * Unbind the current render target texture from the webGL context
  94332. * @param texture defines the render target texture to unbind
  94333. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  94334. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  94335. */
  94336. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  94337. /**
  94338. * Force the mipmap generation for the given render target texture
  94339. * @param texture defines the render target texture to use
  94340. */
  94341. generateMipMapsForCubemap(texture: InternalTexture): void;
  94342. /**
  94343. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  94344. */
  94345. flushFramebuffer(): void;
  94346. /**
  94347. * Unbind the current render target and bind the default framebuffer
  94348. */
  94349. restoreDefaultFramebuffer(): void;
  94350. /**
  94351. * Create an uniform buffer
  94352. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94353. * @param elements defines the content of the uniform buffer
  94354. * @returns the webGL uniform buffer
  94355. */
  94356. createUniformBuffer(elements: FloatArray): DataBuffer;
  94357. /**
  94358. * Create a dynamic uniform buffer
  94359. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94360. * @param elements defines the content of the uniform buffer
  94361. * @returns the webGL uniform buffer
  94362. */
  94363. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  94364. /**
  94365. * Update an existing uniform buffer
  94366. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  94367. * @param uniformBuffer defines the target uniform buffer
  94368. * @param elements defines the content to update
  94369. * @param offset defines the offset in the uniform buffer where update should start
  94370. * @param count defines the size of the data to update
  94371. */
  94372. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  94373. private _resetVertexBufferBinding;
  94374. /**
  94375. * Creates a vertex buffer
  94376. * @param data the data for the vertex buffer
  94377. * @returns the new WebGL static buffer
  94378. */
  94379. createVertexBuffer(data: DataArray): DataBuffer;
  94380. /**
  94381. * Creates a dynamic vertex buffer
  94382. * @param data the data for the dynamic vertex buffer
  94383. * @returns the new WebGL dynamic buffer
  94384. */
  94385. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  94386. /**
  94387. * Update a dynamic index buffer
  94388. * @param indexBuffer defines the target index buffer
  94389. * @param indices defines the data to update
  94390. * @param offset defines the offset in the target index buffer where update should start
  94391. */
  94392. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  94393. /**
  94394. * Updates a dynamic vertex buffer.
  94395. * @param vertexBuffer the vertex buffer to update
  94396. * @param data the data used to update the vertex buffer
  94397. * @param byteOffset the byte offset of the data
  94398. * @param byteLength the byte length of the data
  94399. */
  94400. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  94401. private _resetIndexBufferBinding;
  94402. /**
  94403. * Creates a new index buffer
  94404. * @param indices defines the content of the index buffer
  94405. * @param updatable defines if the index buffer must be updatable
  94406. * @returns a new webGL buffer
  94407. */
  94408. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  94409. /**
  94410. * Bind a webGL buffer to the webGL context
  94411. * @param buffer defines the buffer to bind
  94412. */
  94413. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  94414. /**
  94415. * Bind an uniform buffer to the current webGL context
  94416. * @param buffer defines the buffer to bind
  94417. */
  94418. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  94419. /**
  94420. * Bind a buffer to the current webGL context at a given location
  94421. * @param buffer defines the buffer to bind
  94422. * @param location defines the index where to bind the buffer
  94423. */
  94424. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  94425. /**
  94426. * Bind a specific block at a given index in a specific shader program
  94427. * @param pipelineContext defines the pipeline context to use
  94428. * @param blockName defines the block name
  94429. * @param index defines the index where to bind the block
  94430. */
  94431. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  94432. private bindIndexBuffer;
  94433. private bindBuffer;
  94434. /**
  94435. * update the bound buffer with the given data
  94436. * @param data defines the data to update
  94437. */
  94438. updateArrayBuffer(data: Float32Array): void;
  94439. private _vertexAttribPointer;
  94440. private _bindIndexBufferWithCache;
  94441. private _bindVertexBuffersAttributes;
  94442. /**
  94443. * Records a vertex array object
  94444. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94445. * @param vertexBuffers defines the list of vertex buffers to store
  94446. * @param indexBuffer defines the index buffer to store
  94447. * @param effect defines the effect to store
  94448. * @returns the new vertex array object
  94449. */
  94450. recordVertexArrayObject(vertexBuffers: {
  94451. [key: string]: VertexBuffer;
  94452. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  94453. /**
  94454. * Bind a specific vertex array object
  94455. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  94456. * @param vertexArrayObject defines the vertex array object to bind
  94457. * @param indexBuffer defines the index buffer to bind
  94458. */
  94459. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  94460. /**
  94461. * Bind webGl buffers directly to the webGL context
  94462. * @param vertexBuffer defines the vertex buffer to bind
  94463. * @param indexBuffer defines the index buffer to bind
  94464. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  94465. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  94466. * @param effect defines the effect associated with the vertex buffer
  94467. */
  94468. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  94469. private _unbindVertexArrayObject;
  94470. /**
  94471. * Bind a list of vertex buffers to the webGL context
  94472. * @param vertexBuffers defines the list of vertex buffers to bind
  94473. * @param indexBuffer defines the index buffer to bind
  94474. * @param effect defines the effect associated with the vertex buffers
  94475. */
  94476. bindBuffers(vertexBuffers: {
  94477. [key: string]: Nullable<VertexBuffer>;
  94478. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  94479. /**
  94480. * Unbind all instance attributes
  94481. */
  94482. unbindInstanceAttributes(): void;
  94483. /**
  94484. * Release and free the memory of a vertex array object
  94485. * @param vao defines the vertex array object to delete
  94486. */
  94487. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  94488. /** @hidden */
  94489. _releaseBuffer(buffer: DataBuffer): boolean;
  94490. /**
  94491. * Creates a webGL buffer to use with instanciation
  94492. * @param capacity defines the size of the buffer
  94493. * @returns the webGL buffer
  94494. */
  94495. createInstancesBuffer(capacity: number): DataBuffer;
  94496. /**
  94497. * Delete a webGL buffer used with instanciation
  94498. * @param buffer defines the webGL buffer to delete
  94499. */
  94500. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  94501. /**
  94502. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  94503. * @param instancesBuffer defines the webGL buffer to update and bind
  94504. * @param data defines the data to store in the buffer
  94505. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  94506. */
  94507. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  94508. /**
  94509. * Apply all cached states (depth, culling, stencil and alpha)
  94510. */
  94511. applyStates(): void;
  94512. /**
  94513. * Send a draw order
  94514. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94515. * @param indexStart defines the starting index
  94516. * @param indexCount defines the number of index to draw
  94517. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94518. */
  94519. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  94520. /**
  94521. * Draw a list of points
  94522. * @param verticesStart defines the index of first vertex to draw
  94523. * @param verticesCount defines the count of vertices to draw
  94524. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94525. */
  94526. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94527. /**
  94528. * Draw a list of unindexed primitives
  94529. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  94530. * @param verticesStart defines the index of first vertex to draw
  94531. * @param verticesCount defines the count of vertices to draw
  94532. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94533. */
  94534. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94535. /**
  94536. * Draw a list of indexed primitives
  94537. * @param fillMode defines the primitive to use
  94538. * @param indexStart defines the starting index
  94539. * @param indexCount defines the number of index to draw
  94540. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94541. */
  94542. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  94543. /**
  94544. * Draw a list of unindexed primitives
  94545. * @param fillMode defines the primitive to use
  94546. * @param verticesStart defines the index of first vertex to draw
  94547. * @param verticesCount defines the count of vertices to draw
  94548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  94549. */
  94550. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  94551. private _drawMode;
  94552. /** @hidden */
  94553. _releaseEffect(effect: Effect): void;
  94554. /** @hidden */
  94555. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  94556. /**
  94557. * Create a new effect (used to store vertex/fragment shaders)
  94558. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  94559. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  94560. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  94561. * @param samplers defines an array of string used to represent textures
  94562. * @param defines defines the string containing the defines to use to compile the shaders
  94563. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  94564. * @param onCompiled defines a function to call when the effect creation is successful
  94565. * @param onError defines a function to call when the effect creation has failed
  94566. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  94567. * @returns the new Effect
  94568. */
  94569. 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;
  94570. private _compileShader;
  94571. private _compileRawShader;
  94572. /**
  94573. * Directly creates a webGL program
  94574. * @param pipelineContext defines the pipeline context to attach to
  94575. * @param vertexCode defines the vertex shader code to use
  94576. * @param fragmentCode defines the fragment shader code to use
  94577. * @param context defines the webGL context to use (if not set, the current one will be used)
  94578. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94579. * @returns the new webGL program
  94580. */
  94581. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94582. /**
  94583. * Creates a webGL program
  94584. * @param pipelineContext defines the pipeline context to attach to
  94585. * @param vertexCode defines the vertex shader code to use
  94586. * @param fragmentCode defines the fragment shader code to use
  94587. * @param defines defines the string containing the defines to use to compile the shaders
  94588. * @param context defines the webGL context to use (if not set, the current one will be used)
  94589. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  94590. * @returns the new webGL program
  94591. */
  94592. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  94593. /**
  94594. * Creates a new pipeline context
  94595. * @returns the new pipeline
  94596. */
  94597. createPipelineContext(): WebGLPipelineContext;
  94598. private _createShaderProgram;
  94599. private _finalizePipelineContext;
  94600. /** @hidden */
  94601. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  94602. /** @hidden */
  94603. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  94604. /** @hidden */
  94605. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  94606. /**
  94607. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  94608. * @param pipelineContext defines the pipeline context to use
  94609. * @param uniformsNames defines the list of uniform names
  94610. * @returns an array of webGL uniform locations
  94611. */
  94612. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  94613. /**
  94614. * Gets the lsit of active attributes for a given webGL program
  94615. * @param pipelineContext defines the pipeline context to use
  94616. * @param attributesNames defines the list of attribute names to get
  94617. * @returns an array of indices indicating the offset of each attribute
  94618. */
  94619. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  94620. /**
  94621. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  94622. * @param effect defines the effect to activate
  94623. */
  94624. enableEffect(effect: Nullable<Effect>): void;
  94625. /**
  94626. * Set the value of an uniform to an array of int32
  94627. * @param uniform defines the webGL uniform location where to store the value
  94628. * @param array defines the array of int32 to store
  94629. */
  94630. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94631. /**
  94632. * Set the value of an uniform to an array of int32 (stored as vec2)
  94633. * @param uniform defines the webGL uniform location where to store the value
  94634. * @param array defines the array of int32 to store
  94635. */
  94636. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94637. /**
  94638. * Set the value of an uniform to an array of int32 (stored as vec3)
  94639. * @param uniform defines the webGL uniform location where to store the value
  94640. * @param array defines the array of int32 to store
  94641. */
  94642. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94643. /**
  94644. * Set the value of an uniform to an array of int32 (stored as vec4)
  94645. * @param uniform defines the webGL uniform location where to store the value
  94646. * @param array defines the array of int32 to store
  94647. */
  94648. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  94649. /**
  94650. * Set the value of an uniform to an array of float32
  94651. * @param uniform defines the webGL uniform location where to store the value
  94652. * @param array defines the array of float32 to store
  94653. */
  94654. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94655. /**
  94656. * Set the value of an uniform to an array of float32 (stored as vec2)
  94657. * @param uniform defines the webGL uniform location where to store the value
  94658. * @param array defines the array of float32 to store
  94659. */
  94660. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94661. /**
  94662. * Set the value of an uniform to an array of float32 (stored as vec3)
  94663. * @param uniform defines the webGL uniform location where to store the value
  94664. * @param array defines the array of float32 to store
  94665. */
  94666. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94667. /**
  94668. * Set the value of an uniform to an array of float32 (stored as vec4)
  94669. * @param uniform defines the webGL uniform location where to store the value
  94670. * @param array defines the array of float32 to store
  94671. */
  94672. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  94673. /**
  94674. * Set the value of an uniform to an array of number
  94675. * @param uniform defines the webGL uniform location where to store the value
  94676. * @param array defines the array of number to store
  94677. */
  94678. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94679. /**
  94680. * Set the value of an uniform to an array of number (stored as vec2)
  94681. * @param uniform defines the webGL uniform location where to store the value
  94682. * @param array defines the array of number to store
  94683. */
  94684. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94685. /**
  94686. * Set the value of an uniform to an array of number (stored as vec3)
  94687. * @param uniform defines the webGL uniform location where to store the value
  94688. * @param array defines the array of number to store
  94689. */
  94690. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94691. /**
  94692. * Set the value of an uniform to an array of number (stored as vec4)
  94693. * @param uniform defines the webGL uniform location where to store the value
  94694. * @param array defines the array of number to store
  94695. */
  94696. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  94697. /**
  94698. * Set the value of an uniform to an array of float32 (stored as matrices)
  94699. * @param uniform defines the webGL uniform location where to store the value
  94700. * @param matrices defines the array of float32 to store
  94701. */
  94702. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  94703. /**
  94704. * Set the value of an uniform to a matrix (3x3)
  94705. * @param uniform defines the webGL uniform location where to store the value
  94706. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  94707. */
  94708. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94709. /**
  94710. * Set the value of an uniform to a matrix (2x2)
  94711. * @param uniform defines the webGL uniform location where to store the value
  94712. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  94713. */
  94714. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  94715. /**
  94716. * Set the value of an uniform to a number (int)
  94717. * @param uniform defines the webGL uniform location where to store the value
  94718. * @param value defines the int number to store
  94719. */
  94720. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94721. /**
  94722. * Set the value of an uniform to a number (float)
  94723. * @param uniform defines the webGL uniform location where to store the value
  94724. * @param value defines the float number to store
  94725. */
  94726. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  94727. /**
  94728. * Set the value of an uniform to a vec2
  94729. * @param uniform defines the webGL uniform location where to store the value
  94730. * @param x defines the 1st component of the value
  94731. * @param y defines the 2nd component of the value
  94732. */
  94733. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  94734. /**
  94735. * Set the value of an uniform to a vec3
  94736. * @param uniform defines the webGL uniform location where to store the value
  94737. * @param x defines the 1st component of the value
  94738. * @param y defines the 2nd component of the value
  94739. * @param z defines the 3rd component of the value
  94740. */
  94741. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  94742. /**
  94743. * Set the value of an uniform to a boolean
  94744. * @param uniform defines the webGL uniform location where to store the value
  94745. * @param bool defines the boolean to store
  94746. */
  94747. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  94748. /**
  94749. * Set the value of an uniform to a vec4
  94750. * @param uniform defines the webGL uniform location where to store the value
  94751. * @param x defines the 1st component of the value
  94752. * @param y defines the 2nd component of the value
  94753. * @param z defines the 3rd component of the value
  94754. * @param w defines the 4th component of the value
  94755. */
  94756. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  94757. /**
  94758. * Sets a Color4 on a uniform variable
  94759. * @param uniform defines the uniform location
  94760. * @param color4 defines the value to be set
  94761. */
  94762. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  94763. /**
  94764. * Set various states to the webGL context
  94765. * @param culling defines backface culling state
  94766. * @param zOffset defines the value to apply to zOffset (0 by default)
  94767. * @param force defines if states must be applied even if cache is up to date
  94768. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  94769. */
  94770. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  94771. /**
  94772. * Set the z offset to apply to current rendering
  94773. * @param value defines the offset to apply
  94774. */
  94775. setZOffset(value: number): void;
  94776. /**
  94777. * Gets the current value of the zOffset
  94778. * @returns the current zOffset state
  94779. */
  94780. getZOffset(): number;
  94781. /**
  94782. * Enable or disable depth buffering
  94783. * @param enable defines the state to set
  94784. */
  94785. setDepthBuffer(enable: boolean): void;
  94786. /**
  94787. * Gets a boolean indicating if depth writing is enabled
  94788. * @returns the current depth writing state
  94789. */
  94790. getDepthWrite(): boolean;
  94791. /**
  94792. * Enable or disable depth writing
  94793. * @param enable defines the state to set
  94794. */
  94795. setDepthWrite(enable: boolean): void;
  94796. /**
  94797. * Enable or disable color writing
  94798. * @param enable defines the state to set
  94799. */
  94800. setColorWrite(enable: boolean): void;
  94801. /**
  94802. * Gets a boolean indicating if color writing is enabled
  94803. * @returns the current color writing state
  94804. */
  94805. getColorWrite(): boolean;
  94806. /**
  94807. * Sets alpha constants used by some alpha blending modes
  94808. * @param r defines the red component
  94809. * @param g defines the green component
  94810. * @param b defines the blue component
  94811. * @param a defines the alpha component
  94812. */
  94813. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  94814. /**
  94815. * Sets the current alpha mode
  94816. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  94817. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  94818. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94819. */
  94820. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  94821. /**
  94822. * Gets the current alpha mode
  94823. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  94824. * @returns the current alpha mode
  94825. */
  94826. getAlphaMode(): number;
  94827. /**
  94828. * Clears the list of texture accessible through engine.
  94829. * This can help preventing texture load conflict due to name collision.
  94830. */
  94831. clearInternalTexturesCache(): void;
  94832. /**
  94833. * Force the entire cache to be cleared
  94834. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  94835. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  94836. */
  94837. wipeCaches(bruteForce?: boolean): void;
  94838. /**
  94839. * Set the compressed texture format to use, based on the formats you have, and the formats
  94840. * supported by the hardware / browser.
  94841. *
  94842. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  94843. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  94844. * to API arguments needed to compressed textures. This puts the burden on the container
  94845. * generator to house the arcane code for determining these for current & future formats.
  94846. *
  94847. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  94848. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  94849. *
  94850. * Note: The result of this call is not taken into account when a texture is base64.
  94851. *
  94852. * @param formatsAvailable defines the list of those format families you have created
  94853. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  94854. *
  94855. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  94856. * @returns The extension selected.
  94857. */
  94858. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  94859. /** @hidden */
  94860. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  94861. min: number;
  94862. mag: number;
  94863. };
  94864. /** @hidden */
  94865. _createTexture(): WebGLTexture;
  94866. /**
  94867. * Usually called from Texture.ts.
  94868. * Passed information to create a WebGLTexture
  94869. * @param urlArg defines a value which contains one of the following:
  94870. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  94871. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  94872. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  94873. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  94874. * @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)
  94875. * @param scene needed for loading to the correct scene
  94876. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  94877. * @param onLoad optional callback to be called upon successful completion
  94878. * @param onError optional callback to be called upon failure
  94879. * @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
  94880. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  94881. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  94882. * @param forcedExtension defines the extension to use to pick the right loader
  94883. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  94884. * @returns a InternalTexture for assignment back into BABYLON.Texture
  94885. */
  94886. 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;
  94887. /**
  94888. * @hidden
  94889. * Rescales a texture
  94890. * @param source input texutre
  94891. * @param destination destination texture
  94892. * @param scene scene to use to render the resize
  94893. * @param internalFormat format to use when resizing
  94894. * @param onComplete callback to be called when resize has completed
  94895. */
  94896. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  94897. private _unpackFlipYCached;
  94898. /**
  94899. * In case you are sharing the context with other applications, it might
  94900. * be interested to not cache the unpack flip y state to ensure a consistent
  94901. * value would be set.
  94902. */
  94903. enableUnpackFlipYCached: boolean;
  94904. /** @hidden */
  94905. _unpackFlipY(value: boolean): void;
  94906. /** @hidden */
  94907. _getUnpackAlignement(): number;
  94908. /**
  94909. * Creates a dynamic texture
  94910. * @param width defines the width of the texture
  94911. * @param height defines the height of the texture
  94912. * @param generateMipMaps defines if the engine should generate the mip levels
  94913. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  94914. * @returns the dynamic texture inside an InternalTexture
  94915. */
  94916. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  94917. /**
  94918. * Update the sampling mode of a given texture
  94919. * @param samplingMode defines the required sampling mode
  94920. * @param texture defines the texture to update
  94921. */
  94922. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  94923. /**
  94924. * Update the content of a dynamic texture
  94925. * @param texture defines the texture to update
  94926. * @param canvas defines the canvas containing the source
  94927. * @param invertY defines if data must be stored with Y axis inverted
  94928. * @param premulAlpha defines if alpha is stored as premultiplied
  94929. * @param format defines the format of the data
  94930. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  94931. */
  94932. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  94933. /**
  94934. * Update a video texture
  94935. * @param texture defines the texture to update
  94936. * @param video defines the video element to use
  94937. * @param invertY defines if data must be stored with Y axis inverted
  94938. */
  94939. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  94940. /**
  94941. * Updates a depth texture Comparison Mode and Function.
  94942. * If the comparison Function is equal to 0, the mode will be set to none.
  94943. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  94944. * @param texture The texture to set the comparison function for
  94945. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  94946. */
  94947. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  94948. /** @hidden */
  94949. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  94950. width: number;
  94951. height: number;
  94952. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  94953. /**
  94954. * Creates a depth stencil texture.
  94955. * This is only available in WebGL 2 or with the depth texture extension available.
  94956. * @param size The size of face edge in the texture.
  94957. * @param options The options defining the texture.
  94958. * @returns The texture
  94959. */
  94960. createDepthStencilTexture(size: number | {
  94961. width: number;
  94962. height: number;
  94963. }, options: DepthTextureCreationOptions): InternalTexture;
  94964. /**
  94965. * Creates a depth stencil texture.
  94966. * This is only available in WebGL 2 or with the depth texture extension available.
  94967. * @param size The size of face edge in the texture.
  94968. * @param options The options defining the texture.
  94969. * @returns The texture
  94970. */
  94971. private _createDepthStencilTexture;
  94972. /**
  94973. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  94974. * @param renderTarget The render target to set the frame buffer for
  94975. */
  94976. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  94977. /**
  94978. * Creates a new render target texture
  94979. * @param size defines the size of the texture
  94980. * @param options defines the options used to create the texture
  94981. * @returns a new render target texture stored in an InternalTexture
  94982. */
  94983. createRenderTargetTexture(size: number | {
  94984. width: number;
  94985. height: number;
  94986. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  94987. /** @hidden */
  94988. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  94989. /**
  94990. * Updates the sample count of a render target texture
  94991. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  94992. * @param texture defines the texture to update
  94993. * @param samples defines the sample count to set
  94994. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  94995. */
  94996. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  94997. /** @hidden */
  94998. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  94999. /** @hidden */
  95000. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  95001. /** @hidden */
  95002. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  95003. /** @hidden */
  95004. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  95005. /**
  95006. * @hidden
  95007. */
  95008. _setCubeMapTextureParams(loadMipmap: boolean): void;
  95009. private _prepareWebGLTextureContinuation;
  95010. private _prepareWebGLTexture;
  95011. /** @hidden */
  95012. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  95013. /** @hidden */
  95014. _releaseFramebufferObjects(texture: InternalTexture): void;
  95015. /** @hidden */
  95016. _releaseTexture(texture: InternalTexture): void;
  95017. private setProgram;
  95018. private _boundUniforms;
  95019. /**
  95020. * Binds an effect to the webGL context
  95021. * @param effect defines the effect to bind
  95022. */
  95023. bindSamplers(effect: Effect): void;
  95024. private _activateCurrentTexture;
  95025. /** @hidden */
  95026. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  95027. /** @hidden */
  95028. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  95029. /**
  95030. * Sets a texture to the webGL context from a postprocess
  95031. * @param channel defines the channel to use
  95032. * @param postProcess defines the source postprocess
  95033. */
  95034. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  95035. /**
  95036. * Binds the output of the passed in post process to the texture channel specified
  95037. * @param channel The channel the texture should be bound to
  95038. * @param postProcess The post process which's output should be bound
  95039. */
  95040. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  95041. /**
  95042. * Unbind all textures from the webGL context
  95043. */
  95044. unbindAllTextures(): void;
  95045. /**
  95046. * Sets a texture to the according uniform.
  95047. * @param channel The texture channel
  95048. * @param uniform The uniform to set
  95049. * @param texture The texture to apply
  95050. */
  95051. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  95052. /**
  95053. * Sets a depth stencil texture from a render target to the according uniform.
  95054. * @param channel The texture channel
  95055. * @param uniform The uniform to set
  95056. * @param texture The render target texture containing the depth stencil texture to apply
  95057. */
  95058. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  95059. private _bindSamplerUniformToChannel;
  95060. private _getTextureWrapMode;
  95061. private _setTexture;
  95062. /**
  95063. * Sets an array of texture to the webGL context
  95064. * @param channel defines the channel where the texture array must be set
  95065. * @param uniform defines the associated uniform location
  95066. * @param textures defines the array of textures to bind
  95067. */
  95068. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  95069. /** @hidden */
  95070. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  95071. private _setTextureParameterFloat;
  95072. private _setTextureParameterInteger;
  95073. /**
  95074. * Reads pixels from the current frame buffer. Please note that this function can be slow
  95075. * @param x defines the x coordinate of the rectangle where pixels must be read
  95076. * @param y defines the y coordinate of the rectangle where pixels must be read
  95077. * @param width defines the width of the rectangle where pixels must be read
  95078. * @param height defines the height of the rectangle where pixels must be read
  95079. * @returns a Uint8Array containing RGBA colors
  95080. */
  95081. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  95082. /**
  95083. * Add an externaly attached data from its key.
  95084. * This method call will fail and return false, if such key already exists.
  95085. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95086. * @param key the unique key that identifies the data
  95087. * @param data the data object to associate to the key for this Engine instance
  95088. * @return true if no such key were already present and the data was added successfully, false otherwise
  95089. */
  95090. addExternalData<T>(key: string, data: T): boolean;
  95091. /**
  95092. * Get an externaly attached data from its key
  95093. * @param key the unique key that identifies the data
  95094. * @return the associated data, if present (can be null), or undefined if not present
  95095. */
  95096. getExternalData<T>(key: string): T;
  95097. /**
  95098. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95099. * @param key the unique key that identifies the data
  95100. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95101. * @return the associated data, can be null if the factory returned null.
  95102. */
  95103. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95104. /**
  95105. * Remove an externaly attached data from the Engine instance
  95106. * @param key the unique key that identifies the data
  95107. * @return true if the data was successfully removed, false if it doesn't exist
  95108. */
  95109. removeExternalData(key: string): boolean;
  95110. /**
  95111. * Unbind all vertex attributes from the webGL context
  95112. */
  95113. unbindAllAttributes(): void;
  95114. /**
  95115. * 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
  95116. */
  95117. releaseEffects(): void;
  95118. /**
  95119. * Dispose and release all associated resources
  95120. */
  95121. dispose(): void;
  95122. /**
  95123. * Display the loading screen
  95124. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95125. */
  95126. displayLoadingUI(): void;
  95127. /**
  95128. * Hide the loading screen
  95129. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95130. */
  95131. hideLoadingUI(): void;
  95132. /**
  95133. * Gets the current loading screen object
  95134. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95135. */
  95136. /**
  95137. * Sets the current loading screen object
  95138. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95139. */
  95140. loadingScreen: ILoadingScreen;
  95141. /**
  95142. * Sets the current loading screen text
  95143. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95144. */
  95145. loadingUIText: string;
  95146. /**
  95147. * Sets the current loading screen background color
  95148. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  95149. */
  95150. loadingUIBackgroundColor: string;
  95151. /**
  95152. * Attach a new callback raised when context lost event is fired
  95153. * @param callback defines the callback to call
  95154. */
  95155. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95156. /**
  95157. * Attach a new callback raised when context restored event is fired
  95158. * @param callback defines the callback to call
  95159. */
  95160. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  95161. /**
  95162. * Gets the source code of the vertex shader associated with a specific webGL program
  95163. * @param program defines the program to use
  95164. * @returns a string containing the source code of the vertex shader associated with the program
  95165. */
  95166. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  95167. /**
  95168. * Gets the source code of the fragment shader associated with a specific webGL program
  95169. * @param program defines the program to use
  95170. * @returns a string containing the source code of the fragment shader associated with the program
  95171. */
  95172. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  95173. /**
  95174. * Get the current error code of the webGL context
  95175. * @returns the error code
  95176. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  95177. */
  95178. getError(): number;
  95179. /**
  95180. * Gets the current framerate
  95181. * @returns a number representing the framerate
  95182. */
  95183. getFps(): number;
  95184. /**
  95185. * Gets the time spent between current and previous frame
  95186. * @returns a number representing the delta time in ms
  95187. */
  95188. getDeltaTime(): number;
  95189. private _measureFps;
  95190. /** @hidden */
  95191. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  95192. private _canRenderToFloatFramebuffer;
  95193. private _canRenderToHalfFloatFramebuffer;
  95194. private _canRenderToFramebuffer;
  95195. /** @hidden */
  95196. _getWebGLTextureType(type: number): number;
  95197. /** @hidden */
  95198. _getInternalFormat(format: number): number;
  95199. /** @hidden */
  95200. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  95201. /** @hidden */
  95202. _getRGBAMultiSampleBufferFormat(type: number): number;
  95203. /** @hidden */
  95204. _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;
  95205. /** @hidden */
  95206. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95207. /**
  95208. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  95209. * @returns true if the engine can be created
  95210. * @ignorenaming
  95211. */
  95212. static isSupported(): boolean;
  95213. /**
  95214. * Find the next highest power of two.
  95215. * @param x Number to start search from.
  95216. * @return Next highest power of two.
  95217. */
  95218. static CeilingPOT(x: number): number;
  95219. /**
  95220. * Find the next lowest power of two.
  95221. * @param x Number to start search from.
  95222. * @return Next lowest power of two.
  95223. */
  95224. static FloorPOT(x: number): number;
  95225. /**
  95226. * Find the nearest power of two.
  95227. * @param x Number to start search from.
  95228. * @return Next nearest power of two.
  95229. */
  95230. static NearestPOT(x: number): number;
  95231. /**
  95232. * Get the closest exponent of two
  95233. * @param value defines the value to approximate
  95234. * @param max defines the maximum value to return
  95235. * @param mode defines how to define the closest value
  95236. * @returns closest exponent of two of the given value
  95237. */
  95238. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  95239. /**
  95240. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  95241. * @param func - the function to be called
  95242. * @param requester - the object that will request the next frame. Falls back to window.
  95243. * @returns frame number
  95244. */
  95245. static QueueNewFrame(func: () => void, requester?: any): number;
  95246. /**
  95247. * Ask the browser to promote the current element to pointerlock mode
  95248. * @param element defines the DOM element to promote
  95249. */
  95250. static _RequestPointerlock(element: HTMLElement): void;
  95251. /**
  95252. * Asks the browser to exit pointerlock mode
  95253. */
  95254. static _ExitPointerlock(): void;
  95255. /**
  95256. * Ask the browser to promote the current element to fullscreen rendering mode
  95257. * @param element defines the DOM element to promote
  95258. */
  95259. static _RequestFullscreen(element: HTMLElement): void;
  95260. /**
  95261. * Asks the browser to exit fullscreen mode
  95262. */
  95263. static _ExitFullscreen(): void;
  95264. }
  95265. }
  95266. declare module BABYLON {
  95267. /**
  95268. * The engine store class is responsible to hold all the instances of Engine and Scene created
  95269. * during the life time of the application.
  95270. */
  95271. export class EngineStore {
  95272. /** Gets the list of created engines */
  95273. static Instances: Engine[];
  95274. /** @hidden */
  95275. static _LastCreatedScene: Nullable<Scene>;
  95276. /**
  95277. * Gets the latest created engine
  95278. */
  95279. static readonly LastCreatedEngine: Nullable<Engine>;
  95280. /**
  95281. * Gets the latest created scene
  95282. */
  95283. static readonly LastCreatedScene: Nullable<Scene>;
  95284. /**
  95285. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95286. * @ignorenaming
  95287. */
  95288. static UseFallbackTexture: boolean;
  95289. /**
  95290. * Texture content used if a texture cannot loaded
  95291. * @ignorenaming
  95292. */
  95293. static FallbackTexture: string;
  95294. }
  95295. }
  95296. declare module BABYLON {
  95297. /**
  95298. * Helper class that provides a small promise polyfill
  95299. */
  95300. export class PromisePolyfill {
  95301. /**
  95302. * Static function used to check if the polyfill is required
  95303. * If this is the case then the function will inject the polyfill to window.Promise
  95304. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  95305. */
  95306. static Apply(force?: boolean): void;
  95307. }
  95308. }
  95309. declare module BABYLON {
  95310. interface IColor4Like {
  95311. r: float;
  95312. g: float;
  95313. b: float;
  95314. a: float;
  95315. }
  95316. /**
  95317. * Class containing a set of static utilities functions
  95318. */
  95319. export class Tools {
  95320. /**
  95321. * Gets or sets the base URL to use to load assets
  95322. */
  95323. static BaseUrl: string;
  95324. /**
  95325. * Enable/Disable Custom HTTP Request Headers globally.
  95326. * default = false
  95327. * @see CustomRequestHeaders
  95328. */
  95329. static UseCustomRequestHeaders: boolean;
  95330. /**
  95331. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  95332. * i.e. when loading files, where the server/service expects an Authorization header
  95333. */
  95334. static CustomRequestHeaders: {
  95335. [key: string]: string;
  95336. };
  95337. /**
  95338. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  95339. */
  95340. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  95341. /**
  95342. * Default behaviour for cors in the application.
  95343. * It can be a string if the expected behavior is identical in the entire app.
  95344. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  95345. */
  95346. static CorsBehavior: string | ((url: string | string[]) => string);
  95347. /**
  95348. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  95349. * @ignorenaming
  95350. */
  95351. static UseFallbackTexture: boolean;
  95352. /**
  95353. * Use this object to register external classes like custom textures or material
  95354. * to allow the laoders to instantiate them
  95355. */
  95356. static RegisteredExternalClasses: {
  95357. [key: string]: Object;
  95358. };
  95359. /**
  95360. * Texture content used if a texture cannot loaded
  95361. * @ignorenaming
  95362. */
  95363. static fallbackTexture: string;
  95364. /**
  95365. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  95366. * @param u defines the coordinate on X axis
  95367. * @param v defines the coordinate on Y axis
  95368. * @param width defines the width of the source data
  95369. * @param height defines the height of the source data
  95370. * @param pixels defines the source byte array
  95371. * @param color defines the output color
  95372. */
  95373. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  95374. /**
  95375. * Interpolates between a and b via alpha
  95376. * @param a The lower value (returned when alpha = 0)
  95377. * @param b The upper value (returned when alpha = 1)
  95378. * @param alpha The interpolation-factor
  95379. * @return The mixed value
  95380. */
  95381. static Mix(a: number, b: number, alpha: number): number;
  95382. /**
  95383. * Tries to instantiate a new object from a given class name
  95384. * @param className defines the class name to instantiate
  95385. * @returns the new object or null if the system was not able to do the instantiation
  95386. */
  95387. static Instantiate(className: string): any;
  95388. /**
  95389. * Provides a slice function that will work even on IE
  95390. * @param data defines the array to slice
  95391. * @param start defines the start of the data (optional)
  95392. * @param end defines the end of the data (optional)
  95393. * @returns the new sliced array
  95394. */
  95395. static Slice<T>(data: T, start?: number, end?: number): T;
  95396. /**
  95397. * Polyfill for setImmediate
  95398. * @param action defines the action to execute after the current execution block
  95399. */
  95400. static SetImmediate(action: () => void): void;
  95401. /**
  95402. * Function indicating if a number is an exponent of 2
  95403. * @param value defines the value to test
  95404. * @returns true if the value is an exponent of 2
  95405. */
  95406. static IsExponentOfTwo(value: number): boolean;
  95407. private static _tmpFloatArray;
  95408. /**
  95409. * Returns the nearest 32-bit single precision float representation of a Number
  95410. * @param value A Number. If the parameter is of a different type, it will get converted
  95411. * to a number or to NaN if it cannot be converted
  95412. * @returns number
  95413. */
  95414. static FloatRound(value: number): number;
  95415. /**
  95416. * Extracts the filename from a path
  95417. * @param path defines the path to use
  95418. * @returns the filename
  95419. */
  95420. static GetFilename(path: string): string;
  95421. /**
  95422. * Extracts the "folder" part of a path (everything before the filename).
  95423. * @param uri The URI to extract the info from
  95424. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  95425. * @returns The "folder" part of the path
  95426. */
  95427. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  95428. /**
  95429. * Extracts text content from a DOM element hierarchy
  95430. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  95431. */
  95432. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  95433. /**
  95434. * Convert an angle in radians to degrees
  95435. * @param angle defines the angle to convert
  95436. * @returns the angle in degrees
  95437. */
  95438. static ToDegrees(angle: number): number;
  95439. /**
  95440. * Convert an angle in degrees to radians
  95441. * @param angle defines the angle to convert
  95442. * @returns the angle in radians
  95443. */
  95444. static ToRadians(angle: number): number;
  95445. /**
  95446. * Encode a buffer to a base64 string
  95447. * @param buffer defines the buffer to encode
  95448. * @returns the encoded string
  95449. */
  95450. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  95451. /**
  95452. * Returns an array if obj is not an array
  95453. * @param obj defines the object to evaluate as an array
  95454. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  95455. * @returns either obj directly if obj is an array or a new array containing obj
  95456. */
  95457. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  95458. /**
  95459. * Gets the pointer prefix to use
  95460. * @returns "pointer" if touch is enabled. Else returns "mouse"
  95461. */
  95462. static GetPointerPrefix(): string;
  95463. /**
  95464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  95465. * @param url define the url we are trying
  95466. * @param element define the dom element where to configure the cors policy
  95467. */
  95468. static SetCorsBehavior(url: string | string[], element: {
  95469. crossOrigin: string | null;
  95470. }): void;
  95471. /**
  95472. * Removes unwanted characters from an url
  95473. * @param url defines the url to clean
  95474. * @returns the cleaned url
  95475. */
  95476. static CleanUrl(url: string): string;
  95477. /**
  95478. * Gets or sets a function used to pre-process url before using them to load assets
  95479. */
  95480. static PreprocessUrl: (url: string) => string;
  95481. /**
  95482. * Loads an image as an HTMLImageElement.
  95483. * @param input url string, ArrayBuffer, or Blob to load
  95484. * @param onLoad callback called when the image successfully loads
  95485. * @param onError callback called when the image fails to load
  95486. * @param offlineProvider offline provider for caching
  95487. * @returns the HTMLImageElement of the loaded image
  95488. */
  95489. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  95490. /**
  95491. * Loads a file
  95492. * @param url url string, ArrayBuffer, or Blob to load
  95493. * @param onSuccess callback called when the file successfully loads
  95494. * @param onProgress callback called while file is loading (if the server supports this mode)
  95495. * @param offlineProvider defines the offline provider for caching
  95496. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  95497. * @param onError callback called when the file fails to load
  95498. * @returns a file request object
  95499. */
  95500. 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;
  95501. /**
  95502. * Loads a file from a url
  95503. * @param url the file url to load
  95504. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  95505. */
  95506. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  95507. /**
  95508. * Load a script (identified by an url). When the url returns, the
  95509. * content of this file is added into a new script element, attached to the DOM (body element)
  95510. * @param scriptUrl defines the url of the script to laod
  95511. * @param onSuccess defines the callback called when the script is loaded
  95512. * @param onError defines the callback to call if an error occurs
  95513. * @param scriptId defines the id of the script element
  95514. */
  95515. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  95516. /**
  95517. * Load an asynchronous script (identified by an url). When the url returns, the
  95518. * content of this file is added into a new script element, attached to the DOM (body element)
  95519. * @param scriptUrl defines the url of the script to laod
  95520. * @param scriptId defines the id of the script element
  95521. * @returns a promise request object
  95522. */
  95523. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  95524. /**
  95525. * Loads a file from a blob
  95526. * @param fileToLoad defines the blob to use
  95527. * @param callback defines the callback to call when data is loaded
  95528. * @param progressCallback defines the callback to call during loading process
  95529. * @returns a file request object
  95530. */
  95531. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  95532. /**
  95533. * Loads a file
  95534. * @param fileToLoad defines the file to load
  95535. * @param callback defines the callback to call when data is loaded
  95536. * @param progressCallBack defines the callback to call during loading process
  95537. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  95538. * @returns a file request object
  95539. */
  95540. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  95541. /**
  95542. * Creates a data url from a given string content
  95543. * @param content defines the content to convert
  95544. * @returns the new data url link
  95545. */
  95546. static FileAsURL(content: string): string;
  95547. /**
  95548. * Format the given number to a specific decimal format
  95549. * @param value defines the number to format
  95550. * @param decimals defines the number of decimals to use
  95551. * @returns the formatted string
  95552. */
  95553. static Format(value: number, decimals?: number): string;
  95554. /**
  95555. * Tries to copy an object by duplicating every property
  95556. * @param source defines the source object
  95557. * @param destination defines the target object
  95558. * @param doNotCopyList defines a list of properties to avoid
  95559. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  95560. */
  95561. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  95562. /**
  95563. * Gets a boolean indicating if the given object has no own property
  95564. * @param obj defines the object to test
  95565. * @returns true if object has no own property
  95566. */
  95567. static IsEmpty(obj: any): boolean;
  95568. /**
  95569. * Function used to register events at window level
  95570. * @param events defines the events to register
  95571. */
  95572. static RegisterTopRootEvents(events: {
  95573. name: string;
  95574. handler: Nullable<(e: FocusEvent) => any>;
  95575. }[]): void;
  95576. /**
  95577. * Function used to unregister events from window level
  95578. * @param events defines the events to unregister
  95579. */
  95580. static UnregisterTopRootEvents(events: {
  95581. name: string;
  95582. handler: Nullable<(e: FocusEvent) => any>;
  95583. }[]): void;
  95584. /**
  95585. * @ignore
  95586. */
  95587. static _ScreenshotCanvas: HTMLCanvasElement;
  95588. /**
  95589. * Dumps the current bound framebuffer
  95590. * @param width defines the rendering width
  95591. * @param height defines the rendering height
  95592. * @param engine defines the hosting engine
  95593. * @param successCallback defines the callback triggered once the data are available
  95594. * @param mimeType defines the mime type of the result
  95595. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  95596. */
  95597. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95598. /**
  95599. * Converts the canvas data to blob.
  95600. * This acts as a polyfill for browsers not supporting the to blob function.
  95601. * @param canvas Defines the canvas to extract the data from
  95602. * @param successCallback Defines the callback triggered once the data are available
  95603. * @param mimeType Defines the mime type of the result
  95604. */
  95605. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  95606. /**
  95607. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  95608. * @param successCallback defines the callback triggered once the data are available
  95609. * @param mimeType defines the mime type of the result
  95610. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  95611. */
  95612. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  95613. /**
  95614. * Downloads a blob in the browser
  95615. * @param blob defines the blob to download
  95616. * @param fileName defines the name of the downloaded file
  95617. */
  95618. static Download(blob: Blob, fileName: string): void;
  95619. /**
  95620. * Captures a screenshot of the current rendering
  95621. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95622. * @param engine defines the rendering engine
  95623. * @param camera defines the source camera
  95624. * @param size This parameter can be set to a single number or to an object with the
  95625. * following (optional) properties: precision, width, height. If a single number is passed,
  95626. * it will be used for both width and height. If an object is passed, the screenshot size
  95627. * will be derived from the parameters. The precision property is a multiplier allowing
  95628. * rendering at a higher or lower resolution
  95629. * @param successCallback defines the callback receives a single parameter which contains the
  95630. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95631. * src parameter of an <img> to display it
  95632. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95633. * Check your browser for supported MIME types
  95634. */
  95635. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  95636. /**
  95637. * Captures a screenshot of the current rendering
  95638. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95639. * @param engine defines the rendering engine
  95640. * @param camera defines the source camera
  95641. * @param size This parameter can be set to a single number or to an object with the
  95642. * following (optional) properties: precision, width, height. If a single number is passed,
  95643. * it will be used for both width and height. If an object is passed, the screenshot size
  95644. * will be derived from the parameters. The precision property is a multiplier allowing
  95645. * rendering at a higher or lower resolution
  95646. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  95647. * Check your browser for supported MIME types
  95648. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95649. * to the src parameter of an <img> to display it
  95650. */
  95651. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  95652. /**
  95653. * Generates an image screenshot from the specified camera.
  95654. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95655. * @param engine The engine to use for rendering
  95656. * @param camera The camera to use for rendering
  95657. * @param size This parameter can be set to a single number or to an object with the
  95658. * following (optional) properties: precision, width, height. If a single number is passed,
  95659. * it will be used for both width and height. If an object is passed, the screenshot size
  95660. * will be derived from the parameters. The precision property is a multiplier allowing
  95661. * rendering at a higher or lower resolution
  95662. * @param successCallback The callback receives a single parameter which contains the
  95663. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  95664. * src parameter of an <img> to display it
  95665. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95666. * Check your browser for supported MIME types
  95667. * @param samples Texture samples (default: 1)
  95668. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95669. * @param fileName A name for for the downloaded file.
  95670. */
  95671. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  95672. /**
  95673. * Generates an image screenshot from the specified camera.
  95674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  95675. * @param engine The engine to use for rendering
  95676. * @param camera The camera to use for rendering
  95677. * @param size This parameter can be set to a single number or to an object with the
  95678. * following (optional) properties: precision, width, height. If a single number is passed,
  95679. * it will be used for both width and height. If an object is passed, the screenshot size
  95680. * will be derived from the parameters. The precision property is a multiplier allowing
  95681. * rendering at a higher or lower resolution
  95682. * @param mimeType The MIME type of the screenshot image (default: image/png).
  95683. * Check your browser for supported MIME types
  95684. * @param samples Texture samples (default: 1)
  95685. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  95686. * @param fileName A name for for the downloaded file.
  95687. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  95688. * to the src parameter of an <img> to display it
  95689. */
  95690. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  95691. /**
  95692. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95693. * Be aware Math.random() could cause collisions, but:
  95694. * "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"
  95695. * @returns a pseudo random id
  95696. */
  95697. static RandomId(): string;
  95698. /**
  95699. * Test if the given uri is a base64 string
  95700. * @param uri The uri to test
  95701. * @return True if the uri is a base64 string or false otherwise
  95702. */
  95703. static IsBase64(uri: string): boolean;
  95704. /**
  95705. * Decode the given base64 uri.
  95706. * @param uri The uri to decode
  95707. * @return The decoded base64 data.
  95708. */
  95709. static DecodeBase64(uri: string): ArrayBuffer;
  95710. /**
  95711. * Gets the absolute url.
  95712. * @param url the input url
  95713. * @return the absolute url
  95714. */
  95715. static GetAbsoluteUrl(url: string): string;
  95716. /**
  95717. * No log
  95718. */
  95719. static readonly NoneLogLevel: number;
  95720. /**
  95721. * Only message logs
  95722. */
  95723. static readonly MessageLogLevel: number;
  95724. /**
  95725. * Only warning logs
  95726. */
  95727. static readonly WarningLogLevel: number;
  95728. /**
  95729. * Only error logs
  95730. */
  95731. static readonly ErrorLogLevel: number;
  95732. /**
  95733. * All logs
  95734. */
  95735. static readonly AllLogLevel: number;
  95736. /**
  95737. * Gets a value indicating the number of loading errors
  95738. * @ignorenaming
  95739. */
  95740. static readonly errorsCount: number;
  95741. /**
  95742. * Callback called when a new log is added
  95743. */
  95744. static OnNewCacheEntry: (entry: string) => void;
  95745. /**
  95746. * Log a message to the console
  95747. * @param message defines the message to log
  95748. */
  95749. static Log(message: string): void;
  95750. /**
  95751. * Write a warning message to the console
  95752. * @param message defines the message to log
  95753. */
  95754. static Warn(message: string): void;
  95755. /**
  95756. * Write an error message to the console
  95757. * @param message defines the message to log
  95758. */
  95759. static Error(message: string): void;
  95760. /**
  95761. * Gets current log cache (list of logs)
  95762. */
  95763. static readonly LogCache: string;
  95764. /**
  95765. * Clears the log cache
  95766. */
  95767. static ClearLogCache(): void;
  95768. /**
  95769. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95770. */
  95771. static LogLevels: number;
  95772. /**
  95773. * Checks if the window object exists
  95774. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  95775. */
  95776. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  95777. /**
  95778. * No performance log
  95779. */
  95780. static readonly PerformanceNoneLogLevel: number;
  95781. /**
  95782. * Use user marks to log performance
  95783. */
  95784. static readonly PerformanceUserMarkLogLevel: number;
  95785. /**
  95786. * Log performance to the console
  95787. */
  95788. static readonly PerformanceConsoleLogLevel: number;
  95789. private static _performance;
  95790. /**
  95791. * Sets the current performance log level
  95792. */
  95793. static PerformanceLogLevel: number;
  95794. private static _StartPerformanceCounterDisabled;
  95795. private static _EndPerformanceCounterDisabled;
  95796. private static _StartUserMark;
  95797. private static _EndUserMark;
  95798. private static _StartPerformanceConsole;
  95799. private static _EndPerformanceConsole;
  95800. /**
  95801. * Starts a performance counter
  95802. */
  95803. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95804. /**
  95805. * Ends a specific performance coutner
  95806. */
  95807. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  95808. /**
  95809. * Gets either window.performance.now() if supported or Date.now() else
  95810. */
  95811. static readonly Now: number;
  95812. /**
  95813. * This method will return the name of the class used to create the instance of the given object.
  95814. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  95815. * @param object the object to get the class name from
  95816. * @param isType defines if the object is actually a type
  95817. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  95818. */
  95819. static GetClassName(object: any, isType?: boolean): string;
  95820. /**
  95821. * Gets the first element of an array satisfying a given predicate
  95822. * @param array defines the array to browse
  95823. * @param predicate defines the predicate to use
  95824. * @returns null if not found or the element
  95825. */
  95826. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  95827. /**
  95828. * This method will return the name of the full name of the class, including its owning module (if any).
  95829. * 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).
  95830. * @param object the object to get the class name from
  95831. * @param isType defines if the object is actually a type
  95832. * @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.
  95833. * @ignorenaming
  95834. */
  95835. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  95836. /**
  95837. * Returns a promise that resolves after the given amount of time.
  95838. * @param delay Number of milliseconds to delay
  95839. * @returns Promise that resolves after the given amount of time
  95840. */
  95841. static DelayAsync(delay: number): Promise<void>;
  95842. }
  95843. /**
  95844. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  95845. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  95846. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  95847. * @param name The name of the class, case should be preserved
  95848. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  95849. */
  95850. export function className(name: string, module?: string): (target: Object) => void;
  95851. /**
  95852. * An implementation of a loop for asynchronous functions.
  95853. */
  95854. export class AsyncLoop {
  95855. /**
  95856. * Defines the number of iterations for the loop
  95857. */
  95858. iterations: number;
  95859. /**
  95860. * Defines the current index of the loop.
  95861. */
  95862. index: number;
  95863. private _done;
  95864. private _fn;
  95865. private _successCallback;
  95866. /**
  95867. * Constructor.
  95868. * @param iterations the number of iterations.
  95869. * @param func the function to run each iteration
  95870. * @param successCallback the callback that will be called upon succesful execution
  95871. * @param offset starting offset.
  95872. */
  95873. constructor(
  95874. /**
  95875. * Defines the number of iterations for the loop
  95876. */
  95877. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  95878. /**
  95879. * Execute the next iteration. Must be called after the last iteration was finished.
  95880. */
  95881. executeNext(): void;
  95882. /**
  95883. * Break the loop and run the success callback.
  95884. */
  95885. breakLoop(): void;
  95886. /**
  95887. * Create and run an async loop.
  95888. * @param iterations the number of iterations.
  95889. * @param fn the function to run each iteration
  95890. * @param successCallback the callback that will be called upon succesful execution
  95891. * @param offset starting offset.
  95892. * @returns the created async loop object
  95893. */
  95894. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  95895. /**
  95896. * A for-loop that will run a given number of iterations synchronous and the rest async.
  95897. * @param iterations total number of iterations
  95898. * @param syncedIterations number of synchronous iterations in each async iteration.
  95899. * @param fn the function to call each iteration.
  95900. * @param callback a success call back that will be called when iterating stops.
  95901. * @param breakFunction a break condition (optional)
  95902. * @param timeout timeout settings for the setTimeout function. default - 0.
  95903. * @returns the created async loop object
  95904. */
  95905. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  95906. }
  95907. }
  95908. declare module BABYLON {
  95909. /** @hidden */
  95910. export interface ICollisionCoordinator {
  95911. createCollider(): Collider;
  95912. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95913. init(scene: Scene): void;
  95914. }
  95915. /** @hidden */
  95916. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  95917. private _scene;
  95918. private _scaledPosition;
  95919. private _scaledVelocity;
  95920. private _finalPosition;
  95921. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  95922. createCollider(): Collider;
  95923. init(scene: Scene): void;
  95924. private _collideWithWorld;
  95925. }
  95926. }
  95927. declare module BABYLON {
  95928. /**
  95929. * Class used to manage all inputs for the scene.
  95930. */
  95931. export class InputManager {
  95932. /** The distance in pixel that you have to move to prevent some events */
  95933. static DragMovementThreshold: number;
  95934. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  95935. static LongPressDelay: number;
  95936. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  95937. static DoubleClickDelay: number;
  95938. /** If you need to check double click without raising a single click at first click, enable this flag */
  95939. static ExclusiveDoubleClickMode: boolean;
  95940. private _wheelEventName;
  95941. private _onPointerMove;
  95942. private _onPointerDown;
  95943. private _onPointerUp;
  95944. private _initClickEvent;
  95945. private _initActionManager;
  95946. private _delayedSimpleClick;
  95947. private _delayedSimpleClickTimeout;
  95948. private _previousDelayedSimpleClickTimeout;
  95949. private _meshPickProceed;
  95950. private _previousButtonPressed;
  95951. private _currentPickResult;
  95952. private _previousPickResult;
  95953. private _totalPointersPressed;
  95954. private _doubleClickOccured;
  95955. private _pointerOverMesh;
  95956. private _pickedDownMesh;
  95957. private _pickedUpMesh;
  95958. private _pointerX;
  95959. private _pointerY;
  95960. private _unTranslatedPointerX;
  95961. private _unTranslatedPointerY;
  95962. private _startingPointerPosition;
  95963. private _previousStartingPointerPosition;
  95964. private _startingPointerTime;
  95965. private _previousStartingPointerTime;
  95966. private _pointerCaptures;
  95967. private _onKeyDown;
  95968. private _onKeyUp;
  95969. private _onCanvasFocusObserver;
  95970. private _onCanvasBlurObserver;
  95971. private _scene;
  95972. /**
  95973. * Creates a new InputManager
  95974. * @param scene defines the hosting scene
  95975. */
  95976. constructor(scene: Scene);
  95977. /**
  95978. * Gets the mesh that is currently under the pointer
  95979. */
  95980. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95981. /**
  95982. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  95983. */
  95984. readonly unTranslatedPointer: Vector2;
  95985. /**
  95986. * Gets or sets the current on-screen X position of the pointer
  95987. */
  95988. pointerX: number;
  95989. /**
  95990. * Gets or sets the current on-screen Y position of the pointer
  95991. */
  95992. pointerY: number;
  95993. private _updatePointerPosition;
  95994. private _processPointerMove;
  95995. private _setRayOnPointerInfo;
  95996. private _checkPrePointerObservable;
  95997. /**
  95998. * Use this method to simulate a pointer move on a mesh
  95999. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96000. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96001. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96002. */
  96003. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96004. /**
  96005. * Use this method to simulate a pointer down on a mesh
  96006. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96007. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96008. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96009. */
  96010. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  96011. private _processPointerDown;
  96012. /** @hidden */
  96013. _isPointerSwiping(): boolean;
  96014. /**
  96015. * Use this method to simulate a pointer up on a mesh
  96016. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  96017. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  96018. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  96019. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  96020. */
  96021. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  96022. private _processPointerUp;
  96023. /**
  96024. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  96025. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  96026. * @returns true if the pointer was captured
  96027. */
  96028. isPointerCaptured(pointerId?: number): boolean;
  96029. /**
  96030. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  96031. * @param attachUp defines if you want to attach events to pointerup
  96032. * @param attachDown defines if you want to attach events to pointerdown
  96033. * @param attachMove defines if you want to attach events to pointermove
  96034. */
  96035. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  96036. /**
  96037. * Detaches all event handlers
  96038. */
  96039. detachControl(): void;
  96040. /**
  96041. * Force the value of meshUnderPointer
  96042. * @param mesh defines the mesh to use
  96043. */
  96044. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96045. /**
  96046. * Gets the mesh under the pointer
  96047. * @returns a Mesh or null if no mesh is under the pointer
  96048. */
  96049. getPointerOverMesh(): Nullable<AbstractMesh>;
  96050. }
  96051. }
  96052. declare module BABYLON {
  96053. /**
  96054. * Helper class used to generate session unique ID
  96055. */
  96056. export class UniqueIdGenerator {
  96057. private static _UniqueIdCounter;
  96058. /**
  96059. * Gets an unique (relatively to the current scene) Id
  96060. */
  96061. static readonly UniqueId: number;
  96062. }
  96063. }
  96064. declare module BABYLON {
  96065. /**
  96066. * This class defines the direct association between an animation and a target
  96067. */
  96068. export class TargetedAnimation {
  96069. /**
  96070. * Animation to perform
  96071. */
  96072. animation: Animation;
  96073. /**
  96074. * Target to animate
  96075. */
  96076. target: any;
  96077. /**
  96078. * Serialize the object
  96079. * @returns the JSON object representing the current entity
  96080. */
  96081. serialize(): any;
  96082. }
  96083. /**
  96084. * Use this class to create coordinated animations on multiple targets
  96085. */
  96086. export class AnimationGroup implements IDisposable {
  96087. /** The name of the animation group */
  96088. name: string;
  96089. private _scene;
  96090. private _targetedAnimations;
  96091. private _animatables;
  96092. private _from;
  96093. private _to;
  96094. private _isStarted;
  96095. private _isPaused;
  96096. private _speedRatio;
  96097. private _loopAnimation;
  96098. /**
  96099. * Gets or sets the unique id of the node
  96100. */
  96101. uniqueId: number;
  96102. /**
  96103. * This observable will notify when one animation have ended
  96104. */
  96105. onAnimationEndObservable: Observable<TargetedAnimation>;
  96106. /**
  96107. * Observer raised when one animation loops
  96108. */
  96109. onAnimationLoopObservable: Observable<TargetedAnimation>;
  96110. /**
  96111. * This observable will notify when all animations have ended.
  96112. */
  96113. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  96114. /**
  96115. * This observable will notify when all animations have paused.
  96116. */
  96117. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  96118. /**
  96119. * This observable will notify when all animations are playing.
  96120. */
  96121. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  96122. /**
  96123. * Gets the first frame
  96124. */
  96125. readonly from: number;
  96126. /**
  96127. * Gets the last frame
  96128. */
  96129. readonly to: number;
  96130. /**
  96131. * Define if the animations are started
  96132. */
  96133. readonly isStarted: boolean;
  96134. /**
  96135. * Gets a value indicating that the current group is playing
  96136. */
  96137. readonly isPlaying: boolean;
  96138. /**
  96139. * Gets or sets the speed ratio to use for all animations
  96140. */
  96141. /**
  96142. * Gets or sets the speed ratio to use for all animations
  96143. */
  96144. speedRatio: number;
  96145. /**
  96146. * Gets or sets if all animations should loop or not
  96147. */
  96148. loopAnimation: boolean;
  96149. /**
  96150. * Gets the targeted animations for this animation group
  96151. */
  96152. readonly targetedAnimations: Array<TargetedAnimation>;
  96153. /**
  96154. * returning the list of animatables controlled by this animation group.
  96155. */
  96156. readonly animatables: Array<Animatable>;
  96157. /**
  96158. * Instantiates a new Animation Group.
  96159. * This helps managing several animations at once.
  96160. * @see http://doc.babylonjs.com/how_to/group
  96161. * @param name Defines the name of the group
  96162. * @param scene Defines the scene the group belongs to
  96163. */
  96164. constructor(
  96165. /** The name of the animation group */
  96166. name: string, scene?: Nullable<Scene>);
  96167. /**
  96168. * Add an animation (with its target) in the group
  96169. * @param animation defines the animation we want to add
  96170. * @param target defines the target of the animation
  96171. * @returns the TargetedAnimation object
  96172. */
  96173. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  96174. /**
  96175. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  96176. * It can add constant keys at begin or end
  96177. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  96178. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  96179. * @returns the animation group
  96180. */
  96181. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  96182. /**
  96183. * Start all animations on given targets
  96184. * @param loop defines if animations must loop
  96185. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  96186. * @param from defines the from key (optional)
  96187. * @param to defines the to key (optional)
  96188. * @returns the current animation group
  96189. */
  96190. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  96191. /**
  96192. * Pause all animations
  96193. * @returns the animation group
  96194. */
  96195. pause(): AnimationGroup;
  96196. /**
  96197. * Play all animations to initial state
  96198. * This function will start() the animations if they were not started or will restart() them if they were paused
  96199. * @param loop defines if animations must loop
  96200. * @returns the animation group
  96201. */
  96202. play(loop?: boolean): AnimationGroup;
  96203. /**
  96204. * Reset all animations to initial state
  96205. * @returns the animation group
  96206. */
  96207. reset(): AnimationGroup;
  96208. /**
  96209. * Restart animations from key 0
  96210. * @returns the animation group
  96211. */
  96212. restart(): AnimationGroup;
  96213. /**
  96214. * Stop all animations
  96215. * @returns the animation group
  96216. */
  96217. stop(): AnimationGroup;
  96218. /**
  96219. * Set animation weight for all animatables
  96220. * @param weight defines the weight to use
  96221. * @return the animationGroup
  96222. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96223. */
  96224. setWeightForAllAnimatables(weight: number): AnimationGroup;
  96225. /**
  96226. * Synchronize and normalize all animatables with a source animatable
  96227. * @param root defines the root animatable to synchronize with
  96228. * @return the animationGroup
  96229. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  96230. */
  96231. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  96232. /**
  96233. * Goes to a specific frame in this animation group
  96234. * @param frame the frame number to go to
  96235. * @return the animationGroup
  96236. */
  96237. goToFrame(frame: number): AnimationGroup;
  96238. /**
  96239. * Dispose all associated resources
  96240. */
  96241. dispose(): void;
  96242. private _checkAnimationGroupEnded;
  96243. /**
  96244. * Clone the current animation group and returns a copy
  96245. * @param newName defines the name of the new group
  96246. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  96247. * @returns the new aniamtion group
  96248. */
  96249. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  96250. /**
  96251. * Serializes the animationGroup to an object
  96252. * @returns Serialized object
  96253. */
  96254. serialize(): any;
  96255. /**
  96256. * Returns a new AnimationGroup object parsed from the source provided.
  96257. * @param parsedAnimationGroup defines the source
  96258. * @param scene defines the scene that will receive the animationGroup
  96259. * @returns a new AnimationGroup
  96260. */
  96261. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  96262. /**
  96263. * Returns the string "AnimationGroup"
  96264. * @returns "AnimationGroup"
  96265. */
  96266. getClassName(): string;
  96267. /**
  96268. * Creates a detailled string about the object
  96269. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  96270. * @returns a string representing the object
  96271. */
  96272. toString(fullDetails?: boolean): string;
  96273. }
  96274. }
  96275. declare module BABYLON {
  96276. /**
  96277. * Define an interface for all classes that will hold resources
  96278. */
  96279. export interface IDisposable {
  96280. /**
  96281. * Releases all held resources
  96282. */
  96283. dispose(): void;
  96284. }
  96285. /** Interface defining initialization parameters for Scene class */
  96286. export interface SceneOptions {
  96287. /**
  96288. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  96289. * It will improve performance when the number of geometries becomes important.
  96290. */
  96291. useGeometryUniqueIdsMap?: boolean;
  96292. /**
  96293. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  96294. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96295. */
  96296. useMaterialMeshMap?: boolean;
  96297. /**
  96298. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  96299. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  96300. */
  96301. useClonedMeshhMap?: boolean;
  96302. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  96303. virtual?: boolean;
  96304. }
  96305. /**
  96306. * Represents a scene to be rendered by the engine.
  96307. * @see http://doc.babylonjs.com/features/scene
  96308. */
  96309. export class Scene extends AbstractScene implements IAnimatable {
  96310. /** The fog is deactivated */
  96311. static readonly FOGMODE_NONE: number;
  96312. /** The fog density is following an exponential function */
  96313. static readonly FOGMODE_EXP: number;
  96314. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  96315. static readonly FOGMODE_EXP2: number;
  96316. /** The fog density is following a linear function. */
  96317. static readonly FOGMODE_LINEAR: number;
  96318. /**
  96319. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  96320. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96321. */
  96322. static MinDeltaTime: number;
  96323. /**
  96324. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  96325. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96326. */
  96327. static MaxDeltaTime: number;
  96328. /**
  96329. * Factory used to create the default material.
  96330. * @param name The name of the material to create
  96331. * @param scene The scene to create the material for
  96332. * @returns The default material
  96333. */
  96334. static DefaultMaterialFactory(scene: Scene): Material;
  96335. /**
  96336. * Factory used to create the a collision coordinator.
  96337. * @returns The collision coordinator
  96338. */
  96339. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  96340. /** @hidden */
  96341. _inputManager: InputManager;
  96342. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  96343. cameraToUseForPointers: Nullable<Camera>;
  96344. /** @hidden */
  96345. readonly _isScene: boolean;
  96346. /**
  96347. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  96348. */
  96349. autoClear: boolean;
  96350. /**
  96351. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  96352. */
  96353. autoClearDepthAndStencil: boolean;
  96354. /**
  96355. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  96356. */
  96357. clearColor: Color4;
  96358. /**
  96359. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  96360. */
  96361. ambientColor: Color3;
  96362. /**
  96363. * This is use to store the default BRDF lookup for PBR materials in your scene.
  96364. * It should only be one of the following (if not the default embedded one):
  96365. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  96366. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  96367. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  96368. * The material properties need to be setup according to the type of texture in use.
  96369. */
  96370. environmentBRDFTexture: BaseTexture;
  96371. /** @hidden */
  96372. protected _environmentTexture: Nullable<BaseTexture>;
  96373. /**
  96374. * Texture used in all pbr material as the reflection texture.
  96375. * As in the majority of the scene they are the same (exception for multi room and so on),
  96376. * this is easier to reference from here than from all the materials.
  96377. */
  96378. /**
  96379. * Texture used in all pbr material as the reflection texture.
  96380. * As in the majority of the scene they are the same (exception for multi room and so on),
  96381. * this is easier to set here than in all the materials.
  96382. */
  96383. environmentTexture: Nullable<BaseTexture>;
  96384. /** @hidden */
  96385. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  96386. /**
  96387. * Default image processing configuration used either in the rendering
  96388. * Forward main pass or through the imageProcessingPostProcess if present.
  96389. * As in the majority of the scene they are the same (exception for multi camera),
  96390. * this is easier to reference from here than from all the materials and post process.
  96391. *
  96392. * No setter as we it is a shared configuration, you can set the values instead.
  96393. */
  96394. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  96395. private _forceWireframe;
  96396. /**
  96397. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  96398. */
  96399. forceWireframe: boolean;
  96400. private _forcePointsCloud;
  96401. /**
  96402. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  96403. */
  96404. forcePointsCloud: boolean;
  96405. /**
  96406. * Gets or sets the active clipplane 1
  96407. */
  96408. clipPlane: Nullable<Plane>;
  96409. /**
  96410. * Gets or sets the active clipplane 2
  96411. */
  96412. clipPlane2: Nullable<Plane>;
  96413. /**
  96414. * Gets or sets the active clipplane 3
  96415. */
  96416. clipPlane3: Nullable<Plane>;
  96417. /**
  96418. * Gets or sets the active clipplane 4
  96419. */
  96420. clipPlane4: Nullable<Plane>;
  96421. /**
  96422. * Gets or sets a boolean indicating if animations are enabled
  96423. */
  96424. animationsEnabled: boolean;
  96425. private _animationPropertiesOverride;
  96426. /**
  96427. * Gets or sets the animation properties override
  96428. */
  96429. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  96430. /**
  96431. * Gets or sets a boolean indicating if a constant deltatime has to be used
  96432. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  96433. */
  96434. useConstantAnimationDeltaTime: boolean;
  96435. /**
  96436. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  96437. * Please note that it requires to run a ray cast through the scene on every frame
  96438. */
  96439. constantlyUpdateMeshUnderPointer: boolean;
  96440. /**
  96441. * Defines the HTML cursor to use when hovering over interactive elements
  96442. */
  96443. hoverCursor: string;
  96444. /**
  96445. * Defines the HTML default cursor to use (empty by default)
  96446. */
  96447. defaultCursor: string;
  96448. /**
  96449. * This is used to call preventDefault() on pointer down
  96450. * in order to block unwanted artifacts like system double clicks
  96451. */
  96452. preventDefaultOnPointerDown: boolean;
  96453. /**
  96454. * This is used to call preventDefault() on pointer up
  96455. * in order to block unwanted artifacts like system double clicks
  96456. */
  96457. preventDefaultOnPointerUp: boolean;
  96458. /**
  96459. * Gets or sets user defined metadata
  96460. */
  96461. metadata: any;
  96462. /**
  96463. * For internal use only. Please do not use.
  96464. */
  96465. reservedDataStore: any;
  96466. /**
  96467. * Gets the name of the plugin used to load this scene (null by default)
  96468. */
  96469. loadingPluginName: string;
  96470. /**
  96471. * Use this array to add regular expressions used to disable offline support for specific urls
  96472. */
  96473. disableOfflineSupportExceptionRules: RegExp[];
  96474. /**
  96475. * An event triggered when the scene is disposed.
  96476. */
  96477. onDisposeObservable: Observable<Scene>;
  96478. private _onDisposeObserver;
  96479. /** Sets a function to be executed when this scene is disposed. */
  96480. onDispose: () => void;
  96481. /**
  96482. * An event triggered before rendering the scene (right after animations and physics)
  96483. */
  96484. onBeforeRenderObservable: Observable<Scene>;
  96485. private _onBeforeRenderObserver;
  96486. /** Sets a function to be executed before rendering this scene */
  96487. beforeRender: Nullable<() => void>;
  96488. /**
  96489. * An event triggered after rendering the scene
  96490. */
  96491. onAfterRenderObservable: Observable<Scene>;
  96492. /**
  96493. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  96494. */
  96495. onAfterRenderCameraObservable: Observable<Camera>;
  96496. private _onAfterRenderObserver;
  96497. /** Sets a function to be executed after rendering this scene */
  96498. afterRender: Nullable<() => void>;
  96499. /**
  96500. * An event triggered before animating the scene
  96501. */
  96502. onBeforeAnimationsObservable: Observable<Scene>;
  96503. /**
  96504. * An event triggered after animations processing
  96505. */
  96506. onAfterAnimationsObservable: Observable<Scene>;
  96507. /**
  96508. * An event triggered before draw calls are ready to be sent
  96509. */
  96510. onBeforeDrawPhaseObservable: Observable<Scene>;
  96511. /**
  96512. * An event triggered after draw calls have been sent
  96513. */
  96514. onAfterDrawPhaseObservable: Observable<Scene>;
  96515. /**
  96516. * An event triggered when the scene is ready
  96517. */
  96518. onReadyObservable: Observable<Scene>;
  96519. /**
  96520. * An event triggered before rendering a camera
  96521. */
  96522. onBeforeCameraRenderObservable: Observable<Camera>;
  96523. private _onBeforeCameraRenderObserver;
  96524. /** Sets a function to be executed before rendering a camera*/
  96525. beforeCameraRender: () => void;
  96526. /**
  96527. * An event triggered after rendering a camera
  96528. */
  96529. onAfterCameraRenderObservable: Observable<Camera>;
  96530. private _onAfterCameraRenderObserver;
  96531. /** Sets a function to be executed after rendering a camera*/
  96532. afterCameraRender: () => void;
  96533. /**
  96534. * An event triggered when active meshes evaluation is about to start
  96535. */
  96536. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  96537. /**
  96538. * An event triggered when active meshes evaluation is done
  96539. */
  96540. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  96541. /**
  96542. * An event triggered when particles rendering is about to start
  96543. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96544. */
  96545. onBeforeParticlesRenderingObservable: Observable<Scene>;
  96546. /**
  96547. * An event triggered when particles rendering is done
  96548. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  96549. */
  96550. onAfterParticlesRenderingObservable: Observable<Scene>;
  96551. /**
  96552. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  96553. */
  96554. onDataLoadedObservable: Observable<Scene>;
  96555. /**
  96556. * An event triggered when a camera is created
  96557. */
  96558. onNewCameraAddedObservable: Observable<Camera>;
  96559. /**
  96560. * An event triggered when a camera is removed
  96561. */
  96562. onCameraRemovedObservable: Observable<Camera>;
  96563. /**
  96564. * An event triggered when a light is created
  96565. */
  96566. onNewLightAddedObservable: Observable<Light>;
  96567. /**
  96568. * An event triggered when a light is removed
  96569. */
  96570. onLightRemovedObservable: Observable<Light>;
  96571. /**
  96572. * An event triggered when a geometry is created
  96573. */
  96574. onNewGeometryAddedObservable: Observable<Geometry>;
  96575. /**
  96576. * An event triggered when a geometry is removed
  96577. */
  96578. onGeometryRemovedObservable: Observable<Geometry>;
  96579. /**
  96580. * An event triggered when a transform node is created
  96581. */
  96582. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  96583. /**
  96584. * An event triggered when a transform node is removed
  96585. */
  96586. onTransformNodeRemovedObservable: Observable<TransformNode>;
  96587. /**
  96588. * An event triggered when a mesh is created
  96589. */
  96590. onNewMeshAddedObservable: Observable<AbstractMesh>;
  96591. /**
  96592. * An event triggered when a mesh is removed
  96593. */
  96594. onMeshRemovedObservable: Observable<AbstractMesh>;
  96595. /**
  96596. * An event triggered when a skeleton is created
  96597. */
  96598. onNewSkeletonAddedObservable: Observable<Skeleton>;
  96599. /**
  96600. * An event triggered when a skeleton is removed
  96601. */
  96602. onSkeletonRemovedObservable: Observable<Skeleton>;
  96603. /**
  96604. * An event triggered when a material is created
  96605. */
  96606. onNewMaterialAddedObservable: Observable<Material>;
  96607. /**
  96608. * An event triggered when a material is removed
  96609. */
  96610. onMaterialRemovedObservable: Observable<Material>;
  96611. /**
  96612. * An event triggered when a texture is created
  96613. */
  96614. onNewTextureAddedObservable: Observable<BaseTexture>;
  96615. /**
  96616. * An event triggered when a texture is removed
  96617. */
  96618. onTextureRemovedObservable: Observable<BaseTexture>;
  96619. /**
  96620. * An event triggered when render targets are about to be rendered
  96621. * Can happen multiple times per frame.
  96622. */
  96623. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  96624. /**
  96625. * An event triggered when render targets were rendered.
  96626. * Can happen multiple times per frame.
  96627. */
  96628. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  96629. /**
  96630. * An event triggered before calculating deterministic simulation step
  96631. */
  96632. onBeforeStepObservable: Observable<Scene>;
  96633. /**
  96634. * An event triggered after calculating deterministic simulation step
  96635. */
  96636. onAfterStepObservable: Observable<Scene>;
  96637. /**
  96638. * An event triggered when the activeCamera property is updated
  96639. */
  96640. onActiveCameraChanged: Observable<Scene>;
  96641. /**
  96642. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  96643. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96644. * 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)
  96645. */
  96646. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96647. /**
  96648. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  96649. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  96650. * 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)
  96651. */
  96652. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  96653. /**
  96654. * This Observable will when a mesh has been imported into the scene.
  96655. */
  96656. onMeshImportedObservable: Observable<AbstractMesh>;
  96657. /**
  96658. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  96659. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  96660. */
  96661. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  96662. /** @hidden */
  96663. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  96664. /**
  96665. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  96666. */
  96667. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  96668. /**
  96669. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  96670. */
  96671. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  96672. /**
  96673. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  96674. */
  96675. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  96676. /** Callback called when a pointer move is detected */
  96677. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96678. /** Callback called when a pointer down is detected */
  96679. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  96680. /** Callback called when a pointer up is detected */
  96681. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  96682. /** Callback called when a pointer pick is detected */
  96683. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  96684. /**
  96685. * 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).
  96686. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  96687. */
  96688. onPrePointerObservable: Observable<PointerInfoPre>;
  96689. /**
  96690. * Observable event triggered each time an input event is received from the rendering canvas
  96691. */
  96692. onPointerObservable: Observable<PointerInfo>;
  96693. /**
  96694. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  96695. */
  96696. readonly unTranslatedPointer: Vector2;
  96697. /**
  96698. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  96699. */
  96700. static DragMovementThreshold: number;
  96701. /**
  96702. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  96703. */
  96704. static LongPressDelay: number;
  96705. /**
  96706. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  96707. */
  96708. static DoubleClickDelay: number;
  96709. /** If you need to check double click without raising a single click at first click, enable this flag */
  96710. static ExclusiveDoubleClickMode: boolean;
  96711. /** @hidden */
  96712. _mirroredCameraPosition: Nullable<Vector3>;
  96713. /**
  96714. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  96715. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  96716. */
  96717. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  96718. /**
  96719. * Observable event triggered each time an keyboard event is received from the hosting window
  96720. */
  96721. onKeyboardObservable: Observable<KeyboardInfo>;
  96722. private _useRightHandedSystem;
  96723. /**
  96724. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  96725. */
  96726. useRightHandedSystem: boolean;
  96727. private _timeAccumulator;
  96728. private _currentStepId;
  96729. private _currentInternalStep;
  96730. /**
  96731. * Sets the step Id used by deterministic lock step
  96732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96733. * @param newStepId defines the step Id
  96734. */
  96735. setStepId(newStepId: number): void;
  96736. /**
  96737. * Gets the step Id used by deterministic lock step
  96738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96739. * @returns the step Id
  96740. */
  96741. getStepId(): number;
  96742. /**
  96743. * Gets the internal step used by deterministic lock step
  96744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96745. * @returns the internal step
  96746. */
  96747. getInternalStep(): number;
  96748. private _fogEnabled;
  96749. /**
  96750. * Gets or sets a boolean indicating if fog is enabled on this scene
  96751. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96752. * (Default is true)
  96753. */
  96754. fogEnabled: boolean;
  96755. private _fogMode;
  96756. /**
  96757. * Gets or sets the fog mode to use
  96758. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96759. * | mode | value |
  96760. * | --- | --- |
  96761. * | FOGMODE_NONE | 0 |
  96762. * | FOGMODE_EXP | 1 |
  96763. * | FOGMODE_EXP2 | 2 |
  96764. * | FOGMODE_LINEAR | 3 |
  96765. */
  96766. fogMode: number;
  96767. /**
  96768. * Gets or sets the fog color to use
  96769. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96770. * (Default is Color3(0.2, 0.2, 0.3))
  96771. */
  96772. fogColor: Color3;
  96773. /**
  96774. * Gets or sets the fog density to use
  96775. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96776. * (Default is 0.1)
  96777. */
  96778. fogDensity: number;
  96779. /**
  96780. * Gets or sets the fog start distance to use
  96781. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96782. * (Default is 0)
  96783. */
  96784. fogStart: number;
  96785. /**
  96786. * Gets or sets the fog end distance to use
  96787. * @see http://doc.babylonjs.com/babylon101/environment#fog
  96788. * (Default is 1000)
  96789. */
  96790. fogEnd: number;
  96791. private _shadowsEnabled;
  96792. /**
  96793. * Gets or sets a boolean indicating if shadows are enabled on this scene
  96794. */
  96795. shadowsEnabled: boolean;
  96796. private _lightsEnabled;
  96797. /**
  96798. * Gets or sets a boolean indicating if lights are enabled on this scene
  96799. */
  96800. lightsEnabled: boolean;
  96801. /** All of the active cameras added to this scene. */
  96802. activeCameras: Camera[];
  96803. /** @hidden */
  96804. _activeCamera: Nullable<Camera>;
  96805. /** Gets or sets the current active camera */
  96806. activeCamera: Nullable<Camera>;
  96807. private _defaultMaterial;
  96808. /** The default material used on meshes when no material is affected */
  96809. /** The default material used on meshes when no material is affected */
  96810. defaultMaterial: Material;
  96811. private _texturesEnabled;
  96812. /**
  96813. * Gets or sets a boolean indicating if textures are enabled on this scene
  96814. */
  96815. texturesEnabled: boolean;
  96816. /**
  96817. * Gets or sets a boolean indicating if particles are enabled on this scene
  96818. */
  96819. particlesEnabled: boolean;
  96820. /**
  96821. * Gets or sets a boolean indicating if sprites are enabled on this scene
  96822. */
  96823. spritesEnabled: boolean;
  96824. private _skeletonsEnabled;
  96825. /**
  96826. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  96827. */
  96828. skeletonsEnabled: boolean;
  96829. /**
  96830. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  96831. */
  96832. lensFlaresEnabled: boolean;
  96833. /**
  96834. * Gets or sets a boolean indicating if collisions are enabled on this scene
  96835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96836. */
  96837. collisionsEnabled: boolean;
  96838. private _collisionCoordinator;
  96839. /** @hidden */
  96840. readonly collisionCoordinator: ICollisionCoordinator;
  96841. /**
  96842. * Defines the gravity applied to this scene (used only for collisions)
  96843. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  96844. */
  96845. gravity: Vector3;
  96846. /**
  96847. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  96848. */
  96849. postProcessesEnabled: boolean;
  96850. /**
  96851. * The list of postprocesses added to the scene
  96852. */
  96853. postProcesses: PostProcess[];
  96854. /**
  96855. * Gets the current postprocess manager
  96856. */
  96857. postProcessManager: PostProcessManager;
  96858. /**
  96859. * Gets or sets a boolean indicating if render targets are enabled on this scene
  96860. */
  96861. renderTargetsEnabled: boolean;
  96862. /**
  96863. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  96864. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  96865. */
  96866. dumpNextRenderTargets: boolean;
  96867. /**
  96868. * The list of user defined render targets added to the scene
  96869. */
  96870. customRenderTargets: RenderTargetTexture[];
  96871. /**
  96872. * Defines if texture loading must be delayed
  96873. * If true, textures will only be loaded when they need to be rendered
  96874. */
  96875. useDelayedTextureLoading: boolean;
  96876. /**
  96877. * Gets the list of meshes imported to the scene through SceneLoader
  96878. */
  96879. importedMeshesFiles: String[];
  96880. /**
  96881. * Gets or sets a boolean indicating if probes are enabled on this scene
  96882. */
  96883. probesEnabled: boolean;
  96884. /**
  96885. * Gets or sets the current offline provider to use to store scene data
  96886. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  96887. */
  96888. offlineProvider: IOfflineProvider;
  96889. /**
  96890. * Gets or sets the action manager associated with the scene
  96891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96892. */
  96893. actionManager: AbstractActionManager;
  96894. private _meshesForIntersections;
  96895. /**
  96896. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  96897. */
  96898. proceduralTexturesEnabled: boolean;
  96899. private _engine;
  96900. private _totalVertices;
  96901. /** @hidden */
  96902. _activeIndices: PerfCounter;
  96903. /** @hidden */
  96904. _activeParticles: PerfCounter;
  96905. /** @hidden */
  96906. _activeBones: PerfCounter;
  96907. private _animationRatio;
  96908. /** @hidden */
  96909. _animationTimeLast: number;
  96910. /** @hidden */
  96911. _animationTime: number;
  96912. /**
  96913. * Gets or sets a general scale for animation speed
  96914. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  96915. */
  96916. animationTimeScale: number;
  96917. /** @hidden */
  96918. _cachedMaterial: Nullable<Material>;
  96919. /** @hidden */
  96920. _cachedEffect: Nullable<Effect>;
  96921. /** @hidden */
  96922. _cachedVisibility: Nullable<number>;
  96923. private _renderId;
  96924. private _frameId;
  96925. private _executeWhenReadyTimeoutId;
  96926. private _intermediateRendering;
  96927. private _viewUpdateFlag;
  96928. private _projectionUpdateFlag;
  96929. /** @hidden */
  96930. _toBeDisposed: Nullable<IDisposable>[];
  96931. private _activeRequests;
  96932. /** @hidden */
  96933. _pendingData: any[];
  96934. private _isDisposed;
  96935. /**
  96936. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  96937. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  96938. */
  96939. dispatchAllSubMeshesOfActiveMeshes: boolean;
  96940. private _activeMeshes;
  96941. private _processedMaterials;
  96942. private _renderTargets;
  96943. /** @hidden */
  96944. _activeParticleSystems: SmartArray<IParticleSystem>;
  96945. private _activeSkeletons;
  96946. private _softwareSkinnedMeshes;
  96947. private _renderingManager;
  96948. /** @hidden */
  96949. _activeAnimatables: Animatable[];
  96950. private _transformMatrix;
  96951. private _sceneUbo;
  96952. /** @hidden */
  96953. _viewMatrix: Matrix;
  96954. private _projectionMatrix;
  96955. /** @hidden */
  96956. _forcedViewPosition: Nullable<Vector3>;
  96957. /** @hidden */
  96958. _frustumPlanes: Plane[];
  96959. /**
  96960. * Gets the list of frustum planes (built from the active camera)
  96961. */
  96962. readonly frustumPlanes: Plane[];
  96963. /**
  96964. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  96965. * This is useful if there are more lights that the maximum simulteanous authorized
  96966. */
  96967. requireLightSorting: boolean;
  96968. /** @hidden */
  96969. readonly useMaterialMeshMap: boolean;
  96970. /** @hidden */
  96971. readonly useClonedMeshhMap: boolean;
  96972. private _externalData;
  96973. private _uid;
  96974. /**
  96975. * @hidden
  96976. * Backing store of defined scene components.
  96977. */
  96978. _components: ISceneComponent[];
  96979. /**
  96980. * @hidden
  96981. * Backing store of defined scene components.
  96982. */
  96983. _serializableComponents: ISceneSerializableComponent[];
  96984. /**
  96985. * List of components to register on the next registration step.
  96986. */
  96987. private _transientComponents;
  96988. /**
  96989. * Registers the transient components if needed.
  96990. */
  96991. private _registerTransientComponents;
  96992. /**
  96993. * @hidden
  96994. * Add a component to the scene.
  96995. * Note that the ccomponent could be registered on th next frame if this is called after
  96996. * the register component stage.
  96997. * @param component Defines the component to add to the scene
  96998. */
  96999. _addComponent(component: ISceneComponent): void;
  97000. /**
  97001. * @hidden
  97002. * Gets a component from the scene.
  97003. * @param name defines the name of the component to retrieve
  97004. * @returns the component or null if not present
  97005. */
  97006. _getComponent(name: string): Nullable<ISceneComponent>;
  97007. /**
  97008. * @hidden
  97009. * Defines the actions happening before camera updates.
  97010. */
  97011. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  97012. /**
  97013. * @hidden
  97014. * Defines the actions happening before clear the canvas.
  97015. */
  97016. _beforeClearStage: Stage<SimpleStageAction>;
  97017. /**
  97018. * @hidden
  97019. * Defines the actions when collecting render targets for the frame.
  97020. */
  97021. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97022. /**
  97023. * @hidden
  97024. * Defines the actions happening for one camera in the frame.
  97025. */
  97026. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  97027. /**
  97028. * @hidden
  97029. * Defines the actions happening during the per mesh ready checks.
  97030. */
  97031. _isReadyForMeshStage: Stage<MeshStageAction>;
  97032. /**
  97033. * @hidden
  97034. * Defines the actions happening before evaluate active mesh checks.
  97035. */
  97036. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  97037. /**
  97038. * @hidden
  97039. * Defines the actions happening during the evaluate sub mesh checks.
  97040. */
  97041. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  97042. /**
  97043. * @hidden
  97044. * Defines the actions happening during the active mesh stage.
  97045. */
  97046. _activeMeshStage: Stage<ActiveMeshStageAction>;
  97047. /**
  97048. * @hidden
  97049. * Defines the actions happening during the per camera render target step.
  97050. */
  97051. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  97052. /**
  97053. * @hidden
  97054. * Defines the actions happening just before the active camera is drawing.
  97055. */
  97056. _beforeCameraDrawStage: Stage<CameraStageAction>;
  97057. /**
  97058. * @hidden
  97059. * Defines the actions happening just before a render target is drawing.
  97060. */
  97061. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97062. /**
  97063. * @hidden
  97064. * Defines the actions happening just before a rendering group is drawing.
  97065. */
  97066. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97067. /**
  97068. * @hidden
  97069. * Defines the actions happening just before a mesh is drawing.
  97070. */
  97071. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97072. /**
  97073. * @hidden
  97074. * Defines the actions happening just after a mesh has been drawn.
  97075. */
  97076. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  97077. /**
  97078. * @hidden
  97079. * Defines the actions happening just after a rendering group has been drawn.
  97080. */
  97081. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  97082. /**
  97083. * @hidden
  97084. * Defines the actions happening just after the active camera has been drawn.
  97085. */
  97086. _afterCameraDrawStage: Stage<CameraStageAction>;
  97087. /**
  97088. * @hidden
  97089. * Defines the actions happening just after a render target has been drawn.
  97090. */
  97091. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  97092. /**
  97093. * @hidden
  97094. * Defines the actions happening just after rendering all cameras and computing intersections.
  97095. */
  97096. _afterRenderStage: Stage<SimpleStageAction>;
  97097. /**
  97098. * @hidden
  97099. * Defines the actions happening when a pointer move event happens.
  97100. */
  97101. _pointerMoveStage: Stage<PointerMoveStageAction>;
  97102. /**
  97103. * @hidden
  97104. * Defines the actions happening when a pointer down event happens.
  97105. */
  97106. _pointerDownStage: Stage<PointerUpDownStageAction>;
  97107. /**
  97108. * @hidden
  97109. * Defines the actions happening when a pointer up event happens.
  97110. */
  97111. _pointerUpStage: Stage<PointerUpDownStageAction>;
  97112. /**
  97113. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  97114. */
  97115. private geometriesByUniqueId;
  97116. /**
  97117. * Creates a new Scene
  97118. * @param engine defines the engine to use to render this scene
  97119. * @param options defines the scene options
  97120. */
  97121. constructor(engine: Engine, options?: SceneOptions);
  97122. /**
  97123. * Gets a string idenfifying the name of the class
  97124. * @returns "Scene" string
  97125. */
  97126. getClassName(): string;
  97127. private _defaultMeshCandidates;
  97128. /**
  97129. * @hidden
  97130. */
  97131. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  97132. private _defaultSubMeshCandidates;
  97133. /**
  97134. * @hidden
  97135. */
  97136. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  97137. /**
  97138. * Sets the default candidate providers for the scene.
  97139. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  97140. * and getCollidingSubMeshCandidates to their default function
  97141. */
  97142. setDefaultCandidateProviders(): void;
  97143. /**
  97144. * Gets the mesh that is currently under the pointer
  97145. */
  97146. readonly meshUnderPointer: Nullable<AbstractMesh>;
  97147. /**
  97148. * Gets or sets the current on-screen X position of the pointer
  97149. */
  97150. pointerX: number;
  97151. /**
  97152. * Gets or sets the current on-screen Y position of the pointer
  97153. */
  97154. pointerY: number;
  97155. /**
  97156. * Gets the cached material (ie. the latest rendered one)
  97157. * @returns the cached material
  97158. */
  97159. getCachedMaterial(): Nullable<Material>;
  97160. /**
  97161. * Gets the cached effect (ie. the latest rendered one)
  97162. * @returns the cached effect
  97163. */
  97164. getCachedEffect(): Nullable<Effect>;
  97165. /**
  97166. * Gets the cached visibility state (ie. the latest rendered one)
  97167. * @returns the cached visibility state
  97168. */
  97169. getCachedVisibility(): Nullable<number>;
  97170. /**
  97171. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  97172. * @param material defines the current material
  97173. * @param effect defines the current effect
  97174. * @param visibility defines the current visibility state
  97175. * @returns true if one parameter is not cached
  97176. */
  97177. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  97178. /**
  97179. * Gets the engine associated with the scene
  97180. * @returns an Engine
  97181. */
  97182. getEngine(): Engine;
  97183. /**
  97184. * Gets the total number of vertices rendered per frame
  97185. * @returns the total number of vertices rendered per frame
  97186. */
  97187. getTotalVertices(): number;
  97188. /**
  97189. * Gets the performance counter for total vertices
  97190. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97191. */
  97192. readonly totalVerticesPerfCounter: PerfCounter;
  97193. /**
  97194. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  97195. * @returns the total number of active indices rendered per frame
  97196. */
  97197. getActiveIndices(): number;
  97198. /**
  97199. * Gets the performance counter for active indices
  97200. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97201. */
  97202. readonly totalActiveIndicesPerfCounter: PerfCounter;
  97203. /**
  97204. * Gets the total number of active particles rendered per frame
  97205. * @returns the total number of active particles rendered per frame
  97206. */
  97207. getActiveParticles(): number;
  97208. /**
  97209. * Gets the performance counter for active particles
  97210. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97211. */
  97212. readonly activeParticlesPerfCounter: PerfCounter;
  97213. /**
  97214. * Gets the total number of active bones rendered per frame
  97215. * @returns the total number of active bones rendered per frame
  97216. */
  97217. getActiveBones(): number;
  97218. /**
  97219. * Gets the performance counter for active bones
  97220. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  97221. */
  97222. readonly activeBonesPerfCounter: PerfCounter;
  97223. /**
  97224. * Gets the array of active meshes
  97225. * @returns an array of AbstractMesh
  97226. */
  97227. getActiveMeshes(): SmartArray<AbstractMesh>;
  97228. /**
  97229. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  97230. * @returns a number
  97231. */
  97232. getAnimationRatio(): number;
  97233. /**
  97234. * Gets an unique Id for the current render phase
  97235. * @returns a number
  97236. */
  97237. getRenderId(): number;
  97238. /**
  97239. * Gets an unique Id for the current frame
  97240. * @returns a number
  97241. */
  97242. getFrameId(): number;
  97243. /** Call this function if you want to manually increment the render Id*/
  97244. incrementRenderId(): void;
  97245. private _createUbo;
  97246. /**
  97247. * Use this method to simulate a pointer move on a mesh
  97248. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97249. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97250. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97251. * @returns the current scene
  97252. */
  97253. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97254. /**
  97255. * Use this method to simulate a pointer down on a mesh
  97256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97259. * @returns the current scene
  97260. */
  97261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  97262. /**
  97263. * Use this method to simulate a pointer up on a mesh
  97264. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  97265. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  97266. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  97267. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  97268. * @returns the current scene
  97269. */
  97270. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  97271. /**
  97272. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  97273. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  97274. * @returns true if the pointer was captured
  97275. */
  97276. isPointerCaptured(pointerId?: number): boolean;
  97277. /**
  97278. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  97279. * @param attachUp defines if you want to attach events to pointerup
  97280. * @param attachDown defines if you want to attach events to pointerdown
  97281. * @param attachMove defines if you want to attach events to pointermove
  97282. */
  97283. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  97284. /** Detaches all event handlers*/
  97285. detachControl(): void;
  97286. /**
  97287. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  97288. * Delay loaded resources are not taking in account
  97289. * @return true if all required resources are ready
  97290. */
  97291. isReady(): boolean;
  97292. /** Resets all cached information relative to material (including effect and visibility) */
  97293. resetCachedMaterial(): void;
  97294. /**
  97295. * Registers a function to be called before every frame render
  97296. * @param func defines the function to register
  97297. */
  97298. registerBeforeRender(func: () => void): void;
  97299. /**
  97300. * Unregisters a function called before every frame render
  97301. * @param func defines the function to unregister
  97302. */
  97303. unregisterBeforeRender(func: () => void): void;
  97304. /**
  97305. * Registers a function to be called after every frame render
  97306. * @param func defines the function to register
  97307. */
  97308. registerAfterRender(func: () => void): void;
  97309. /**
  97310. * Unregisters a function called after every frame render
  97311. * @param func defines the function to unregister
  97312. */
  97313. unregisterAfterRender(func: () => void): void;
  97314. private _executeOnceBeforeRender;
  97315. /**
  97316. * The provided function will run before render once and will be disposed afterwards.
  97317. * A timeout delay can be provided so that the function will be executed in N ms.
  97318. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  97319. * @param func The function to be executed.
  97320. * @param timeout optional delay in ms
  97321. */
  97322. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  97323. /** @hidden */
  97324. _addPendingData(data: any): void;
  97325. /** @hidden */
  97326. _removePendingData(data: any): void;
  97327. /**
  97328. * Returns the number of items waiting to be loaded
  97329. * @returns the number of items waiting to be loaded
  97330. */
  97331. getWaitingItemsCount(): number;
  97332. /**
  97333. * Returns a boolean indicating if the scene is still loading data
  97334. */
  97335. readonly isLoading: boolean;
  97336. /**
  97337. * Registers a function to be executed when the scene is ready
  97338. * @param {Function} func - the function to be executed
  97339. */
  97340. executeWhenReady(func: () => void): void;
  97341. /**
  97342. * Returns a promise that resolves when the scene is ready
  97343. * @returns A promise that resolves when the scene is ready
  97344. */
  97345. whenReadyAsync(): Promise<void>;
  97346. /** @hidden */
  97347. _checkIsReady(): void;
  97348. /**
  97349. * Gets all animatable attached to the scene
  97350. */
  97351. readonly animatables: Animatable[];
  97352. /**
  97353. * Resets the last animation time frame.
  97354. * Useful to override when animations start running when loading a scene for the first time.
  97355. */
  97356. resetLastAnimationTimeFrame(): void;
  97357. /**
  97358. * Gets the current view matrix
  97359. * @returns a Matrix
  97360. */
  97361. getViewMatrix(): Matrix;
  97362. /**
  97363. * Gets the current projection matrix
  97364. * @returns a Matrix
  97365. */
  97366. getProjectionMatrix(): Matrix;
  97367. /**
  97368. * Gets the current transform matrix
  97369. * @returns a Matrix made of View * Projection
  97370. */
  97371. getTransformMatrix(): Matrix;
  97372. /**
  97373. * Sets the current transform matrix
  97374. * @param viewL defines the View matrix to use
  97375. * @param projectionL defines the Projection matrix to use
  97376. * @param viewR defines the right View matrix to use (if provided)
  97377. * @param projectionR defines the right Projection matrix to use (if provided)
  97378. */
  97379. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  97380. /**
  97381. * Gets the uniform buffer used to store scene data
  97382. * @returns a UniformBuffer
  97383. */
  97384. getSceneUniformBuffer(): UniformBuffer;
  97385. /**
  97386. * Gets an unique (relatively to the current scene) Id
  97387. * @returns an unique number for the scene
  97388. */
  97389. getUniqueId(): number;
  97390. /**
  97391. * Add a mesh to the list of scene's meshes
  97392. * @param newMesh defines the mesh to add
  97393. * @param recursive if all child meshes should also be added to the scene
  97394. */
  97395. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  97396. /**
  97397. * Remove a mesh for the list of scene's meshes
  97398. * @param toRemove defines the mesh to remove
  97399. * @param recursive if all child meshes should also be removed from the scene
  97400. * @returns the index where the mesh was in the mesh list
  97401. */
  97402. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  97403. /**
  97404. * Add a transform node to the list of scene's transform nodes
  97405. * @param newTransformNode defines the transform node to add
  97406. */
  97407. addTransformNode(newTransformNode: TransformNode): void;
  97408. /**
  97409. * Remove a transform node for the list of scene's transform nodes
  97410. * @param toRemove defines the transform node to remove
  97411. * @returns the index where the transform node was in the transform node list
  97412. */
  97413. removeTransformNode(toRemove: TransformNode): number;
  97414. /**
  97415. * Remove a skeleton for the list of scene's skeletons
  97416. * @param toRemove defines the skeleton to remove
  97417. * @returns the index where the skeleton was in the skeleton list
  97418. */
  97419. removeSkeleton(toRemove: Skeleton): number;
  97420. /**
  97421. * Remove a morph target for the list of scene's morph targets
  97422. * @param toRemove defines the morph target to remove
  97423. * @returns the index where the morph target was in the morph target list
  97424. */
  97425. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  97426. /**
  97427. * Remove a light for the list of scene's lights
  97428. * @param toRemove defines the light to remove
  97429. * @returns the index where the light was in the light list
  97430. */
  97431. removeLight(toRemove: Light): number;
  97432. /**
  97433. * Remove a camera for the list of scene's cameras
  97434. * @param toRemove defines the camera to remove
  97435. * @returns the index where the camera was in the camera list
  97436. */
  97437. removeCamera(toRemove: Camera): number;
  97438. /**
  97439. * Remove a particle system for the list of scene's particle systems
  97440. * @param toRemove defines the particle system to remove
  97441. * @returns the index where the particle system was in the particle system list
  97442. */
  97443. removeParticleSystem(toRemove: IParticleSystem): number;
  97444. /**
  97445. * Remove a animation for the list of scene's animations
  97446. * @param toRemove defines the animation to remove
  97447. * @returns the index where the animation was in the animation list
  97448. */
  97449. removeAnimation(toRemove: Animation): number;
  97450. /**
  97451. * Will stop the animation of the given target
  97452. * @param target - the target
  97453. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  97454. * @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)
  97455. */
  97456. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  97457. /**
  97458. * Removes the given animation group from this scene.
  97459. * @param toRemove The animation group to remove
  97460. * @returns The index of the removed animation group
  97461. */
  97462. removeAnimationGroup(toRemove: AnimationGroup): number;
  97463. /**
  97464. * Removes the given multi-material from this scene.
  97465. * @param toRemove The multi-material to remove
  97466. * @returns The index of the removed multi-material
  97467. */
  97468. removeMultiMaterial(toRemove: MultiMaterial): number;
  97469. /**
  97470. * Removes the given material from this scene.
  97471. * @param toRemove The material to remove
  97472. * @returns The index of the removed material
  97473. */
  97474. removeMaterial(toRemove: Material): number;
  97475. /**
  97476. * Removes the given action manager from this scene.
  97477. * @param toRemove The action manager to remove
  97478. * @returns The index of the removed action manager
  97479. */
  97480. removeActionManager(toRemove: AbstractActionManager): number;
  97481. /**
  97482. * Removes the given texture from this scene.
  97483. * @param toRemove The texture to remove
  97484. * @returns The index of the removed texture
  97485. */
  97486. removeTexture(toRemove: BaseTexture): number;
  97487. /**
  97488. * Adds the given light to this scene
  97489. * @param newLight The light to add
  97490. */
  97491. addLight(newLight: Light): void;
  97492. /**
  97493. * Sorts the list list based on light priorities
  97494. */
  97495. sortLightsByPriority(): void;
  97496. /**
  97497. * Adds the given camera to this scene
  97498. * @param newCamera The camera to add
  97499. */
  97500. addCamera(newCamera: Camera): void;
  97501. /**
  97502. * Adds the given skeleton to this scene
  97503. * @param newSkeleton The skeleton to add
  97504. */
  97505. addSkeleton(newSkeleton: Skeleton): void;
  97506. /**
  97507. * Adds the given particle system to this scene
  97508. * @param newParticleSystem The particle system to add
  97509. */
  97510. addParticleSystem(newParticleSystem: IParticleSystem): void;
  97511. /**
  97512. * Adds the given animation to this scene
  97513. * @param newAnimation The animation to add
  97514. */
  97515. addAnimation(newAnimation: Animation): void;
  97516. /**
  97517. * Adds the given animation group to this scene.
  97518. * @param newAnimationGroup The animation group to add
  97519. */
  97520. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  97521. /**
  97522. * Adds the given multi-material to this scene
  97523. * @param newMultiMaterial The multi-material to add
  97524. */
  97525. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  97526. /**
  97527. * Adds the given material to this scene
  97528. * @param newMaterial The material to add
  97529. */
  97530. addMaterial(newMaterial: Material): void;
  97531. /**
  97532. * Adds the given morph target to this scene
  97533. * @param newMorphTargetManager The morph target to add
  97534. */
  97535. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  97536. /**
  97537. * Adds the given geometry to this scene
  97538. * @param newGeometry The geometry to add
  97539. */
  97540. addGeometry(newGeometry: Geometry): void;
  97541. /**
  97542. * Adds the given action manager to this scene
  97543. * @param newActionManager The action manager to add
  97544. */
  97545. addActionManager(newActionManager: AbstractActionManager): void;
  97546. /**
  97547. * Adds the given texture to this scene.
  97548. * @param newTexture The texture to add
  97549. */
  97550. addTexture(newTexture: BaseTexture): void;
  97551. /**
  97552. * Switch active camera
  97553. * @param newCamera defines the new active camera
  97554. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  97555. */
  97556. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  97557. /**
  97558. * sets the active camera of the scene using its ID
  97559. * @param id defines the camera's ID
  97560. * @return the new active camera or null if none found.
  97561. */
  97562. setActiveCameraByID(id: string): Nullable<Camera>;
  97563. /**
  97564. * sets the active camera of the scene using its name
  97565. * @param name defines the camera's name
  97566. * @returns the new active camera or null if none found.
  97567. */
  97568. setActiveCameraByName(name: string): Nullable<Camera>;
  97569. /**
  97570. * get an animation group using its name
  97571. * @param name defines the material's name
  97572. * @return the animation group or null if none found.
  97573. */
  97574. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  97575. /**
  97576. * Get a material using its unique id
  97577. * @param uniqueId defines the material's unique id
  97578. * @return the material or null if none found.
  97579. */
  97580. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  97581. /**
  97582. * get a material using its id
  97583. * @param id defines the material's ID
  97584. * @return the material or null if none found.
  97585. */
  97586. getMaterialByID(id: string): Nullable<Material>;
  97587. /**
  97588. * Gets a the last added material using a given id
  97589. * @param id defines the material's ID
  97590. * @return the last material with the given id or null if none found.
  97591. */
  97592. getLastMaterialByID(id: string): Nullable<Material>;
  97593. /**
  97594. * Gets a material using its name
  97595. * @param name defines the material's name
  97596. * @return the material or null if none found.
  97597. */
  97598. getMaterialByName(name: string): Nullable<Material>;
  97599. /**
  97600. * Gets a camera using its id
  97601. * @param id defines the id to look for
  97602. * @returns the camera or null if not found
  97603. */
  97604. getCameraByID(id: string): Nullable<Camera>;
  97605. /**
  97606. * Gets a camera using its unique id
  97607. * @param uniqueId defines the unique id to look for
  97608. * @returns the camera or null if not found
  97609. */
  97610. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  97611. /**
  97612. * Gets a camera using its name
  97613. * @param name defines the camera's name
  97614. * @return the camera or null if none found.
  97615. */
  97616. getCameraByName(name: string): Nullable<Camera>;
  97617. /**
  97618. * Gets a bone using its id
  97619. * @param id defines the bone's id
  97620. * @return the bone or null if not found
  97621. */
  97622. getBoneByID(id: string): Nullable<Bone>;
  97623. /**
  97624. * Gets a bone using its id
  97625. * @param name defines the bone's name
  97626. * @return the bone or null if not found
  97627. */
  97628. getBoneByName(name: string): Nullable<Bone>;
  97629. /**
  97630. * Gets a light node using its name
  97631. * @param name defines the the light's name
  97632. * @return the light or null if none found.
  97633. */
  97634. getLightByName(name: string): Nullable<Light>;
  97635. /**
  97636. * Gets a light node using its id
  97637. * @param id defines the light's id
  97638. * @return the light or null if none found.
  97639. */
  97640. getLightByID(id: string): Nullable<Light>;
  97641. /**
  97642. * Gets a light node using its scene-generated unique ID
  97643. * @param uniqueId defines the light's unique id
  97644. * @return the light or null if none found.
  97645. */
  97646. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  97647. /**
  97648. * Gets a particle system by id
  97649. * @param id defines the particle system id
  97650. * @return the corresponding system or null if none found
  97651. */
  97652. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  97653. /**
  97654. * Gets a geometry using its ID
  97655. * @param id defines the geometry's id
  97656. * @return the geometry or null if none found.
  97657. */
  97658. getGeometryByID(id: string): Nullable<Geometry>;
  97659. private _getGeometryByUniqueID;
  97660. /**
  97661. * Add a new geometry to this scene
  97662. * @param geometry defines the geometry to be added to the scene.
  97663. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  97664. * @return a boolean defining if the geometry was added or not
  97665. */
  97666. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  97667. /**
  97668. * Removes an existing geometry
  97669. * @param geometry defines the geometry to be removed from the scene
  97670. * @return a boolean defining if the geometry was removed or not
  97671. */
  97672. removeGeometry(geometry: Geometry): boolean;
  97673. /**
  97674. * Gets the list of geometries attached to the scene
  97675. * @returns an array of Geometry
  97676. */
  97677. getGeometries(): Geometry[];
  97678. /**
  97679. * Gets the first added mesh found of a given ID
  97680. * @param id defines the id to search for
  97681. * @return the mesh found or null if not found at all
  97682. */
  97683. getMeshByID(id: string): Nullable<AbstractMesh>;
  97684. /**
  97685. * Gets a list of meshes using their id
  97686. * @param id defines the id to search for
  97687. * @returns a list of meshes
  97688. */
  97689. getMeshesByID(id: string): Array<AbstractMesh>;
  97690. /**
  97691. * Gets the first added transform node found of a given ID
  97692. * @param id defines the id to search for
  97693. * @return the found transform node or null if not found at all.
  97694. */
  97695. getTransformNodeByID(id: string): Nullable<TransformNode>;
  97696. /**
  97697. * Gets a transform node with its auto-generated unique id
  97698. * @param uniqueId efines the unique id to search for
  97699. * @return the found transform node or null if not found at all.
  97700. */
  97701. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  97702. /**
  97703. * Gets a list of transform nodes using their id
  97704. * @param id defines the id to search for
  97705. * @returns a list of transform nodes
  97706. */
  97707. getTransformNodesByID(id: string): Array<TransformNode>;
  97708. /**
  97709. * Gets a mesh with its auto-generated unique id
  97710. * @param uniqueId defines the unique id to search for
  97711. * @return the found mesh or null if not found at all.
  97712. */
  97713. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  97714. /**
  97715. * Gets a the last added mesh using a given id
  97716. * @param id defines the id to search for
  97717. * @return the found mesh or null if not found at all.
  97718. */
  97719. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  97720. /**
  97721. * Gets a the last added node (Mesh, Camera, Light) using a given id
  97722. * @param id defines the id to search for
  97723. * @return the found node or null if not found at all
  97724. */
  97725. getLastEntryByID(id: string): Nullable<Node>;
  97726. /**
  97727. * Gets a node (Mesh, Camera, Light) using a given id
  97728. * @param id defines the id to search for
  97729. * @return the found node or null if not found at all
  97730. */
  97731. getNodeByID(id: string): Nullable<Node>;
  97732. /**
  97733. * Gets a node (Mesh, Camera, Light) using a given name
  97734. * @param name defines the name to search for
  97735. * @return the found node or null if not found at all.
  97736. */
  97737. getNodeByName(name: string): Nullable<Node>;
  97738. /**
  97739. * Gets a mesh using a given name
  97740. * @param name defines the name to search for
  97741. * @return the found mesh or null if not found at all.
  97742. */
  97743. getMeshByName(name: string): Nullable<AbstractMesh>;
  97744. /**
  97745. * Gets a transform node using a given name
  97746. * @param name defines the name to search for
  97747. * @return the found transform node or null if not found at all.
  97748. */
  97749. getTransformNodeByName(name: string): Nullable<TransformNode>;
  97750. /**
  97751. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  97752. * @param id defines the id to search for
  97753. * @return the found skeleton or null if not found at all.
  97754. */
  97755. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  97756. /**
  97757. * Gets a skeleton using a given auto generated unique id
  97758. * @param uniqueId defines the unique id to search for
  97759. * @return the found skeleton or null if not found at all.
  97760. */
  97761. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  97762. /**
  97763. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  97764. * @param id defines the id to search for
  97765. * @return the found skeleton or null if not found at all.
  97766. */
  97767. getSkeletonById(id: string): Nullable<Skeleton>;
  97768. /**
  97769. * Gets a skeleton using a given name
  97770. * @param name defines the name to search for
  97771. * @return the found skeleton or null if not found at all.
  97772. */
  97773. getSkeletonByName(name: string): Nullable<Skeleton>;
  97774. /**
  97775. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  97776. * @param id defines the id to search for
  97777. * @return the found morph target manager or null if not found at all.
  97778. */
  97779. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  97780. /**
  97781. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  97782. * @param id defines the id to search for
  97783. * @return the found morph target or null if not found at all.
  97784. */
  97785. getMorphTargetById(id: string): Nullable<MorphTarget>;
  97786. /**
  97787. * Gets a boolean indicating if the given mesh is active
  97788. * @param mesh defines the mesh to look for
  97789. * @returns true if the mesh is in the active list
  97790. */
  97791. isActiveMesh(mesh: AbstractMesh): boolean;
  97792. /**
  97793. * Return a unique id as a string which can serve as an identifier for the scene
  97794. */
  97795. readonly uid: string;
  97796. /**
  97797. * Add an externaly attached data from its key.
  97798. * This method call will fail and return false, if such key already exists.
  97799. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  97800. * @param key the unique key that identifies the data
  97801. * @param data the data object to associate to the key for this Engine instance
  97802. * @return true if no such key were already present and the data was added successfully, false otherwise
  97803. */
  97804. addExternalData<T>(key: string, data: T): boolean;
  97805. /**
  97806. * Get an externaly attached data from its key
  97807. * @param key the unique key that identifies the data
  97808. * @return the associated data, if present (can be null), or undefined if not present
  97809. */
  97810. getExternalData<T>(key: string): Nullable<T>;
  97811. /**
  97812. * Get an externaly attached data from its key, create it using a factory if it's not already present
  97813. * @param key the unique key that identifies the data
  97814. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  97815. * @return the associated data, can be null if the factory returned null.
  97816. */
  97817. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  97818. /**
  97819. * Remove an externaly attached data from the Engine instance
  97820. * @param key the unique key that identifies the data
  97821. * @return true if the data was successfully removed, false if it doesn't exist
  97822. */
  97823. removeExternalData(key: string): boolean;
  97824. private _evaluateSubMesh;
  97825. /**
  97826. * Clear the processed materials smart array preventing retention point in material dispose.
  97827. */
  97828. freeProcessedMaterials(): void;
  97829. private _preventFreeActiveMeshesAndRenderingGroups;
  97830. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  97831. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  97832. * when disposing several meshes in a row or a hierarchy of meshes.
  97833. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  97834. */
  97835. blockfreeActiveMeshesAndRenderingGroups: boolean;
  97836. /**
  97837. * Clear the active meshes smart array preventing retention point in mesh dispose.
  97838. */
  97839. freeActiveMeshes(): void;
  97840. /**
  97841. * Clear the info related to rendering groups preventing retention points during dispose.
  97842. */
  97843. freeRenderingGroups(): void;
  97844. /** @hidden */
  97845. _isInIntermediateRendering(): boolean;
  97846. /**
  97847. * Lambda returning the list of potentially active meshes.
  97848. */
  97849. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  97850. /**
  97851. * Lambda returning the list of potentially active sub meshes.
  97852. */
  97853. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  97854. /**
  97855. * Lambda returning the list of potentially intersecting sub meshes.
  97856. */
  97857. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  97858. /**
  97859. * Lambda returning the list of potentially colliding sub meshes.
  97860. */
  97861. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  97862. private _activeMeshesFrozen;
  97863. /**
  97864. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  97865. * @returns the current scene
  97866. */
  97867. freezeActiveMeshes(): Scene;
  97868. /**
  97869. * Use this function to restart evaluating active meshes on every frame
  97870. * @returns the current scene
  97871. */
  97872. unfreezeActiveMeshes(): Scene;
  97873. private _evaluateActiveMeshes;
  97874. private _activeMesh;
  97875. /**
  97876. * Update the transform matrix to update from the current active camera
  97877. * @param force defines a boolean used to force the update even if cache is up to date
  97878. */
  97879. updateTransformMatrix(force?: boolean): void;
  97880. private _bindFrameBuffer;
  97881. /** @hidden */
  97882. _allowPostProcessClearColor: boolean;
  97883. /** @hidden */
  97884. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  97885. private _processSubCameras;
  97886. private _checkIntersections;
  97887. /** @hidden */
  97888. _advancePhysicsEngineStep(step: number): void;
  97889. /**
  97890. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  97891. */
  97892. getDeterministicFrameTime: () => number;
  97893. /** @hidden */
  97894. _animate(): void;
  97895. /** Execute all animations (for a frame) */
  97896. animate(): void;
  97897. /**
  97898. * Render the scene
  97899. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  97900. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  97901. */
  97902. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  97903. /**
  97904. * Freeze all materials
  97905. * A frozen material will not be updatable but should be faster to render
  97906. */
  97907. freezeMaterials(): void;
  97908. /**
  97909. * Unfreeze all materials
  97910. * A frozen material will not be updatable but should be faster to render
  97911. */
  97912. unfreezeMaterials(): void;
  97913. /**
  97914. * Releases all held ressources
  97915. */
  97916. dispose(): void;
  97917. /**
  97918. * Gets if the scene is already disposed
  97919. */
  97920. readonly isDisposed: boolean;
  97921. /**
  97922. * Call this function to reduce memory footprint of the scene.
  97923. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  97924. */
  97925. clearCachedVertexData(): void;
  97926. /**
  97927. * This function will remove the local cached buffer data from texture.
  97928. * It will save memory but will prevent the texture from being rebuilt
  97929. */
  97930. cleanCachedTextureBuffer(): void;
  97931. /**
  97932. * Get the world extend vectors with an optional filter
  97933. *
  97934. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  97935. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  97936. */
  97937. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  97938. min: Vector3;
  97939. max: Vector3;
  97940. };
  97941. /**
  97942. * Creates a ray that can be used to pick in the scene
  97943. * @param x defines the x coordinate of the origin (on-screen)
  97944. * @param y defines the y coordinate of the origin (on-screen)
  97945. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97946. * @param camera defines the camera to use for the picking
  97947. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97948. * @returns a Ray
  97949. */
  97950. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  97951. /**
  97952. * Creates a ray that can be used to pick in the scene
  97953. * @param x defines the x coordinate of the origin (on-screen)
  97954. * @param y defines the y coordinate of the origin (on-screen)
  97955. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  97956. * @param result defines the ray where to store the picking ray
  97957. * @param camera defines the camera to use for the picking
  97958. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  97959. * @returns the current scene
  97960. */
  97961. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  97962. /**
  97963. * Creates a ray that can be used to pick in the scene
  97964. * @param x defines the x coordinate of the origin (on-screen)
  97965. * @param y defines the y coordinate of the origin (on-screen)
  97966. * @param camera defines the camera to use for the picking
  97967. * @returns a Ray
  97968. */
  97969. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  97970. /**
  97971. * Creates a ray that can be used to pick in the scene
  97972. * @param x defines the x coordinate of the origin (on-screen)
  97973. * @param y defines the y coordinate of the origin (on-screen)
  97974. * @param result defines the ray where to store the picking ray
  97975. * @param camera defines the camera to use for the picking
  97976. * @returns the current scene
  97977. */
  97978. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  97979. /** Launch a ray to try to pick a mesh in the scene
  97980. * @param x position on screen
  97981. * @param y position on screen
  97982. * @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
  97983. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  97984. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  97985. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97986. * @returns a PickingInfo
  97987. */
  97988. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97989. /** Use the given ray to pick a mesh in the scene
  97990. * @param ray The ray to use to pick meshes
  97991. * @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
  97992. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  97993. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  97994. * @returns a PickingInfo
  97995. */
  97996. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  97997. /**
  97998. * Launch a ray to try to pick a mesh in the scene
  97999. * @param x X position on screen
  98000. * @param y Y position on screen
  98001. * @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
  98002. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  98003. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98004. * @returns an array of PickingInfo
  98005. */
  98006. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98007. /**
  98008. * Launch a ray to try to pick a mesh in the scene
  98009. * @param ray Ray to use
  98010. * @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
  98011. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  98012. * @returns an array of PickingInfo
  98013. */
  98014. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  98015. /**
  98016. * Force the value of meshUnderPointer
  98017. * @param mesh defines the mesh to use
  98018. */
  98019. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  98020. /**
  98021. * Gets the mesh under the pointer
  98022. * @returns a Mesh or null if no mesh is under the pointer
  98023. */
  98024. getPointerOverMesh(): Nullable<AbstractMesh>;
  98025. /** @hidden */
  98026. _rebuildGeometries(): void;
  98027. /** @hidden */
  98028. _rebuildTextures(): void;
  98029. private _getByTags;
  98030. /**
  98031. * Get a list of meshes by tags
  98032. * @param tagsQuery defines the tags query to use
  98033. * @param forEach defines a predicate used to filter results
  98034. * @returns an array of Mesh
  98035. */
  98036. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  98037. /**
  98038. * Get a list of cameras by tags
  98039. * @param tagsQuery defines the tags query to use
  98040. * @param forEach defines a predicate used to filter results
  98041. * @returns an array of Camera
  98042. */
  98043. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  98044. /**
  98045. * Get a list of lights by tags
  98046. * @param tagsQuery defines the tags query to use
  98047. * @param forEach defines a predicate used to filter results
  98048. * @returns an array of Light
  98049. */
  98050. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  98051. /**
  98052. * Get a list of materials by tags
  98053. * @param tagsQuery defines the tags query to use
  98054. * @param forEach defines a predicate used to filter results
  98055. * @returns an array of Material
  98056. */
  98057. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  98058. /**
  98059. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98060. * This allowed control for front to back rendering or reversly depending of the special needs.
  98061. *
  98062. * @param renderingGroupId The rendering group id corresponding to its index
  98063. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98064. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98065. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98066. */
  98067. 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;
  98068. /**
  98069. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98070. *
  98071. * @param renderingGroupId The rendering group id corresponding to its index
  98072. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98073. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98074. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98075. */
  98076. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98077. /**
  98078. * Gets the current auto clear configuration for one rendering group of the rendering
  98079. * manager.
  98080. * @param index the rendering group index to get the information for
  98081. * @returns The auto clear setup for the requested rendering group
  98082. */
  98083. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98084. private _blockMaterialDirtyMechanism;
  98085. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  98086. blockMaterialDirtyMechanism: boolean;
  98087. /**
  98088. * Will flag all materials as dirty to trigger new shader compilation
  98089. * @param flag defines the flag used to specify which material part must be marked as dirty
  98090. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  98091. */
  98092. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98093. /** @hidden */
  98094. _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;
  98095. /** @hidden */
  98096. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98097. }
  98098. }
  98099. declare module BABYLON {
  98100. /**
  98101. * Set of assets to keep when moving a scene into an asset container.
  98102. */
  98103. export class KeepAssets extends AbstractScene {
  98104. }
  98105. /**
  98106. * Container with a set of assets that can be added or removed from a scene.
  98107. */
  98108. export class AssetContainer extends AbstractScene {
  98109. /**
  98110. * The scene the AssetContainer belongs to.
  98111. */
  98112. scene: Scene;
  98113. /**
  98114. * Instantiates an AssetContainer.
  98115. * @param scene The scene the AssetContainer belongs to.
  98116. */
  98117. constructor(scene: Scene);
  98118. /**
  98119. * Adds all the assets from the container to the scene.
  98120. */
  98121. addAllToScene(): void;
  98122. /**
  98123. * Removes all the assets in the container from the scene
  98124. */
  98125. removeAllFromScene(): void;
  98126. /**
  98127. * Disposes all the assets in the container
  98128. */
  98129. dispose(): void;
  98130. private _moveAssets;
  98131. /**
  98132. * Removes all the assets contained in the scene and adds them to the container.
  98133. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  98134. */
  98135. moveAllFromScene(keepAssets?: KeepAssets): void;
  98136. /**
  98137. * 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.
  98138. * @returns the root mesh
  98139. */
  98140. createRootMesh(): Mesh;
  98141. }
  98142. }
  98143. declare module BABYLON {
  98144. /**
  98145. * Defines how the parser contract is defined.
  98146. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  98147. */
  98148. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  98149. /**
  98150. * Defines how the individual parser contract is defined.
  98151. * These parser can parse an individual asset
  98152. */
  98153. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  98154. /**
  98155. * Base class of the scene acting as a container for the different elements composing a scene.
  98156. * This class is dynamically extended by the different components of the scene increasing
  98157. * flexibility and reducing coupling
  98158. */
  98159. export abstract class AbstractScene {
  98160. /**
  98161. * Stores the list of available parsers in the application.
  98162. */
  98163. private static _BabylonFileParsers;
  98164. /**
  98165. * Stores the list of available individual parsers in the application.
  98166. */
  98167. private static _IndividualBabylonFileParsers;
  98168. /**
  98169. * Adds a parser in the list of available ones
  98170. * @param name Defines the name of the parser
  98171. * @param parser Defines the parser to add
  98172. */
  98173. static AddParser(name: string, parser: BabylonFileParser): void;
  98174. /**
  98175. * Gets a general parser from the list of avaialble ones
  98176. * @param name Defines the name of the parser
  98177. * @returns the requested parser or null
  98178. */
  98179. static GetParser(name: string): Nullable<BabylonFileParser>;
  98180. /**
  98181. * Adds n individual parser in the list of available ones
  98182. * @param name Defines the name of the parser
  98183. * @param parser Defines the parser to add
  98184. */
  98185. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  98186. /**
  98187. * Gets an individual parser from the list of avaialble ones
  98188. * @param name Defines the name of the parser
  98189. * @returns the requested parser or null
  98190. */
  98191. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  98192. /**
  98193. * Parser json data and populate both a scene and its associated container object
  98194. * @param jsonData Defines the data to parse
  98195. * @param scene Defines the scene to parse the data for
  98196. * @param container Defines the container attached to the parsing sequence
  98197. * @param rootUrl Defines the root url of the data
  98198. */
  98199. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  98200. /**
  98201. * Gets the list of root nodes (ie. nodes with no parent)
  98202. */
  98203. rootNodes: Node[];
  98204. /** All of the cameras added to this scene
  98205. * @see http://doc.babylonjs.com/babylon101/cameras
  98206. */
  98207. cameras: Camera[];
  98208. /**
  98209. * All of the lights added to this scene
  98210. * @see http://doc.babylonjs.com/babylon101/lights
  98211. */
  98212. lights: Light[];
  98213. /**
  98214. * All of the (abstract) meshes added to this scene
  98215. */
  98216. meshes: AbstractMesh[];
  98217. /**
  98218. * The list of skeletons added to the scene
  98219. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  98220. */
  98221. skeletons: Skeleton[];
  98222. /**
  98223. * All of the particle systems added to this scene
  98224. * @see http://doc.babylonjs.com/babylon101/particles
  98225. */
  98226. particleSystems: IParticleSystem[];
  98227. /**
  98228. * Gets a list of Animations associated with the scene
  98229. */
  98230. animations: Animation[];
  98231. /**
  98232. * All of the animation groups added to this scene
  98233. * @see http://doc.babylonjs.com/how_to/group
  98234. */
  98235. animationGroups: AnimationGroup[];
  98236. /**
  98237. * All of the multi-materials added to this scene
  98238. * @see http://doc.babylonjs.com/how_to/multi_materials
  98239. */
  98240. multiMaterials: MultiMaterial[];
  98241. /**
  98242. * All of the materials added to this scene
  98243. * In the context of a Scene, it is not supposed to be modified manually.
  98244. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  98245. * Note also that the order of the Material wihin the array is not significant and might change.
  98246. * @see http://doc.babylonjs.com/babylon101/materials
  98247. */
  98248. materials: Material[];
  98249. /**
  98250. * The list of morph target managers added to the scene
  98251. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  98252. */
  98253. morphTargetManagers: MorphTargetManager[];
  98254. /**
  98255. * The list of geometries used in the scene.
  98256. */
  98257. geometries: Geometry[];
  98258. /**
  98259. * All of the tranform nodes added to this scene
  98260. * In the context of a Scene, it is not supposed to be modified manually.
  98261. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  98262. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  98263. * @see http://doc.babylonjs.com/how_to/transformnode
  98264. */
  98265. transformNodes: TransformNode[];
  98266. /**
  98267. * ActionManagers available on the scene.
  98268. */
  98269. actionManagers: AbstractActionManager[];
  98270. /**
  98271. * Textures to keep.
  98272. */
  98273. textures: BaseTexture[];
  98274. /**
  98275. * Environment texture for the scene
  98276. */
  98277. environmentTexture: Nullable<BaseTexture>;
  98278. }
  98279. }
  98280. declare module BABYLON {
  98281. /**
  98282. * Interface used to define options for Sound class
  98283. */
  98284. export interface ISoundOptions {
  98285. /**
  98286. * Does the sound autoplay once loaded.
  98287. */
  98288. autoplay?: boolean;
  98289. /**
  98290. * Does the sound loop after it finishes playing once.
  98291. */
  98292. loop?: boolean;
  98293. /**
  98294. * Sound's volume
  98295. */
  98296. volume?: number;
  98297. /**
  98298. * Is it a spatial sound?
  98299. */
  98300. spatialSound?: boolean;
  98301. /**
  98302. * Maximum distance to hear that sound
  98303. */
  98304. maxDistance?: number;
  98305. /**
  98306. * Uses user defined attenuation function
  98307. */
  98308. useCustomAttenuation?: boolean;
  98309. /**
  98310. * Define the roll off factor of spatial sounds.
  98311. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98312. */
  98313. rolloffFactor?: number;
  98314. /**
  98315. * Define the reference distance the sound should be heard perfectly.
  98316. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98317. */
  98318. refDistance?: number;
  98319. /**
  98320. * Define the distance attenuation model the sound will follow.
  98321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98322. */
  98323. distanceModel?: string;
  98324. /**
  98325. * Defines the playback speed (1 by default)
  98326. */
  98327. playbackRate?: number;
  98328. /**
  98329. * Defines if the sound is from a streaming source
  98330. */
  98331. streaming?: boolean;
  98332. /**
  98333. * Defines an optional length (in seconds) inside the sound file
  98334. */
  98335. length?: number;
  98336. /**
  98337. * Defines an optional offset (in seconds) inside the sound file
  98338. */
  98339. offset?: number;
  98340. /**
  98341. * If true, URLs will not be required to state the audio file codec to use.
  98342. */
  98343. skipCodecCheck?: boolean;
  98344. }
  98345. /**
  98346. * Defines a sound that can be played in the application.
  98347. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  98348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98349. */
  98350. export class Sound {
  98351. /**
  98352. * The name of the sound in the scene.
  98353. */
  98354. name: string;
  98355. /**
  98356. * Does the sound autoplay once loaded.
  98357. */
  98358. autoplay: boolean;
  98359. /**
  98360. * Does the sound loop after it finishes playing once.
  98361. */
  98362. loop: boolean;
  98363. /**
  98364. * Does the sound use a custom attenuation curve to simulate the falloff
  98365. * happening when the source gets further away from the camera.
  98366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98367. */
  98368. useCustomAttenuation: boolean;
  98369. /**
  98370. * The sound track id this sound belongs to.
  98371. */
  98372. soundTrackId: number;
  98373. /**
  98374. * Is this sound currently played.
  98375. */
  98376. isPlaying: boolean;
  98377. /**
  98378. * Is this sound currently paused.
  98379. */
  98380. isPaused: boolean;
  98381. /**
  98382. * Does this sound enables spatial sound.
  98383. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98384. */
  98385. spatialSound: boolean;
  98386. /**
  98387. * Define the reference distance the sound should be heard perfectly.
  98388. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98389. */
  98390. refDistance: number;
  98391. /**
  98392. * Define the roll off factor of spatial sounds.
  98393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98394. */
  98395. rolloffFactor: number;
  98396. /**
  98397. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  98398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98399. */
  98400. maxDistance: number;
  98401. /**
  98402. * Define the distance attenuation model the sound will follow.
  98403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98404. */
  98405. distanceModel: string;
  98406. /**
  98407. * @hidden
  98408. * Back Compat
  98409. **/
  98410. onended: () => any;
  98411. /**
  98412. * Observable event when the current playing sound finishes.
  98413. */
  98414. onEndedObservable: Observable<Sound>;
  98415. private _panningModel;
  98416. private _playbackRate;
  98417. private _streaming;
  98418. private _startTime;
  98419. private _startOffset;
  98420. private _position;
  98421. /** @hidden */
  98422. _positionInEmitterSpace: boolean;
  98423. private _localDirection;
  98424. private _volume;
  98425. private _isReadyToPlay;
  98426. private _isDirectional;
  98427. private _readyToPlayCallback;
  98428. private _audioBuffer;
  98429. private _soundSource;
  98430. private _streamingSource;
  98431. private _soundPanner;
  98432. private _soundGain;
  98433. private _inputAudioNode;
  98434. private _outputAudioNode;
  98435. private _coneInnerAngle;
  98436. private _coneOuterAngle;
  98437. private _coneOuterGain;
  98438. private _scene;
  98439. private _connectedTransformNode;
  98440. private _customAttenuationFunction;
  98441. private _registerFunc;
  98442. private _isOutputConnected;
  98443. private _htmlAudioElement;
  98444. private _urlType;
  98445. private _length?;
  98446. private _offset?;
  98447. /** @hidden */
  98448. static _SceneComponentInitialization: (scene: Scene) => void;
  98449. /**
  98450. * Create a sound and attach it to a scene
  98451. * @param name Name of your sound
  98452. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  98453. * @param scene defines the scene the sound belongs to
  98454. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  98455. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  98456. */
  98457. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  98458. /**
  98459. * Release the sound and its associated resources
  98460. */
  98461. dispose(): void;
  98462. /**
  98463. * Gets if the sounds is ready to be played or not.
  98464. * @returns true if ready, otherwise false
  98465. */
  98466. isReady(): boolean;
  98467. private _soundLoaded;
  98468. /**
  98469. * Sets the data of the sound from an audiobuffer
  98470. * @param audioBuffer The audioBuffer containing the data
  98471. */
  98472. setAudioBuffer(audioBuffer: AudioBuffer): void;
  98473. /**
  98474. * Updates the current sounds options such as maxdistance, loop...
  98475. * @param options A JSON object containing values named as the object properties
  98476. */
  98477. updateOptions(options: ISoundOptions): void;
  98478. private _createSpatialParameters;
  98479. private _updateSpatialParameters;
  98480. /**
  98481. * Switch the panning model to HRTF:
  98482. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98484. */
  98485. switchPanningModelToHRTF(): void;
  98486. /**
  98487. * Switch the panning model to Equal Power:
  98488. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98490. */
  98491. switchPanningModelToEqualPower(): void;
  98492. private _switchPanningModel;
  98493. /**
  98494. * Connect this sound to a sound track audio node like gain...
  98495. * @param soundTrackAudioNode the sound track audio node to connect to
  98496. */
  98497. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  98498. /**
  98499. * Transform this sound into a directional source
  98500. * @param coneInnerAngle Size of the inner cone in degree
  98501. * @param coneOuterAngle Size of the outer cone in degree
  98502. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  98503. */
  98504. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  98505. /**
  98506. * Gets or sets the inner angle for the directional cone.
  98507. */
  98508. /**
  98509. * Gets or sets the inner angle for the directional cone.
  98510. */
  98511. directionalConeInnerAngle: number;
  98512. /**
  98513. * Gets or sets the outer angle for the directional cone.
  98514. */
  98515. /**
  98516. * Gets or sets the outer angle for the directional cone.
  98517. */
  98518. directionalConeOuterAngle: number;
  98519. /**
  98520. * Sets the position of the emitter if spatial sound is enabled
  98521. * @param newPosition Defines the new posisiton
  98522. */
  98523. setPosition(newPosition: Vector3): void;
  98524. /**
  98525. * Sets the local direction of the emitter if spatial sound is enabled
  98526. * @param newLocalDirection Defines the new local direction
  98527. */
  98528. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  98529. private _updateDirection;
  98530. /** @hidden */
  98531. updateDistanceFromListener(): void;
  98532. /**
  98533. * Sets a new custom attenuation function for the sound.
  98534. * @param callback Defines the function used for the attenuation
  98535. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  98536. */
  98537. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  98538. /**
  98539. * Play the sound
  98540. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  98541. * @param offset (optional) Start the sound at a specific time in seconds
  98542. * @param length (optional) Sound duration (in seconds)
  98543. */
  98544. play(time?: number, offset?: number, length?: number): void;
  98545. private _onended;
  98546. /**
  98547. * Stop the sound
  98548. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  98549. */
  98550. stop(time?: number): void;
  98551. /**
  98552. * Put the sound in pause
  98553. */
  98554. pause(): void;
  98555. /**
  98556. * Sets a dedicated volume for this sounds
  98557. * @param newVolume Define the new volume of the sound
  98558. * @param time Define time for gradual change to new volume
  98559. */
  98560. setVolume(newVolume: number, time?: number): void;
  98561. /**
  98562. * Set the sound play back rate
  98563. * @param newPlaybackRate Define the playback rate the sound should be played at
  98564. */
  98565. setPlaybackRate(newPlaybackRate: number): void;
  98566. /**
  98567. * Gets the volume of the sound.
  98568. * @returns the volume of the sound
  98569. */
  98570. getVolume(): number;
  98571. /**
  98572. * Attach the sound to a dedicated mesh
  98573. * @param transformNode The transform node to connect the sound with
  98574. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98575. */
  98576. attachToMesh(transformNode: TransformNode): void;
  98577. /**
  98578. * Detach the sound from the previously attached mesh
  98579. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  98580. */
  98581. detachFromMesh(): void;
  98582. private _onRegisterAfterWorldMatrixUpdate;
  98583. /**
  98584. * Clone the current sound in the scene.
  98585. * @returns the new sound clone
  98586. */
  98587. clone(): Nullable<Sound>;
  98588. /**
  98589. * Gets the current underlying audio buffer containing the data
  98590. * @returns the audio buffer
  98591. */
  98592. getAudioBuffer(): Nullable<AudioBuffer>;
  98593. /**
  98594. * Serializes the Sound in a JSON representation
  98595. * @returns the JSON representation of the sound
  98596. */
  98597. serialize(): any;
  98598. /**
  98599. * Parse a JSON representation of a sound to innstantiate in a given scene
  98600. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  98601. * @param scene Define the scene the new parsed sound should be created in
  98602. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  98603. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  98604. * @returns the newly parsed sound
  98605. */
  98606. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  98607. }
  98608. }
  98609. declare module BABYLON {
  98610. /**
  98611. * This defines an action helpful to play a defined sound on a triggered action.
  98612. */
  98613. export class PlaySoundAction extends Action {
  98614. private _sound;
  98615. /**
  98616. * Instantiate the action
  98617. * @param triggerOptions defines the trigger options
  98618. * @param sound defines the sound to play
  98619. * @param condition defines the trigger related conditions
  98620. */
  98621. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98622. /** @hidden */
  98623. _prepare(): void;
  98624. /**
  98625. * Execute the action and play the sound.
  98626. */
  98627. execute(): void;
  98628. /**
  98629. * Serializes the actions and its related information.
  98630. * @param parent defines the object to serialize in
  98631. * @returns the serialized object
  98632. */
  98633. serialize(parent: any): any;
  98634. }
  98635. /**
  98636. * This defines an action helpful to stop a defined sound on a triggered action.
  98637. */
  98638. export class StopSoundAction extends Action {
  98639. private _sound;
  98640. /**
  98641. * Instantiate the action
  98642. * @param triggerOptions defines the trigger options
  98643. * @param sound defines the sound to stop
  98644. * @param condition defines the trigger related conditions
  98645. */
  98646. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  98647. /** @hidden */
  98648. _prepare(): void;
  98649. /**
  98650. * Execute the action and stop the sound.
  98651. */
  98652. execute(): void;
  98653. /**
  98654. * Serializes the actions and its related information.
  98655. * @param parent defines the object to serialize in
  98656. * @returns the serialized object
  98657. */
  98658. serialize(parent: any): any;
  98659. }
  98660. }
  98661. declare module BABYLON {
  98662. /**
  98663. * This defines an action responsible to change the value of a property
  98664. * by interpolating between its current value and the newly set one once triggered.
  98665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  98666. */
  98667. export class InterpolateValueAction extends Action {
  98668. /**
  98669. * Defines the path of the property where the value should be interpolated
  98670. */
  98671. propertyPath: string;
  98672. /**
  98673. * Defines the target value at the end of the interpolation.
  98674. */
  98675. value: any;
  98676. /**
  98677. * Defines the time it will take for the property to interpolate to the value.
  98678. */
  98679. duration: number;
  98680. /**
  98681. * Defines if the other scene animations should be stopped when the action has been triggered
  98682. */
  98683. stopOtherAnimations?: boolean;
  98684. /**
  98685. * Defines a callback raised once the interpolation animation has been done.
  98686. */
  98687. onInterpolationDone?: () => void;
  98688. /**
  98689. * Observable triggered once the interpolation animation has been done.
  98690. */
  98691. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  98692. private _target;
  98693. private _effectiveTarget;
  98694. private _property;
  98695. /**
  98696. * Instantiate the action
  98697. * @param triggerOptions defines the trigger options
  98698. * @param target defines the object containing the value to interpolate
  98699. * @param propertyPath defines the path to the property in the target object
  98700. * @param value defines the target value at the end of the interpolation
  98701. * @param duration deines the time it will take for the property to interpolate to the value.
  98702. * @param condition defines the trigger related conditions
  98703. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  98704. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  98705. */
  98706. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  98707. /** @hidden */
  98708. _prepare(): void;
  98709. /**
  98710. * Execute the action starts the value interpolation.
  98711. */
  98712. execute(): void;
  98713. /**
  98714. * Serializes the actions and its related information.
  98715. * @param parent defines the object to serialize in
  98716. * @returns the serialized object
  98717. */
  98718. serialize(parent: any): any;
  98719. }
  98720. }
  98721. declare module BABYLON {
  98722. /**
  98723. * Options allowed during the creation of a sound track.
  98724. */
  98725. export interface ISoundTrackOptions {
  98726. /**
  98727. * The volume the sound track should take during creation
  98728. */
  98729. volume?: number;
  98730. /**
  98731. * Define if the sound track is the main sound track of the scene
  98732. */
  98733. mainTrack?: boolean;
  98734. }
  98735. /**
  98736. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  98737. * It will be also used in a future release to apply effects on a specific track.
  98738. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98739. */
  98740. export class SoundTrack {
  98741. /**
  98742. * The unique identifier of the sound track in the scene.
  98743. */
  98744. id: number;
  98745. /**
  98746. * The list of sounds included in the sound track.
  98747. */
  98748. soundCollection: Array<Sound>;
  98749. private _outputAudioNode;
  98750. private _scene;
  98751. private _isMainTrack;
  98752. private _connectedAnalyser;
  98753. private _options;
  98754. private _isInitialized;
  98755. /**
  98756. * Creates a new sound track.
  98757. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  98758. * @param scene Define the scene the sound track belongs to
  98759. * @param options
  98760. */
  98761. constructor(scene: Scene, options?: ISoundTrackOptions);
  98762. private _initializeSoundTrackAudioGraph;
  98763. /**
  98764. * Release the sound track and its associated resources
  98765. */
  98766. dispose(): void;
  98767. /**
  98768. * Adds a sound to this sound track
  98769. * @param sound define the cound to add
  98770. * @ignoreNaming
  98771. */
  98772. AddSound(sound: Sound): void;
  98773. /**
  98774. * Removes a sound to this sound track
  98775. * @param sound define the cound to remove
  98776. * @ignoreNaming
  98777. */
  98778. RemoveSound(sound: Sound): void;
  98779. /**
  98780. * Set a global volume for the full sound track.
  98781. * @param newVolume Define the new volume of the sound track
  98782. */
  98783. setVolume(newVolume: number): void;
  98784. /**
  98785. * Switch the panning model to HRTF:
  98786. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  98787. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98788. */
  98789. switchPanningModelToHRTF(): void;
  98790. /**
  98791. * Switch the panning model to Equal Power:
  98792. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  98793. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  98794. */
  98795. switchPanningModelToEqualPower(): void;
  98796. /**
  98797. * Connect the sound track to an audio analyser allowing some amazing
  98798. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  98799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  98800. * @param analyser The analyser to connect to the engine
  98801. */
  98802. connectToAnalyser(analyser: Analyser): void;
  98803. }
  98804. }
  98805. declare module BABYLON {
  98806. interface AbstractScene {
  98807. /**
  98808. * The list of sounds used in the scene.
  98809. */
  98810. sounds: Nullable<Array<Sound>>;
  98811. }
  98812. interface Scene {
  98813. /**
  98814. * @hidden
  98815. * Backing field
  98816. */
  98817. _mainSoundTrack: SoundTrack;
  98818. /**
  98819. * The main sound track played by the scene.
  98820. * It cotains your primary collection of sounds.
  98821. */
  98822. mainSoundTrack: SoundTrack;
  98823. /**
  98824. * The list of sound tracks added to the scene
  98825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98826. */
  98827. soundTracks: Nullable<Array<SoundTrack>>;
  98828. /**
  98829. * Gets a sound using a given name
  98830. * @param name defines the name to search for
  98831. * @return the found sound or null if not found at all.
  98832. */
  98833. getSoundByName(name: string): Nullable<Sound>;
  98834. /**
  98835. * Gets or sets if audio support is enabled
  98836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98837. */
  98838. audioEnabled: boolean;
  98839. /**
  98840. * Gets or sets if audio will be output to headphones
  98841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98842. */
  98843. headphone: boolean;
  98844. }
  98845. /**
  98846. * Defines the sound scene component responsible to manage any sounds
  98847. * in a given scene.
  98848. */
  98849. export class AudioSceneComponent implements ISceneSerializableComponent {
  98850. /**
  98851. * The component name helpfull to identify the component in the list of scene components.
  98852. */
  98853. readonly name: string;
  98854. /**
  98855. * The scene the component belongs to.
  98856. */
  98857. scene: Scene;
  98858. private _audioEnabled;
  98859. /**
  98860. * Gets whether audio is enabled or not.
  98861. * Please use related enable/disable method to switch state.
  98862. */
  98863. readonly audioEnabled: boolean;
  98864. private _headphone;
  98865. /**
  98866. * Gets whether audio is outputing to headphone or not.
  98867. * Please use the according Switch methods to change output.
  98868. */
  98869. readonly headphone: boolean;
  98870. /**
  98871. * Creates a new instance of the component for the given scene
  98872. * @param scene Defines the scene to register the component in
  98873. */
  98874. constructor(scene: Scene);
  98875. /**
  98876. * Registers the component in a given scene
  98877. */
  98878. register(): void;
  98879. /**
  98880. * Rebuilds the elements related to this component in case of
  98881. * context lost for instance.
  98882. */
  98883. rebuild(): void;
  98884. /**
  98885. * Serializes the component data to the specified json object
  98886. * @param serializationObject The object to serialize to
  98887. */
  98888. serialize(serializationObject: any): void;
  98889. /**
  98890. * Adds all the elements from the container to the scene
  98891. * @param container the container holding the elements
  98892. */
  98893. addFromContainer(container: AbstractScene): void;
  98894. /**
  98895. * Removes all the elements in the container from the scene
  98896. * @param container contains the elements to remove
  98897. * @param dispose if the removed element should be disposed (default: false)
  98898. */
  98899. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  98900. /**
  98901. * Disposes the component and the associated ressources.
  98902. */
  98903. dispose(): void;
  98904. /**
  98905. * Disables audio in the associated scene.
  98906. */
  98907. disableAudio(): void;
  98908. /**
  98909. * Enables audio in the associated scene.
  98910. */
  98911. enableAudio(): void;
  98912. /**
  98913. * Switch audio to headphone output.
  98914. */
  98915. switchAudioModeForHeadphones(): void;
  98916. /**
  98917. * Switch audio to normal speakers.
  98918. */
  98919. switchAudioModeForNormalSpeakers(): void;
  98920. private _afterRender;
  98921. }
  98922. }
  98923. declare module BABYLON {
  98924. /**
  98925. * Wraps one or more Sound objects and selects one with random weight for playback.
  98926. */
  98927. export class WeightedSound {
  98928. /** When true a Sound will be selected and played when the current playing Sound completes. */
  98929. loop: boolean;
  98930. private _coneInnerAngle;
  98931. private _coneOuterAngle;
  98932. private _volume;
  98933. /** A Sound is currently playing. */
  98934. isPlaying: boolean;
  98935. /** A Sound is currently paused. */
  98936. isPaused: boolean;
  98937. private _sounds;
  98938. private _weights;
  98939. private _currentIndex?;
  98940. /**
  98941. * Creates a new WeightedSound from the list of sounds given.
  98942. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  98943. * @param sounds Array of Sounds that will be selected from.
  98944. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  98945. */
  98946. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  98947. /**
  98948. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  98949. */
  98950. /**
  98951. * The size of cone in degress for a directional sound in which there will be no attenuation.
  98952. */
  98953. directionalConeInnerAngle: number;
  98954. /**
  98955. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98956. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98957. */
  98958. /**
  98959. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  98960. * Listener angles between innerAngle and outerAngle will falloff linearly.
  98961. */
  98962. directionalConeOuterAngle: number;
  98963. /**
  98964. * Playback volume.
  98965. */
  98966. /**
  98967. * Playback volume.
  98968. */
  98969. volume: number;
  98970. private _onended;
  98971. /**
  98972. * Suspend playback
  98973. */
  98974. pause(): void;
  98975. /**
  98976. * Stop playback
  98977. */
  98978. stop(): void;
  98979. /**
  98980. * Start playback.
  98981. * @param startOffset Position the clip head at a specific time in seconds.
  98982. */
  98983. play(startOffset?: number): void;
  98984. }
  98985. }
  98986. declare module BABYLON {
  98987. /**
  98988. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  98989. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98990. */
  98991. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  98992. /**
  98993. * Gets the name of the behavior.
  98994. */
  98995. readonly name: string;
  98996. /**
  98997. * The easing function used by animations
  98998. */
  98999. static EasingFunction: BackEase;
  99000. /**
  99001. * The easing mode used by animations
  99002. */
  99003. static EasingMode: number;
  99004. /**
  99005. * The duration of the animation, in milliseconds
  99006. */
  99007. transitionDuration: number;
  99008. /**
  99009. * Length of the distance animated by the transition when lower radius is reached
  99010. */
  99011. lowerRadiusTransitionRange: number;
  99012. /**
  99013. * Length of the distance animated by the transition when upper radius is reached
  99014. */
  99015. upperRadiusTransitionRange: number;
  99016. private _autoTransitionRange;
  99017. /**
  99018. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99019. */
  99020. /**
  99021. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  99022. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  99023. */
  99024. autoTransitionRange: boolean;
  99025. private _attachedCamera;
  99026. private _onAfterCheckInputsObserver;
  99027. private _onMeshTargetChangedObserver;
  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 _radiusIsAnimating;
  99042. private _radiusBounceTransition;
  99043. private _animatables;
  99044. private _cachedWheelPrecision;
  99045. /**
  99046. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  99047. * @param radiusLimit The limit to check against.
  99048. * @return Bool to indicate if at limit.
  99049. */
  99050. private _isRadiusAtLimit;
  99051. /**
  99052. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  99053. * @param radiusDelta The delta by which to animate to. Can be negative.
  99054. */
  99055. private _applyBoundRadiusAnimation;
  99056. /**
  99057. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  99058. */
  99059. protected _clearAnimationLocks(): void;
  99060. /**
  99061. * Stops and removes all animations that have been applied to the camera
  99062. */
  99063. stopAllAnimations(): void;
  99064. }
  99065. }
  99066. declare module BABYLON {
  99067. /**
  99068. * 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.
  99069. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99070. */
  99071. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  99072. /**
  99073. * Gets the name of the behavior.
  99074. */
  99075. readonly name: string;
  99076. private _mode;
  99077. private _radiusScale;
  99078. private _positionScale;
  99079. private _defaultElevation;
  99080. private _elevationReturnTime;
  99081. private _elevationReturnWaitTime;
  99082. private _zoomStopsAnimation;
  99083. private _framingTime;
  99084. /**
  99085. * The easing function used by animations
  99086. */
  99087. static EasingFunction: ExponentialEase;
  99088. /**
  99089. * The easing mode used by animations
  99090. */
  99091. static EasingMode: number;
  99092. /**
  99093. * Sets the current mode used by the behavior
  99094. */
  99095. /**
  99096. * Gets current mode used by the behavior.
  99097. */
  99098. mode: number;
  99099. /**
  99100. * Sets the scale applied to the radius (1 by default)
  99101. */
  99102. /**
  99103. * Gets the scale applied to the radius
  99104. */
  99105. radiusScale: number;
  99106. /**
  99107. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99108. */
  99109. /**
  99110. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  99111. */
  99112. positionScale: number;
  99113. /**
  99114. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99115. * behaviour is triggered, in radians.
  99116. */
  99117. /**
  99118. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  99119. * behaviour is triggered, in radians.
  99120. */
  99121. defaultElevation: number;
  99122. /**
  99123. * Sets the time (in milliseconds) taken to return to the default beta position.
  99124. * Negative value indicates camera should not return to default.
  99125. */
  99126. /**
  99127. * Gets the time (in milliseconds) taken to return to the default beta position.
  99128. * Negative value indicates camera should not return to default.
  99129. */
  99130. elevationReturnTime: number;
  99131. /**
  99132. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99133. */
  99134. /**
  99135. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  99136. */
  99137. elevationReturnWaitTime: number;
  99138. /**
  99139. * Sets the flag that indicates if user zooming should stop animation.
  99140. */
  99141. /**
  99142. * Gets the flag that indicates if user zooming should stop animation.
  99143. */
  99144. zoomStopsAnimation: boolean;
  99145. /**
  99146. * Sets the transition time when framing the mesh, in milliseconds
  99147. */
  99148. /**
  99149. * Gets the transition time when framing the mesh, in milliseconds
  99150. */
  99151. framingTime: number;
  99152. /**
  99153. * Define if the behavior should automatically change the configured
  99154. * camera limits and sensibilities.
  99155. */
  99156. autoCorrectCameraLimitsAndSensibility: boolean;
  99157. private _onPrePointerObservableObserver;
  99158. private _onAfterCheckInputsObserver;
  99159. private _onMeshTargetChangedObserver;
  99160. private _attachedCamera;
  99161. private _isPointerDown;
  99162. private _lastInteractionTime;
  99163. /**
  99164. * Initializes the behavior.
  99165. */
  99166. init(): void;
  99167. /**
  99168. * Attaches the behavior to its arc rotate camera.
  99169. * @param camera Defines the camera to attach the behavior to
  99170. */
  99171. attach(camera: ArcRotateCamera): void;
  99172. /**
  99173. * Detaches the behavior from its current arc rotate camera.
  99174. */
  99175. detach(): void;
  99176. private _animatables;
  99177. private _betaIsAnimating;
  99178. private _betaTransition;
  99179. private _radiusTransition;
  99180. private _vectorTransition;
  99181. /**
  99182. * Targets the given mesh and updates zoom level accordingly.
  99183. * @param mesh The mesh to target.
  99184. * @param radius Optional. If a cached radius position already exists, overrides default.
  99185. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99186. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99187. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99188. */
  99189. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99190. /**
  99191. * Targets the given mesh with its children and updates zoom level accordingly.
  99192. * @param mesh The mesh to target.
  99193. * @param radius Optional. If a cached radius position already exists, overrides default.
  99194. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99195. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99196. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99197. */
  99198. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99199. /**
  99200. * Targets the given meshes with their children and updates zoom level accordingly.
  99201. * @param meshes The mesh to target.
  99202. * @param radius Optional. If a cached radius position already exists, overrides default.
  99203. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  99204. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99205. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99206. */
  99207. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99208. /**
  99209. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  99210. * @param minimumWorld Determines the smaller position of the bounding box extend
  99211. * @param maximumWorld Determines the bigger position of the bounding box extend
  99212. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  99213. * @param onAnimationEnd Callback triggered at the end of the framing animation
  99214. */
  99215. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  99216. /**
  99217. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  99218. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  99219. * frustum width.
  99220. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  99221. * to fully enclose the mesh in the viewing frustum.
  99222. */
  99223. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  99224. /**
  99225. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  99226. * is automatically returned to its default position (expected to be above ground plane).
  99227. */
  99228. private _maintainCameraAboveGround;
  99229. /**
  99230. * Returns the frustum slope based on the canvas ratio and camera FOV
  99231. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  99232. */
  99233. private _getFrustumSlope;
  99234. /**
  99235. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  99236. */
  99237. private _clearAnimationLocks;
  99238. /**
  99239. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  99240. */
  99241. private _applyUserInteraction;
  99242. /**
  99243. * Stops and removes all animations that have been applied to the camera
  99244. */
  99245. stopAllAnimations(): void;
  99246. /**
  99247. * Gets a value indicating if the user is moving the camera
  99248. */
  99249. readonly isUserIsMoving: boolean;
  99250. /**
  99251. * The camera can move all the way towards the mesh.
  99252. */
  99253. static IgnoreBoundsSizeMode: number;
  99254. /**
  99255. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  99256. */
  99257. static FitFrustumSidesMode: number;
  99258. }
  99259. }
  99260. declare module BABYLON {
  99261. /**
  99262. * Base class for Camera Pointer Inputs.
  99263. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  99264. * for example usage.
  99265. */
  99266. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  99267. /**
  99268. * Defines the camera the input is attached to.
  99269. */
  99270. abstract camera: Camera;
  99271. /**
  99272. * Whether keyboard modifier keys are pressed at time of last mouse event.
  99273. */
  99274. protected _altKey: boolean;
  99275. protected _ctrlKey: boolean;
  99276. protected _metaKey: boolean;
  99277. protected _shiftKey: boolean;
  99278. /**
  99279. * Which mouse buttons were pressed at time of last mouse event.
  99280. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  99281. */
  99282. protected _buttonsPressed: number;
  99283. /**
  99284. * Defines the buttons associated with the input to handle camera move.
  99285. */
  99286. buttons: number[];
  99287. /**
  99288. * Attach the input controls to a specific dom element to get the input from.
  99289. * @param element Defines the element the controls should be listened from
  99290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99291. */
  99292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99293. /**
  99294. * Detach the current controls from the specified dom element.
  99295. * @param element Defines the element to stop listening the inputs from
  99296. */
  99297. detachControl(element: Nullable<HTMLElement>): void;
  99298. /**
  99299. * Gets the class name of the current input.
  99300. * @returns the class name
  99301. */
  99302. getClassName(): string;
  99303. /**
  99304. * Get the friendly name associated with the input class.
  99305. * @returns the input friendly name
  99306. */
  99307. getSimpleName(): string;
  99308. /**
  99309. * Called on pointer POINTERDOUBLETAP event.
  99310. * Override this method to provide functionality on POINTERDOUBLETAP event.
  99311. */
  99312. protected onDoubleTap(type: string): void;
  99313. /**
  99314. * Called on pointer POINTERMOVE event if only a single touch is active.
  99315. * Override this method to provide functionality.
  99316. */
  99317. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99318. /**
  99319. * Called on pointer POINTERMOVE event if multiple touches are active.
  99320. * Override this method to provide functionality.
  99321. */
  99322. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99323. /**
  99324. * Called on JS contextmenu event.
  99325. * Override this method to provide functionality.
  99326. */
  99327. protected onContextMenu(evt: PointerEvent): void;
  99328. /**
  99329. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99330. * press.
  99331. * Override this method to provide functionality.
  99332. */
  99333. protected onButtonDown(evt: PointerEvent): void;
  99334. /**
  99335. * Called each time a new POINTERUP event occurs. Ie, for each button
  99336. * release.
  99337. * Override this method to provide functionality.
  99338. */
  99339. protected onButtonUp(evt: PointerEvent): void;
  99340. /**
  99341. * Called when window becomes inactive.
  99342. * Override this method to provide functionality.
  99343. */
  99344. protected onLostFocus(): void;
  99345. private _pointerInput;
  99346. private _observer;
  99347. private _onLostFocus;
  99348. private pointA;
  99349. private pointB;
  99350. }
  99351. }
  99352. declare module BABYLON {
  99353. /**
  99354. * Manage the pointers inputs to control an arc rotate camera.
  99355. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99356. */
  99357. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  99358. /**
  99359. * Defines the camera the input is attached to.
  99360. */
  99361. camera: ArcRotateCamera;
  99362. /**
  99363. * Gets the class name of the current input.
  99364. * @returns the class name
  99365. */
  99366. getClassName(): string;
  99367. /**
  99368. * Defines the buttons associated with the input to handle camera move.
  99369. */
  99370. buttons: number[];
  99371. /**
  99372. * Defines the pointer angular sensibility along the X axis or how fast is
  99373. * the camera rotating.
  99374. */
  99375. angularSensibilityX: number;
  99376. /**
  99377. * Defines the pointer angular sensibility along the Y axis or how fast is
  99378. * the camera rotating.
  99379. */
  99380. angularSensibilityY: number;
  99381. /**
  99382. * Defines the pointer pinch precision or how fast is the camera zooming.
  99383. */
  99384. pinchPrecision: number;
  99385. /**
  99386. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99387. * from 0.
  99388. * It defines the percentage of current camera.radius to use as delta when
  99389. * pinch zoom is used.
  99390. */
  99391. pinchDeltaPercentage: number;
  99392. /**
  99393. * Defines the pointer panning sensibility or how fast is the camera moving.
  99394. */
  99395. panningSensibility: number;
  99396. /**
  99397. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  99398. */
  99399. multiTouchPanning: boolean;
  99400. /**
  99401. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  99402. * zoom (pinch) through multitouch.
  99403. */
  99404. multiTouchPanAndZoom: boolean;
  99405. /**
  99406. * Revers pinch action direction.
  99407. */
  99408. pinchInwards: boolean;
  99409. private _isPanClick;
  99410. private _twoFingerActivityCount;
  99411. private _isPinching;
  99412. /**
  99413. * Called on pointer POINTERMOVE event if only a single touch is active.
  99414. */
  99415. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99416. /**
  99417. * Called on pointer POINTERDOUBLETAP event.
  99418. */
  99419. protected onDoubleTap(type: string): void;
  99420. /**
  99421. * Called on pointer POINTERMOVE event if multiple touches are active.
  99422. */
  99423. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99424. /**
  99425. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  99426. * press.
  99427. */
  99428. protected onButtonDown(evt: PointerEvent): void;
  99429. /**
  99430. * Called each time a new POINTERUP event occurs. Ie, for each button
  99431. * release.
  99432. */
  99433. protected onButtonUp(evt: PointerEvent): void;
  99434. /**
  99435. * Called when window becomes inactive.
  99436. */
  99437. protected onLostFocus(): void;
  99438. }
  99439. }
  99440. declare module BABYLON {
  99441. /**
  99442. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  99443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99444. */
  99445. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  99446. /**
  99447. * Defines the camera the input is attached to.
  99448. */
  99449. camera: ArcRotateCamera;
  99450. /**
  99451. * Defines the list of key codes associated with the up action (increase alpha)
  99452. */
  99453. keysUp: number[];
  99454. /**
  99455. * Defines the list of key codes associated with the down action (decrease alpha)
  99456. */
  99457. keysDown: number[];
  99458. /**
  99459. * Defines the list of key codes associated with the left action (increase beta)
  99460. */
  99461. keysLeft: number[];
  99462. /**
  99463. * Defines the list of key codes associated with the right action (decrease beta)
  99464. */
  99465. keysRight: number[];
  99466. /**
  99467. * Defines the list of key codes associated with the reset action.
  99468. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  99469. */
  99470. keysReset: number[];
  99471. /**
  99472. * Defines the panning sensibility of the inputs.
  99473. * (How fast is the camera paning)
  99474. */
  99475. panningSensibility: number;
  99476. /**
  99477. * Defines the zooming sensibility of the inputs.
  99478. * (How fast is the camera zooming)
  99479. */
  99480. zoomingSensibility: number;
  99481. /**
  99482. * Defines wether maintaining the alt key down switch the movement mode from
  99483. * orientation to zoom.
  99484. */
  99485. useAltToZoom: boolean;
  99486. /**
  99487. * Rotation speed of the camera
  99488. */
  99489. angularSpeed: number;
  99490. private _keys;
  99491. private _ctrlPressed;
  99492. private _altPressed;
  99493. private _onCanvasBlurObserver;
  99494. private _onKeyboardObserver;
  99495. private _engine;
  99496. private _scene;
  99497. /**
  99498. * Attach the input controls to a specific dom element to get the input from.
  99499. * @param element Defines the element the controls should be listened from
  99500. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99501. */
  99502. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99503. /**
  99504. * Detach the current controls from the specified dom element.
  99505. * @param element Defines the element to stop listening the inputs from
  99506. */
  99507. detachControl(element: Nullable<HTMLElement>): void;
  99508. /**
  99509. * Update the current camera state depending on the inputs that have been used this frame.
  99510. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99511. */
  99512. checkInputs(): void;
  99513. /**
  99514. * Gets the class name of the current intput.
  99515. * @returns the class name
  99516. */
  99517. getClassName(): string;
  99518. /**
  99519. * Get the friendly name associated with the input class.
  99520. * @returns the input friendly name
  99521. */
  99522. getSimpleName(): string;
  99523. }
  99524. }
  99525. declare module BABYLON {
  99526. /**
  99527. * Manage the mouse wheel inputs to control an arc rotate camera.
  99528. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99529. */
  99530. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  99531. /**
  99532. * Defines the camera the input is attached to.
  99533. */
  99534. camera: ArcRotateCamera;
  99535. /**
  99536. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99537. */
  99538. wheelPrecision: number;
  99539. /**
  99540. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99541. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99542. */
  99543. wheelDeltaPercentage: number;
  99544. private _wheel;
  99545. private _observer;
  99546. private computeDeltaFromMouseWheelLegacyEvent;
  99547. /**
  99548. * Attach the input controls to a specific dom element to get the input from.
  99549. * @param element Defines the element the controls should be listened from
  99550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99551. */
  99552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99553. /**
  99554. * Detach the current controls from the specified dom element.
  99555. * @param element Defines the element to stop listening the inputs from
  99556. */
  99557. detachControl(element: Nullable<HTMLElement>): void;
  99558. /**
  99559. * Gets the class name of the current intput.
  99560. * @returns the class name
  99561. */
  99562. getClassName(): string;
  99563. /**
  99564. * Get the friendly name associated with the input class.
  99565. * @returns the input friendly name
  99566. */
  99567. getSimpleName(): string;
  99568. }
  99569. }
  99570. declare module BABYLON {
  99571. /**
  99572. * Default Inputs manager for the ArcRotateCamera.
  99573. * It groups all the default supported inputs for ease of use.
  99574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99575. */
  99576. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  99577. /**
  99578. * Instantiates a new ArcRotateCameraInputsManager.
  99579. * @param camera Defines the camera the inputs belong to
  99580. */
  99581. constructor(camera: ArcRotateCamera);
  99582. /**
  99583. * Add mouse wheel input support to the input manager.
  99584. * @returns the current input manager
  99585. */
  99586. addMouseWheel(): ArcRotateCameraInputsManager;
  99587. /**
  99588. * Add pointers input support to the input manager.
  99589. * @returns the current input manager
  99590. */
  99591. addPointers(): ArcRotateCameraInputsManager;
  99592. /**
  99593. * Add keyboard input support to the input manager.
  99594. * @returns the current input manager
  99595. */
  99596. addKeyboard(): ArcRotateCameraInputsManager;
  99597. }
  99598. }
  99599. declare module BABYLON {
  99600. /**
  99601. * This represents an orbital type of camera.
  99602. *
  99603. * 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.
  99604. * 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.
  99605. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  99606. */
  99607. export class ArcRotateCamera extends TargetCamera {
  99608. /**
  99609. * Defines the rotation angle of the camera along the longitudinal axis.
  99610. */
  99611. alpha: number;
  99612. /**
  99613. * Defines the rotation angle of the camera along the latitudinal axis.
  99614. */
  99615. beta: number;
  99616. /**
  99617. * Defines the radius of the camera from it s target point.
  99618. */
  99619. radius: number;
  99620. protected _target: Vector3;
  99621. protected _targetHost: Nullable<AbstractMesh>;
  99622. /**
  99623. * Defines the target point of the camera.
  99624. * The camera looks towards it form the radius distance.
  99625. */
  99626. target: Vector3;
  99627. /**
  99628. * Define the current local position of the camera in the scene
  99629. */
  99630. position: Vector3;
  99631. protected _upVector: Vector3;
  99632. protected _upToYMatrix: Matrix;
  99633. protected _YToUpMatrix: Matrix;
  99634. /**
  99635. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  99636. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  99637. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  99638. */
  99639. upVector: Vector3;
  99640. /**
  99641. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  99642. */
  99643. setMatUp(): void;
  99644. /**
  99645. * Current inertia value on the longitudinal axis.
  99646. * The bigger this number the longer it will take for the camera to stop.
  99647. */
  99648. inertialAlphaOffset: number;
  99649. /**
  99650. * Current inertia value on the latitudinal axis.
  99651. * The bigger this number the longer it will take for the camera to stop.
  99652. */
  99653. inertialBetaOffset: number;
  99654. /**
  99655. * Current inertia value on the radius axis.
  99656. * The bigger this number the longer it will take for the camera to stop.
  99657. */
  99658. inertialRadiusOffset: number;
  99659. /**
  99660. * Minimum allowed angle on the longitudinal axis.
  99661. * This can help limiting how the Camera is able to move in the scene.
  99662. */
  99663. lowerAlphaLimit: Nullable<number>;
  99664. /**
  99665. * Maximum allowed angle on the longitudinal axis.
  99666. * This can help limiting how the Camera is able to move in the scene.
  99667. */
  99668. upperAlphaLimit: Nullable<number>;
  99669. /**
  99670. * Minimum allowed angle on the latitudinal axis.
  99671. * This can help limiting how the Camera is able to move in the scene.
  99672. */
  99673. lowerBetaLimit: number;
  99674. /**
  99675. * Maximum allowed angle on the latitudinal axis.
  99676. * This can help limiting how the Camera is able to move in the scene.
  99677. */
  99678. upperBetaLimit: number;
  99679. /**
  99680. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  99681. * This can help limiting how the Camera is able to move in the scene.
  99682. */
  99683. lowerRadiusLimit: Nullable<number>;
  99684. /**
  99685. * Maximum allowed distance of the camera to the target (The camera can not get further).
  99686. * This can help limiting how the Camera is able to move in the scene.
  99687. */
  99688. upperRadiusLimit: Nullable<number>;
  99689. /**
  99690. * Defines the current inertia value used during panning of the camera along the X axis.
  99691. */
  99692. inertialPanningX: number;
  99693. /**
  99694. * Defines the current inertia value used during panning of the camera along the Y axis.
  99695. */
  99696. inertialPanningY: number;
  99697. /**
  99698. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  99699. * Basically if your fingers moves away from more than this distance you will be considered
  99700. * in pinch mode.
  99701. */
  99702. pinchToPanMaxDistance: number;
  99703. /**
  99704. * Defines the maximum distance the camera can pan.
  99705. * This could help keeping the cammera always in your scene.
  99706. */
  99707. panningDistanceLimit: Nullable<number>;
  99708. /**
  99709. * Defines the target of the camera before paning.
  99710. */
  99711. panningOriginTarget: Vector3;
  99712. /**
  99713. * Defines the value of the inertia used during panning.
  99714. * 0 would mean stop inertia and one would mean no decelleration at all.
  99715. */
  99716. panningInertia: number;
  99717. /**
  99718. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  99719. */
  99720. angularSensibilityX: number;
  99721. /**
  99722. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  99723. */
  99724. angularSensibilityY: number;
  99725. /**
  99726. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  99727. */
  99728. pinchPrecision: number;
  99729. /**
  99730. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  99731. * It will be used instead of pinchDeltaPrecision if different from 0.
  99732. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99733. */
  99734. pinchDeltaPercentage: number;
  99735. /**
  99736. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  99737. */
  99738. panningSensibility: number;
  99739. /**
  99740. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  99741. */
  99742. keysUp: number[];
  99743. /**
  99744. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  99745. */
  99746. keysDown: number[];
  99747. /**
  99748. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  99749. */
  99750. keysLeft: number[];
  99751. /**
  99752. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  99753. */
  99754. keysRight: number[];
  99755. /**
  99756. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  99757. */
  99758. wheelPrecision: number;
  99759. /**
  99760. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  99761. * It will be used instead of pinchDeltaPrecision if different from 0.
  99762. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  99763. */
  99764. wheelDeltaPercentage: number;
  99765. /**
  99766. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  99767. */
  99768. zoomOnFactor: number;
  99769. /**
  99770. * Defines a screen offset for the camera position.
  99771. */
  99772. targetScreenOffset: Vector2;
  99773. /**
  99774. * Allows the camera to be completely reversed.
  99775. * If false the camera can not arrive upside down.
  99776. */
  99777. allowUpsideDown: boolean;
  99778. /**
  99779. * Define if double tap/click is used to restore the previously saved state of the camera.
  99780. */
  99781. useInputToRestoreState: boolean;
  99782. /** @hidden */
  99783. _viewMatrix: Matrix;
  99784. /** @hidden */
  99785. _useCtrlForPanning: boolean;
  99786. /** @hidden */
  99787. _panningMouseButton: number;
  99788. /**
  99789. * Defines the input associated to the camera.
  99790. */
  99791. inputs: ArcRotateCameraInputsManager;
  99792. /** @hidden */
  99793. _reset: () => void;
  99794. /**
  99795. * Defines the allowed panning axis.
  99796. */
  99797. panningAxis: Vector3;
  99798. protected _localDirection: Vector3;
  99799. protected _transformedDirection: Vector3;
  99800. private _bouncingBehavior;
  99801. /**
  99802. * Gets the bouncing behavior of the camera if it has been enabled.
  99803. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99804. */
  99805. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  99806. /**
  99807. * Defines if the bouncing behavior of the camera is enabled on the camera.
  99808. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  99809. */
  99810. useBouncingBehavior: boolean;
  99811. private _framingBehavior;
  99812. /**
  99813. * Gets the framing behavior of the camera if it has been enabled.
  99814. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99815. */
  99816. readonly framingBehavior: Nullable<FramingBehavior>;
  99817. /**
  99818. * Defines if the framing behavior of the camera is enabled on the camera.
  99819. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  99820. */
  99821. useFramingBehavior: boolean;
  99822. private _autoRotationBehavior;
  99823. /**
  99824. * Gets the auto rotation behavior of the camera if it has been enabled.
  99825. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99826. */
  99827. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  99828. /**
  99829. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  99830. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99831. */
  99832. useAutoRotationBehavior: boolean;
  99833. /**
  99834. * Observable triggered when the mesh target has been changed on the camera.
  99835. */
  99836. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  99837. /**
  99838. * Event raised when the camera is colliding with a mesh.
  99839. */
  99840. onCollide: (collidedMesh: AbstractMesh) => void;
  99841. /**
  99842. * Defines whether the camera should check collision with the objects oh the scene.
  99843. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  99844. */
  99845. checkCollisions: boolean;
  99846. /**
  99847. * Defines the collision radius of the camera.
  99848. * This simulates a sphere around the camera.
  99849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99850. */
  99851. collisionRadius: Vector3;
  99852. protected _collider: Collider;
  99853. protected _previousPosition: Vector3;
  99854. protected _collisionVelocity: Vector3;
  99855. protected _newPosition: Vector3;
  99856. protected _previousAlpha: number;
  99857. protected _previousBeta: number;
  99858. protected _previousRadius: number;
  99859. protected _collisionTriggered: boolean;
  99860. protected _targetBoundingCenter: Nullable<Vector3>;
  99861. private _computationVector;
  99862. /**
  99863. * Instantiates a new ArcRotateCamera in a given scene
  99864. * @param name Defines the name of the camera
  99865. * @param alpha Defines the camera rotation along the logitudinal axis
  99866. * @param beta Defines the camera rotation along the latitudinal axis
  99867. * @param radius Defines the camera distance from its target
  99868. * @param target Defines the camera target
  99869. * @param scene Defines the scene the camera belongs to
  99870. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99871. */
  99872. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99873. /** @hidden */
  99874. _initCache(): void;
  99875. /** @hidden */
  99876. _updateCache(ignoreParentClass?: boolean): void;
  99877. protected _getTargetPosition(): Vector3;
  99878. private _storedAlpha;
  99879. private _storedBeta;
  99880. private _storedRadius;
  99881. private _storedTarget;
  99882. /**
  99883. * Stores the current state of the camera (alpha, beta, radius and target)
  99884. * @returns the camera itself
  99885. */
  99886. storeState(): Camera;
  99887. /**
  99888. * @hidden
  99889. * Restored camera state. You must call storeState() first
  99890. */
  99891. _restoreStateValues(): boolean;
  99892. /** @hidden */
  99893. _isSynchronizedViewMatrix(): boolean;
  99894. /**
  99895. * Attached controls to the current camera.
  99896. * @param element Defines the element the controls should be listened from
  99897. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99898. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  99899. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  99900. */
  99901. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  99902. /**
  99903. * Detach the current controls from the camera.
  99904. * The camera will stop reacting to inputs.
  99905. * @param element Defines the element to stop listening the inputs from
  99906. */
  99907. detachControl(element: HTMLElement): void;
  99908. /** @hidden */
  99909. _checkInputs(): void;
  99910. protected _checkLimits(): void;
  99911. /**
  99912. * Rebuilds angles (alpha, beta) and radius from the give position and target
  99913. */
  99914. rebuildAnglesAndRadius(): void;
  99915. /**
  99916. * Use a position to define the current camera related information like aplha, beta and radius
  99917. * @param position Defines the position to set the camera at
  99918. */
  99919. setPosition(position: Vector3): void;
  99920. /**
  99921. * Defines the target the camera should look at.
  99922. * This will automatically adapt alpha beta and radius to fit within the new target.
  99923. * @param target Defines the new target as a Vector or a mesh
  99924. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  99925. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  99926. */
  99927. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  99928. /** @hidden */
  99929. _getViewMatrix(): Matrix;
  99930. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  99931. /**
  99932. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  99933. * @param meshes Defines the mesh to zoom on
  99934. * @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)
  99935. */
  99936. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  99937. /**
  99938. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  99939. * The target will be changed but the radius
  99940. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  99941. * @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)
  99942. */
  99943. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  99944. min: Vector3;
  99945. max: Vector3;
  99946. distance: number;
  99947. }, doNotUpdateMaxZ?: boolean): void;
  99948. /**
  99949. * @override
  99950. * Override Camera.createRigCamera
  99951. */
  99952. createRigCamera(name: string, cameraIndex: number): Camera;
  99953. /**
  99954. * @hidden
  99955. * @override
  99956. * Override Camera._updateRigCameras
  99957. */
  99958. _updateRigCameras(): void;
  99959. /**
  99960. * Destroy the camera and release the current resources hold by it.
  99961. */
  99962. dispose(): void;
  99963. /**
  99964. * Gets the current object class name.
  99965. * @return the class name
  99966. */
  99967. getClassName(): string;
  99968. }
  99969. }
  99970. declare module BABYLON {
  99971. /**
  99972. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  99973. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  99974. */
  99975. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  99976. /**
  99977. * Gets the name of the behavior.
  99978. */
  99979. readonly name: string;
  99980. private _zoomStopsAnimation;
  99981. private _idleRotationSpeed;
  99982. private _idleRotationWaitTime;
  99983. private _idleRotationSpinupTime;
  99984. /**
  99985. * Sets the flag that indicates if user zooming should stop animation.
  99986. */
  99987. /**
  99988. * Gets the flag that indicates if user zooming should stop animation.
  99989. */
  99990. zoomStopsAnimation: boolean;
  99991. /**
  99992. * Sets the default speed at which the camera rotates around the model.
  99993. */
  99994. /**
  99995. * Gets the default speed at which the camera rotates around the model.
  99996. */
  99997. idleRotationSpeed: number;
  99998. /**
  99999. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  100000. */
  100001. /**
  100002. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  100003. */
  100004. idleRotationWaitTime: number;
  100005. /**
  100006. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100007. */
  100008. /**
  100009. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  100010. */
  100011. idleRotationSpinupTime: number;
  100012. /**
  100013. * Gets a value indicating if the camera is currently rotating because of this behavior
  100014. */
  100015. readonly rotationInProgress: boolean;
  100016. private _onPrePointerObservableObserver;
  100017. private _onAfterCheckInputsObserver;
  100018. private _attachedCamera;
  100019. private _isPointerDown;
  100020. private _lastFrameTime;
  100021. private _lastInteractionTime;
  100022. private _cameraRotationSpeed;
  100023. /**
  100024. * Initializes the behavior.
  100025. */
  100026. init(): void;
  100027. /**
  100028. * Attaches the behavior to its arc rotate camera.
  100029. * @param camera Defines the camera to attach the behavior to
  100030. */
  100031. attach(camera: ArcRotateCamera): void;
  100032. /**
  100033. * Detaches the behavior from its current arc rotate camera.
  100034. */
  100035. detach(): void;
  100036. /**
  100037. * Returns true if user is scrolling.
  100038. * @return true if user is scrolling.
  100039. */
  100040. private _userIsZooming;
  100041. private _lastFrameRadius;
  100042. private _shouldAnimationStopForInteraction;
  100043. /**
  100044. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  100045. */
  100046. private _applyUserInteraction;
  100047. private _userIsMoving;
  100048. }
  100049. }
  100050. declare module BABYLON {
  100051. /**
  100052. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  100053. */
  100054. export class AttachToBoxBehavior implements Behavior<Mesh> {
  100055. private ui;
  100056. /**
  100057. * The name of the behavior
  100058. */
  100059. name: string;
  100060. /**
  100061. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  100062. */
  100063. distanceAwayFromFace: number;
  100064. /**
  100065. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  100066. */
  100067. distanceAwayFromBottomOfFace: number;
  100068. private _faceVectors;
  100069. private _target;
  100070. private _scene;
  100071. private _onRenderObserver;
  100072. private _tmpMatrix;
  100073. private _tmpVector;
  100074. /**
  100075. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  100076. * @param ui The transform node that should be attched to the mesh
  100077. */
  100078. constructor(ui: TransformNode);
  100079. /**
  100080. * Initializes the behavior
  100081. */
  100082. init(): void;
  100083. private _closestFace;
  100084. private _zeroVector;
  100085. private _lookAtTmpMatrix;
  100086. private _lookAtToRef;
  100087. /**
  100088. * Attaches the AttachToBoxBehavior to the passed in mesh
  100089. * @param target The mesh that the specified node will be attached to
  100090. */
  100091. attach(target: Mesh): void;
  100092. /**
  100093. * Detaches the behavior from the mesh
  100094. */
  100095. detach(): void;
  100096. }
  100097. }
  100098. declare module BABYLON {
  100099. /**
  100100. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  100101. */
  100102. export class FadeInOutBehavior implements Behavior<Mesh> {
  100103. /**
  100104. * Time in milliseconds to delay before fading in (Default: 0)
  100105. */
  100106. delay: number;
  100107. /**
  100108. * Time in milliseconds for the mesh to fade in (Default: 300)
  100109. */
  100110. fadeInTime: number;
  100111. private _millisecondsPerFrame;
  100112. private _hovered;
  100113. private _hoverValue;
  100114. private _ownerNode;
  100115. /**
  100116. * Instatiates the FadeInOutBehavior
  100117. */
  100118. constructor();
  100119. /**
  100120. * The name of the behavior
  100121. */
  100122. readonly name: string;
  100123. /**
  100124. * Initializes the behavior
  100125. */
  100126. init(): void;
  100127. /**
  100128. * Attaches the fade behavior on the passed in mesh
  100129. * @param ownerNode The mesh that will be faded in/out once attached
  100130. */
  100131. attach(ownerNode: Mesh): void;
  100132. /**
  100133. * Detaches the behavior from the mesh
  100134. */
  100135. detach(): void;
  100136. /**
  100137. * Triggers the mesh to begin fading in or out
  100138. * @param value if the object should fade in or out (true to fade in)
  100139. */
  100140. fadeIn(value: boolean): void;
  100141. private _update;
  100142. private _setAllVisibility;
  100143. }
  100144. }
  100145. declare module BABYLON {
  100146. /**
  100147. * Class containing a set of static utilities functions for managing Pivots
  100148. * @hidden
  100149. */
  100150. export class PivotTools {
  100151. private static _PivotCached;
  100152. private static _OldPivotPoint;
  100153. private static _PivotTranslation;
  100154. private static _PivotTmpVector;
  100155. /** @hidden */
  100156. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  100157. /** @hidden */
  100158. static _RestorePivotPoint(mesh: AbstractMesh): void;
  100159. }
  100160. }
  100161. declare module BABYLON {
  100162. /**
  100163. * Class containing static functions to help procedurally build meshes
  100164. */
  100165. export class PlaneBuilder {
  100166. /**
  100167. * Creates a plane mesh
  100168. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  100169. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  100170. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  100171. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100173. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100174. * @param name defines the name of the mesh
  100175. * @param options defines the options used to create the mesh
  100176. * @param scene defines the hosting scene
  100177. * @returns the plane mesh
  100178. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  100179. */
  100180. static CreatePlane(name: string, options: {
  100181. size?: number;
  100182. width?: number;
  100183. height?: number;
  100184. sideOrientation?: number;
  100185. frontUVs?: Vector4;
  100186. backUVs?: Vector4;
  100187. updatable?: boolean;
  100188. sourcePlane?: Plane;
  100189. }, scene?: Nullable<Scene>): Mesh;
  100190. }
  100191. }
  100192. declare module BABYLON {
  100193. /**
  100194. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  100195. */
  100196. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  100197. private static _AnyMouseID;
  100198. /**
  100199. * Abstract mesh the behavior is set on
  100200. */
  100201. attachedNode: AbstractMesh;
  100202. private _dragPlane;
  100203. private _scene;
  100204. private _pointerObserver;
  100205. private _beforeRenderObserver;
  100206. private static _planeScene;
  100207. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  100208. /**
  100209. * 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)
  100210. */
  100211. maxDragAngle: number;
  100212. /**
  100213. * @hidden
  100214. */
  100215. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  100216. /**
  100217. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100218. */
  100219. currentDraggingPointerID: number;
  100220. /**
  100221. * The last position where the pointer hit the drag plane in world space
  100222. */
  100223. lastDragPosition: Vector3;
  100224. /**
  100225. * If the behavior is currently in a dragging state
  100226. */
  100227. dragging: boolean;
  100228. /**
  100229. * 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)
  100230. */
  100231. dragDeltaRatio: number;
  100232. /**
  100233. * If the drag plane orientation should be updated during the dragging (Default: true)
  100234. */
  100235. updateDragPlane: boolean;
  100236. private _debugMode;
  100237. private _moving;
  100238. /**
  100239. * Fires each time the attached mesh is dragged with the pointer
  100240. * * delta between last drag position and current drag position in world space
  100241. * * dragDistance along the drag axis
  100242. * * dragPlaneNormal normal of the current drag plane used during the drag
  100243. * * dragPlanePoint in world space where the drag intersects the drag plane
  100244. */
  100245. onDragObservable: Observable<{
  100246. delta: Vector3;
  100247. dragPlanePoint: Vector3;
  100248. dragPlaneNormal: Vector3;
  100249. dragDistance: number;
  100250. pointerId: number;
  100251. }>;
  100252. /**
  100253. * Fires each time a drag begins (eg. mouse down on mesh)
  100254. */
  100255. onDragStartObservable: Observable<{
  100256. dragPlanePoint: Vector3;
  100257. pointerId: number;
  100258. }>;
  100259. /**
  100260. * Fires each time a drag ends (eg. mouse release after drag)
  100261. */
  100262. onDragEndObservable: Observable<{
  100263. dragPlanePoint: Vector3;
  100264. pointerId: number;
  100265. }>;
  100266. /**
  100267. * If the attached mesh should be moved when dragged
  100268. */
  100269. moveAttached: boolean;
  100270. /**
  100271. * If the drag behavior will react to drag events (Default: true)
  100272. */
  100273. enabled: boolean;
  100274. /**
  100275. * If pointer events should start and release the drag (Default: true)
  100276. */
  100277. startAndReleaseDragOnPointerEvents: boolean;
  100278. /**
  100279. * If camera controls should be detached during the drag
  100280. */
  100281. detachCameraControls: boolean;
  100282. /**
  100283. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  100284. */
  100285. useObjectOrienationForDragging: boolean;
  100286. private _options;
  100287. /**
  100288. * Creates a pointer drag behavior that can be attached to a mesh
  100289. * @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)
  100290. */
  100291. constructor(options?: {
  100292. dragAxis?: Vector3;
  100293. dragPlaneNormal?: Vector3;
  100294. });
  100295. /**
  100296. * Predicate to determine if it is valid to move the object to a new position when it is moved
  100297. */
  100298. validateDrag: (targetPosition: Vector3) => boolean;
  100299. /**
  100300. * The name of the behavior
  100301. */
  100302. readonly name: string;
  100303. /**
  100304. * Initializes the behavior
  100305. */
  100306. init(): void;
  100307. private _tmpVector;
  100308. private _alternatePickedPoint;
  100309. private _worldDragAxis;
  100310. private _targetPosition;
  100311. private _attachedElement;
  100312. /**
  100313. * Attaches the drag behavior the passed in mesh
  100314. * @param ownerNode The mesh that will be dragged around once attached
  100315. */
  100316. attach(ownerNode: AbstractMesh): void;
  100317. /**
  100318. * Force relase the drag action by code.
  100319. */
  100320. releaseDrag(): void;
  100321. private _startDragRay;
  100322. private _lastPointerRay;
  100323. /**
  100324. * Simulates the start of a pointer drag event on the behavior
  100325. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  100326. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  100327. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  100328. */
  100329. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  100330. private _startDrag;
  100331. private _dragDelta;
  100332. private _moveDrag;
  100333. private _pickWithRayOnDragPlane;
  100334. private _pointA;
  100335. private _pointB;
  100336. private _pointC;
  100337. private _lineA;
  100338. private _lineB;
  100339. private _localAxis;
  100340. private _lookAt;
  100341. private _updateDragPlanePosition;
  100342. /**
  100343. * Detaches the behavior from the mesh
  100344. */
  100345. detach(): void;
  100346. }
  100347. }
  100348. declare module BABYLON {
  100349. /**
  100350. * A behavior that when attached to a mesh will allow the mesh to be scaled
  100351. */
  100352. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  100353. private _dragBehaviorA;
  100354. private _dragBehaviorB;
  100355. private _startDistance;
  100356. private _initialScale;
  100357. private _targetScale;
  100358. private _ownerNode;
  100359. private _sceneRenderObserver;
  100360. /**
  100361. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  100362. */
  100363. constructor();
  100364. /**
  100365. * The name of the behavior
  100366. */
  100367. readonly name: string;
  100368. /**
  100369. * Initializes the behavior
  100370. */
  100371. init(): void;
  100372. private _getCurrentDistance;
  100373. /**
  100374. * Attaches the scale behavior the passed in mesh
  100375. * @param ownerNode The mesh that will be scaled around once attached
  100376. */
  100377. attach(ownerNode: Mesh): void;
  100378. /**
  100379. * Detaches the behavior from the mesh
  100380. */
  100381. detach(): void;
  100382. }
  100383. }
  100384. declare module BABYLON {
  100385. /**
  100386. * 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
  100387. */
  100388. export class SixDofDragBehavior implements Behavior<Mesh> {
  100389. private static _virtualScene;
  100390. private _ownerNode;
  100391. private _sceneRenderObserver;
  100392. private _scene;
  100393. private _targetPosition;
  100394. private _virtualOriginMesh;
  100395. private _virtualDragMesh;
  100396. private _pointerObserver;
  100397. private _moving;
  100398. private _startingOrientation;
  100399. /**
  100400. * 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)
  100401. */
  100402. private zDragFactor;
  100403. /**
  100404. * If the object should rotate to face the drag origin
  100405. */
  100406. rotateDraggedObject: boolean;
  100407. /**
  100408. * If the behavior is currently in a dragging state
  100409. */
  100410. dragging: boolean;
  100411. /**
  100412. * 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)
  100413. */
  100414. dragDeltaRatio: number;
  100415. /**
  100416. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  100417. */
  100418. currentDraggingPointerID: number;
  100419. /**
  100420. * If camera controls should be detached during the drag
  100421. */
  100422. detachCameraControls: boolean;
  100423. /**
  100424. * Fires each time a drag starts
  100425. */
  100426. onDragStartObservable: Observable<{}>;
  100427. /**
  100428. * Fires each time a drag ends (eg. mouse release after drag)
  100429. */
  100430. onDragEndObservable: Observable<{}>;
  100431. /**
  100432. * 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
  100433. */
  100434. constructor();
  100435. /**
  100436. * The name of the behavior
  100437. */
  100438. readonly name: string;
  100439. /**
  100440. * Initializes the behavior
  100441. */
  100442. init(): void;
  100443. /**
  100444. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  100445. */
  100446. private readonly _pointerCamera;
  100447. /**
  100448. * Attaches the scale behavior the passed in mesh
  100449. * @param ownerNode The mesh that will be scaled around once attached
  100450. */
  100451. attach(ownerNode: Mesh): void;
  100452. /**
  100453. * Detaches the behavior from the mesh
  100454. */
  100455. detach(): void;
  100456. }
  100457. }
  100458. declare module BABYLON {
  100459. /**
  100460. * Class used to apply inverse kinematics to bones
  100461. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  100462. */
  100463. export class BoneIKController {
  100464. private static _tmpVecs;
  100465. private static _tmpQuat;
  100466. private static _tmpMats;
  100467. /**
  100468. * Gets or sets the target mesh
  100469. */
  100470. targetMesh: AbstractMesh;
  100471. /** Gets or sets the mesh used as pole */
  100472. poleTargetMesh: AbstractMesh;
  100473. /**
  100474. * Gets or sets the bone used as pole
  100475. */
  100476. poleTargetBone: Nullable<Bone>;
  100477. /**
  100478. * Gets or sets the target position
  100479. */
  100480. targetPosition: Vector3;
  100481. /**
  100482. * Gets or sets the pole target position
  100483. */
  100484. poleTargetPosition: Vector3;
  100485. /**
  100486. * Gets or sets the pole target local offset
  100487. */
  100488. poleTargetLocalOffset: Vector3;
  100489. /**
  100490. * Gets or sets the pole angle
  100491. */
  100492. poleAngle: number;
  100493. /**
  100494. * Gets or sets the mesh associated with the controller
  100495. */
  100496. mesh: AbstractMesh;
  100497. /**
  100498. * 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)
  100499. */
  100500. slerpAmount: number;
  100501. private _bone1Quat;
  100502. private _bone1Mat;
  100503. private _bone2Ang;
  100504. private _bone1;
  100505. private _bone2;
  100506. private _bone1Length;
  100507. private _bone2Length;
  100508. private _maxAngle;
  100509. private _maxReach;
  100510. private _rightHandedSystem;
  100511. private _bendAxis;
  100512. private _slerping;
  100513. private _adjustRoll;
  100514. /**
  100515. * Gets or sets maximum allowed angle
  100516. */
  100517. maxAngle: number;
  100518. /**
  100519. * Creates a new BoneIKController
  100520. * @param mesh defines the mesh to control
  100521. * @param bone defines the bone to control
  100522. * @param options defines options to set up the controller
  100523. */
  100524. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  100525. targetMesh?: AbstractMesh;
  100526. poleTargetMesh?: AbstractMesh;
  100527. poleTargetBone?: Bone;
  100528. poleTargetLocalOffset?: Vector3;
  100529. poleAngle?: number;
  100530. bendAxis?: Vector3;
  100531. maxAngle?: number;
  100532. slerpAmount?: number;
  100533. });
  100534. private _setMaxAngle;
  100535. /**
  100536. * Force the controller to update the bones
  100537. */
  100538. update(): void;
  100539. }
  100540. }
  100541. declare module BABYLON {
  100542. /**
  100543. * Class used to make a bone look toward a point in space
  100544. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  100545. */
  100546. export class BoneLookController {
  100547. private static _tmpVecs;
  100548. private static _tmpQuat;
  100549. private static _tmpMats;
  100550. /**
  100551. * The target Vector3 that the bone will look at
  100552. */
  100553. target: Vector3;
  100554. /**
  100555. * The mesh that the bone is attached to
  100556. */
  100557. mesh: AbstractMesh;
  100558. /**
  100559. * The bone that will be looking to the target
  100560. */
  100561. bone: Bone;
  100562. /**
  100563. * The up axis of the coordinate system that is used when the bone is rotated
  100564. */
  100565. upAxis: Vector3;
  100566. /**
  100567. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  100568. */
  100569. upAxisSpace: Space;
  100570. /**
  100571. * Used to make an adjustment to the yaw of the bone
  100572. */
  100573. adjustYaw: number;
  100574. /**
  100575. * Used to make an adjustment to the pitch of the bone
  100576. */
  100577. adjustPitch: number;
  100578. /**
  100579. * Used to make an adjustment to the roll of the bone
  100580. */
  100581. adjustRoll: number;
  100582. /**
  100583. * 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)
  100584. */
  100585. slerpAmount: number;
  100586. private _minYaw;
  100587. private _maxYaw;
  100588. private _minPitch;
  100589. private _maxPitch;
  100590. private _minYawSin;
  100591. private _minYawCos;
  100592. private _maxYawSin;
  100593. private _maxYawCos;
  100594. private _midYawConstraint;
  100595. private _minPitchTan;
  100596. private _maxPitchTan;
  100597. private _boneQuat;
  100598. private _slerping;
  100599. private _transformYawPitch;
  100600. private _transformYawPitchInv;
  100601. private _firstFrameSkipped;
  100602. private _yawRange;
  100603. private _fowardAxis;
  100604. /**
  100605. * Gets or sets the minimum yaw angle that the bone can look to
  100606. */
  100607. minYaw: number;
  100608. /**
  100609. * Gets or sets the maximum yaw angle that the bone can look to
  100610. */
  100611. maxYaw: number;
  100612. /**
  100613. * Gets or sets the minimum pitch angle that the bone can look to
  100614. */
  100615. minPitch: number;
  100616. /**
  100617. * Gets or sets the maximum pitch angle that the bone can look to
  100618. */
  100619. maxPitch: number;
  100620. /**
  100621. * Create a BoneLookController
  100622. * @param mesh the mesh that the bone belongs to
  100623. * @param bone the bone that will be looking to the target
  100624. * @param target the target Vector3 to look at
  100625. * @param options optional settings:
  100626. * * maxYaw: the maximum angle the bone will yaw to
  100627. * * minYaw: the minimum angle the bone will yaw to
  100628. * * maxPitch: the maximum angle the bone will pitch to
  100629. * * minPitch: the minimum angle the bone will yaw to
  100630. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  100631. * * upAxis: the up axis of the coordinate system
  100632. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  100633. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  100634. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  100635. * * adjustYaw: used to make an adjustment to the yaw of the bone
  100636. * * adjustPitch: used to make an adjustment to the pitch of the bone
  100637. * * adjustRoll: used to make an adjustment to the roll of the bone
  100638. **/
  100639. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  100640. maxYaw?: number;
  100641. minYaw?: number;
  100642. maxPitch?: number;
  100643. minPitch?: number;
  100644. slerpAmount?: number;
  100645. upAxis?: Vector3;
  100646. upAxisSpace?: Space;
  100647. yawAxis?: Vector3;
  100648. pitchAxis?: Vector3;
  100649. adjustYaw?: number;
  100650. adjustPitch?: number;
  100651. adjustRoll?: number;
  100652. });
  100653. /**
  100654. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  100655. */
  100656. update(): void;
  100657. private _getAngleDiff;
  100658. private _getAngleBetween;
  100659. private _isAngleBetween;
  100660. }
  100661. }
  100662. declare module BABYLON {
  100663. /**
  100664. * Manage the gamepad inputs to control an arc rotate camera.
  100665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100666. */
  100667. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  100668. /**
  100669. * Defines the camera the input is attached to.
  100670. */
  100671. camera: ArcRotateCamera;
  100672. /**
  100673. * Defines the gamepad the input is gathering event from.
  100674. */
  100675. gamepad: Nullable<Gamepad>;
  100676. /**
  100677. * Defines the gamepad rotation sensiblity.
  100678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100679. */
  100680. gamepadRotationSensibility: number;
  100681. /**
  100682. * Defines the gamepad move sensiblity.
  100683. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100684. */
  100685. gamepadMoveSensibility: number;
  100686. private _onGamepadConnectedObserver;
  100687. private _onGamepadDisconnectedObserver;
  100688. /**
  100689. * Attach the input controls to a specific dom element to get the input from.
  100690. * @param element Defines the element the controls should be listened from
  100691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100692. */
  100693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100694. /**
  100695. * Detach the current controls from the specified dom element.
  100696. * @param element Defines the element to stop listening the inputs from
  100697. */
  100698. detachControl(element: Nullable<HTMLElement>): void;
  100699. /**
  100700. * Update the current camera state depending on the inputs that have been used this frame.
  100701. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100702. */
  100703. checkInputs(): void;
  100704. /**
  100705. * Gets the class name of the current intput.
  100706. * @returns the class name
  100707. */
  100708. getClassName(): string;
  100709. /**
  100710. * Get the friendly name associated with the input class.
  100711. * @returns the input friendly name
  100712. */
  100713. getSimpleName(): string;
  100714. }
  100715. }
  100716. declare module BABYLON {
  100717. interface ArcRotateCameraInputsManager {
  100718. /**
  100719. * Add orientation input support to the input manager.
  100720. * @returns the current input manager
  100721. */
  100722. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  100723. }
  100724. /**
  100725. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  100726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100727. */
  100728. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  100729. /**
  100730. * Defines the camera the input is attached to.
  100731. */
  100732. camera: ArcRotateCamera;
  100733. /**
  100734. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  100735. */
  100736. alphaCorrection: number;
  100737. /**
  100738. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  100739. */
  100740. gammaCorrection: number;
  100741. private _alpha;
  100742. private _gamma;
  100743. private _dirty;
  100744. private _deviceOrientationHandler;
  100745. /**
  100746. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  100747. */
  100748. constructor();
  100749. /**
  100750. * Attach the input controls to a specific dom element to get the input from.
  100751. * @param element Defines the element the controls should be listened from
  100752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100753. */
  100754. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100755. /** @hidden */
  100756. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  100757. /**
  100758. * Update the current camera state depending on the inputs that have been used this frame.
  100759. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100760. */
  100761. checkInputs(): void;
  100762. /**
  100763. * Detach the current controls from the specified dom element.
  100764. * @param element Defines the element to stop listening the inputs from
  100765. */
  100766. detachControl(element: Nullable<HTMLElement>): void;
  100767. /**
  100768. * Gets the class name of the current intput.
  100769. * @returns the class name
  100770. */
  100771. getClassName(): string;
  100772. /**
  100773. * Get the friendly name associated with the input class.
  100774. * @returns the input friendly name
  100775. */
  100776. getSimpleName(): string;
  100777. }
  100778. }
  100779. declare module BABYLON {
  100780. /**
  100781. * Listen to mouse events to control the camera.
  100782. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100783. */
  100784. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  100785. /**
  100786. * Defines the camera the input is attached to.
  100787. */
  100788. camera: FlyCamera;
  100789. /**
  100790. * Defines if touch is enabled. (Default is true.)
  100791. */
  100792. touchEnabled: boolean;
  100793. /**
  100794. * Defines the buttons associated with the input to handle camera rotation.
  100795. */
  100796. buttons: number[];
  100797. /**
  100798. * Assign buttons for Yaw control.
  100799. */
  100800. buttonsYaw: number[];
  100801. /**
  100802. * Assign buttons for Pitch control.
  100803. */
  100804. buttonsPitch: number[];
  100805. /**
  100806. * Assign buttons for Roll control.
  100807. */
  100808. buttonsRoll: number[];
  100809. /**
  100810. * Detect if any button is being pressed while mouse is moved.
  100811. * -1 = Mouse locked.
  100812. * 0 = Left button.
  100813. * 1 = Middle Button.
  100814. * 2 = Right Button.
  100815. */
  100816. activeButton: number;
  100817. /**
  100818. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  100819. * Higher values reduce its sensitivity.
  100820. */
  100821. angularSensibility: number;
  100822. private _mousemoveCallback;
  100823. private _observer;
  100824. private _rollObserver;
  100825. private previousPosition;
  100826. private noPreventDefault;
  100827. private element;
  100828. /**
  100829. * Listen to mouse events to control the camera.
  100830. * @param touchEnabled Define if touch is enabled. (Default is true.)
  100831. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100832. */
  100833. constructor(touchEnabled?: boolean);
  100834. /**
  100835. * Attach the mouse control to the HTML DOM element.
  100836. * @param element Defines the element that listens to the input events.
  100837. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  100838. */
  100839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100840. /**
  100841. * Detach the current controls from the specified dom element.
  100842. * @param element Defines the element to stop listening the inputs from
  100843. */
  100844. detachControl(element: Nullable<HTMLElement>): void;
  100845. /**
  100846. * Gets the class name of the current input.
  100847. * @returns the class name.
  100848. */
  100849. getClassName(): string;
  100850. /**
  100851. * Get the friendly name associated with the input class.
  100852. * @returns the input's friendly name.
  100853. */
  100854. getSimpleName(): string;
  100855. private _pointerInput;
  100856. private _onMouseMove;
  100857. /**
  100858. * Rotate camera by mouse offset.
  100859. */
  100860. private rotateCamera;
  100861. }
  100862. }
  100863. declare module BABYLON {
  100864. /**
  100865. * Default Inputs manager for the FlyCamera.
  100866. * It groups all the default supported inputs for ease of use.
  100867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100868. */
  100869. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  100870. /**
  100871. * Instantiates a new FlyCameraInputsManager.
  100872. * @param camera Defines the camera the inputs belong to.
  100873. */
  100874. constructor(camera: FlyCamera);
  100875. /**
  100876. * Add keyboard input support to the input manager.
  100877. * @returns the new FlyCameraKeyboardMoveInput().
  100878. */
  100879. addKeyboard(): FlyCameraInputsManager;
  100880. /**
  100881. * Add mouse input support to the input manager.
  100882. * @param touchEnabled Enable touch screen support.
  100883. * @returns the new FlyCameraMouseInput().
  100884. */
  100885. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  100886. }
  100887. }
  100888. declare module BABYLON {
  100889. /**
  100890. * This is a flying camera, designed for 3D movement and rotation in all directions,
  100891. * such as in a 3D Space Shooter or a Flight Simulator.
  100892. */
  100893. export class FlyCamera extends TargetCamera {
  100894. /**
  100895. * Define the collision ellipsoid of the camera.
  100896. * This is helpful for simulating a camera body, like a player's body.
  100897. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100898. */
  100899. ellipsoid: Vector3;
  100900. /**
  100901. * Define an offset for the position of the ellipsoid around the camera.
  100902. * This can be helpful if the camera is attached away from the player's body center,
  100903. * such as at its head.
  100904. */
  100905. ellipsoidOffset: Vector3;
  100906. /**
  100907. * Enable or disable collisions of the camera with the rest of the scene objects.
  100908. */
  100909. checkCollisions: boolean;
  100910. /**
  100911. * Enable or disable gravity on the camera.
  100912. */
  100913. applyGravity: boolean;
  100914. /**
  100915. * Define the current direction the camera is moving to.
  100916. */
  100917. cameraDirection: Vector3;
  100918. /**
  100919. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  100920. * This overrides and empties cameraRotation.
  100921. */
  100922. rotationQuaternion: Quaternion;
  100923. /**
  100924. * Track Roll to maintain the wanted Rolling when looking around.
  100925. */
  100926. _trackRoll: number;
  100927. /**
  100928. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  100929. */
  100930. rollCorrect: number;
  100931. /**
  100932. * Mimic a banked turn, Rolling the camera when Yawing.
  100933. * It's recommended to use rollCorrect = 10 for faster banking correction.
  100934. */
  100935. bankedTurn: boolean;
  100936. /**
  100937. * Limit in radians for how much Roll banking will add. (Default: 90°)
  100938. */
  100939. bankedTurnLimit: number;
  100940. /**
  100941. * Value of 0 disables the banked Roll.
  100942. * Value of 1 is equal to the Yaw angle in radians.
  100943. */
  100944. bankedTurnMultiplier: number;
  100945. /**
  100946. * The inputs manager loads all the input sources, such as keyboard and mouse.
  100947. */
  100948. inputs: FlyCameraInputsManager;
  100949. /**
  100950. * Gets the input sensibility for mouse input.
  100951. * Higher values reduce sensitivity.
  100952. */
  100953. /**
  100954. * Sets the input sensibility for a mouse input.
  100955. * Higher values reduce sensitivity.
  100956. */
  100957. angularSensibility: number;
  100958. /**
  100959. * Get the keys for camera movement forward.
  100960. */
  100961. /**
  100962. * Set the keys for camera movement forward.
  100963. */
  100964. keysForward: number[];
  100965. /**
  100966. * Get the keys for camera movement backward.
  100967. */
  100968. keysBackward: number[];
  100969. /**
  100970. * Get the keys for camera movement up.
  100971. */
  100972. /**
  100973. * Set the keys for camera movement up.
  100974. */
  100975. keysUp: number[];
  100976. /**
  100977. * Get the keys for camera movement down.
  100978. */
  100979. /**
  100980. * Set the keys for camera movement down.
  100981. */
  100982. keysDown: number[];
  100983. /**
  100984. * Get the keys for camera movement left.
  100985. */
  100986. /**
  100987. * Set the keys for camera movement left.
  100988. */
  100989. keysLeft: number[];
  100990. /**
  100991. * Set the keys for camera movement right.
  100992. */
  100993. /**
  100994. * Set the keys for camera movement right.
  100995. */
  100996. keysRight: number[];
  100997. /**
  100998. * Event raised when the camera collides with a mesh in the scene.
  100999. */
  101000. onCollide: (collidedMesh: AbstractMesh) => void;
  101001. private _collider;
  101002. private _needMoveForGravity;
  101003. private _oldPosition;
  101004. private _diffPosition;
  101005. private _newPosition;
  101006. /** @hidden */
  101007. _localDirection: Vector3;
  101008. /** @hidden */
  101009. _transformedDirection: Vector3;
  101010. /**
  101011. * Instantiates a FlyCamera.
  101012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  101013. * such as in a 3D Space Shooter or a Flight Simulator.
  101014. * @param name Define the name of the camera in the scene.
  101015. * @param position Define the starting position of the camera in the scene.
  101016. * @param scene Define the scene the camera belongs to.
  101017. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  101018. */
  101019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  101020. /**
  101021. * Attach a control to the HTML DOM element.
  101022. * @param element Defines the element that listens to the input events.
  101023. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  101024. */
  101025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101026. /**
  101027. * Detach a control from the HTML DOM element.
  101028. * The camera will stop reacting to that input.
  101029. * @param element Defines the element that listens to the input events.
  101030. */
  101031. detachControl(element: HTMLElement): void;
  101032. private _collisionMask;
  101033. /**
  101034. * Get the mask that the camera ignores in collision events.
  101035. */
  101036. /**
  101037. * Set the mask that the camera ignores in collision events.
  101038. */
  101039. collisionMask: number;
  101040. /** @hidden */
  101041. _collideWithWorld(displacement: Vector3): void;
  101042. /** @hidden */
  101043. private _onCollisionPositionChange;
  101044. /** @hidden */
  101045. _checkInputs(): void;
  101046. /** @hidden */
  101047. _decideIfNeedsToMove(): boolean;
  101048. /** @hidden */
  101049. _updatePosition(): void;
  101050. /**
  101051. * Restore the Roll to its target value at the rate specified.
  101052. * @param rate - Higher means slower restoring.
  101053. * @hidden
  101054. */
  101055. restoreRoll(rate: number): void;
  101056. /**
  101057. * Destroy the camera and release the current resources held by it.
  101058. */
  101059. dispose(): void;
  101060. /**
  101061. * Get the current object class name.
  101062. * @returns the class name.
  101063. */
  101064. getClassName(): string;
  101065. }
  101066. }
  101067. declare module BABYLON {
  101068. /**
  101069. * Listen to keyboard events to control the camera.
  101070. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101071. */
  101072. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  101073. /**
  101074. * Defines the camera the input is attached to.
  101075. */
  101076. camera: FlyCamera;
  101077. /**
  101078. * The list of keyboard keys used to control the forward move of the camera.
  101079. */
  101080. keysForward: number[];
  101081. /**
  101082. * The list of keyboard keys used to control the backward move of the camera.
  101083. */
  101084. keysBackward: number[];
  101085. /**
  101086. * The list of keyboard keys used to control the forward move of the camera.
  101087. */
  101088. keysUp: number[];
  101089. /**
  101090. * The list of keyboard keys used to control the backward move of the camera.
  101091. */
  101092. keysDown: number[];
  101093. /**
  101094. * The list of keyboard keys used to control the right strafe move of the camera.
  101095. */
  101096. keysRight: number[];
  101097. /**
  101098. * The list of keyboard keys used to control the left strafe move of the camera.
  101099. */
  101100. keysLeft: number[];
  101101. private _keys;
  101102. private _onCanvasBlurObserver;
  101103. private _onKeyboardObserver;
  101104. private _engine;
  101105. private _scene;
  101106. /**
  101107. * Attach the input controls to a specific dom element to get the input from.
  101108. * @param element Defines the element the controls should be listened from
  101109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101110. */
  101111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101112. /**
  101113. * Detach the current controls from the specified dom element.
  101114. * @param element Defines the element to stop listening the inputs from
  101115. */
  101116. detachControl(element: Nullable<HTMLElement>): void;
  101117. /**
  101118. * Gets the class name of the current intput.
  101119. * @returns the class name
  101120. */
  101121. getClassName(): string;
  101122. /** @hidden */
  101123. _onLostFocus(e: FocusEvent): void;
  101124. /**
  101125. * Get the friendly name associated with the input class.
  101126. * @returns the input friendly name
  101127. */
  101128. getSimpleName(): string;
  101129. /**
  101130. * Update the current camera state depending on the inputs that have been used this frame.
  101131. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101132. */
  101133. checkInputs(): void;
  101134. }
  101135. }
  101136. declare module BABYLON {
  101137. /**
  101138. * Manage the mouse wheel inputs to control a follow camera.
  101139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101140. */
  101141. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  101142. /**
  101143. * Defines the camera the input is attached to.
  101144. */
  101145. camera: FollowCamera;
  101146. /**
  101147. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  101148. */
  101149. axisControlRadius: boolean;
  101150. /**
  101151. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  101152. */
  101153. axisControlHeight: boolean;
  101154. /**
  101155. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  101156. */
  101157. axisControlRotation: boolean;
  101158. /**
  101159. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  101160. * relation to mouseWheel events.
  101161. */
  101162. wheelPrecision: number;
  101163. /**
  101164. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  101165. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  101166. */
  101167. wheelDeltaPercentage: number;
  101168. private _wheel;
  101169. private _observer;
  101170. /**
  101171. * Attach the input controls to a specific dom element to get the input from.
  101172. * @param element Defines the element the controls should be listened from
  101173. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101174. */
  101175. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101176. /**
  101177. * Detach the current controls from the specified dom element.
  101178. * @param element Defines the element to stop listening the inputs from
  101179. */
  101180. detachControl(element: Nullable<HTMLElement>): void;
  101181. /**
  101182. * Gets the class name of the current intput.
  101183. * @returns the class name
  101184. */
  101185. getClassName(): string;
  101186. /**
  101187. * Get the friendly name associated with the input class.
  101188. * @returns the input friendly name
  101189. */
  101190. getSimpleName(): string;
  101191. }
  101192. }
  101193. declare module BABYLON {
  101194. /**
  101195. * Manage the pointers inputs to control an follow camera.
  101196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101197. */
  101198. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  101199. /**
  101200. * Defines the camera the input is attached to.
  101201. */
  101202. camera: FollowCamera;
  101203. /**
  101204. * Gets the class name of the current input.
  101205. * @returns the class name
  101206. */
  101207. getClassName(): string;
  101208. /**
  101209. * Defines the pointer angular sensibility along the X axis or how fast is
  101210. * the camera rotating.
  101211. * A negative number will reverse the axis direction.
  101212. */
  101213. angularSensibilityX: number;
  101214. /**
  101215. * Defines the pointer angular sensibility along the Y axis or how fast is
  101216. * the camera rotating.
  101217. * A negative number will reverse the axis direction.
  101218. */
  101219. angularSensibilityY: number;
  101220. /**
  101221. * Defines the pointer pinch precision or how fast is the camera zooming.
  101222. * A negative number will reverse the axis direction.
  101223. */
  101224. pinchPrecision: number;
  101225. /**
  101226. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  101227. * from 0.
  101228. * It defines the percentage of current camera.radius to use as delta when
  101229. * pinch zoom is used.
  101230. */
  101231. pinchDeltaPercentage: number;
  101232. /**
  101233. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  101234. */
  101235. axisXControlRadius: boolean;
  101236. /**
  101237. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  101238. */
  101239. axisXControlHeight: boolean;
  101240. /**
  101241. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  101242. */
  101243. axisXControlRotation: boolean;
  101244. /**
  101245. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  101246. */
  101247. axisYControlRadius: boolean;
  101248. /**
  101249. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  101250. */
  101251. axisYControlHeight: boolean;
  101252. /**
  101253. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  101254. */
  101255. axisYControlRotation: boolean;
  101256. /**
  101257. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  101258. */
  101259. axisPinchControlRadius: boolean;
  101260. /**
  101261. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  101262. */
  101263. axisPinchControlHeight: boolean;
  101264. /**
  101265. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  101266. */
  101267. axisPinchControlRotation: boolean;
  101268. /**
  101269. * Log error messages if basic misconfiguration has occurred.
  101270. */
  101271. warningEnable: boolean;
  101272. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  101273. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  101274. private _warningCounter;
  101275. private _warning;
  101276. }
  101277. }
  101278. declare module BABYLON {
  101279. /**
  101280. * Default Inputs manager for the FollowCamera.
  101281. * It groups all the default supported inputs for ease of use.
  101282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101283. */
  101284. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  101285. /**
  101286. * Instantiates a new FollowCameraInputsManager.
  101287. * @param camera Defines the camera the inputs belong to
  101288. */
  101289. constructor(camera: FollowCamera);
  101290. /**
  101291. * Add keyboard input support to the input manager.
  101292. * @returns the current input manager
  101293. */
  101294. addKeyboard(): FollowCameraInputsManager;
  101295. /**
  101296. * Add mouse wheel input support to the input manager.
  101297. * @returns the current input manager
  101298. */
  101299. addMouseWheel(): FollowCameraInputsManager;
  101300. /**
  101301. * Add pointers input support to the input manager.
  101302. * @returns the current input manager
  101303. */
  101304. addPointers(): FollowCameraInputsManager;
  101305. /**
  101306. * Add orientation input support to the input manager.
  101307. * @returns the current input manager
  101308. */
  101309. addVRDeviceOrientation(): FollowCameraInputsManager;
  101310. }
  101311. }
  101312. declare module BABYLON {
  101313. /**
  101314. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  101315. * an arc rotate version arcFollowCamera are available.
  101316. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101317. */
  101318. export class FollowCamera extends TargetCamera {
  101319. /**
  101320. * Distance the follow camera should follow an object at
  101321. */
  101322. radius: number;
  101323. /**
  101324. * Minimum allowed distance of the camera to the axis of rotation
  101325. * (The camera can not get closer).
  101326. * This can help limiting how the Camera is able to move in the scene.
  101327. */
  101328. lowerRadiusLimit: Nullable<number>;
  101329. /**
  101330. * Maximum allowed distance of the camera to the axis of rotation
  101331. * (The camera can not get further).
  101332. * This can help limiting how the Camera is able to move in the scene.
  101333. */
  101334. upperRadiusLimit: Nullable<number>;
  101335. /**
  101336. * Define a rotation offset between the camera and the object it follows
  101337. */
  101338. rotationOffset: number;
  101339. /**
  101340. * Minimum allowed angle to camera position relative to target object.
  101341. * This can help limiting how the Camera is able to move in the scene.
  101342. */
  101343. lowerRotationOffsetLimit: Nullable<number>;
  101344. /**
  101345. * Maximum allowed angle to camera position relative to target object.
  101346. * This can help limiting how the Camera is able to move in the scene.
  101347. */
  101348. upperRotationOffsetLimit: Nullable<number>;
  101349. /**
  101350. * Define a height offset between the camera and the object it follows.
  101351. * It can help following an object from the top (like a car chaing a plane)
  101352. */
  101353. heightOffset: number;
  101354. /**
  101355. * Minimum allowed height of camera position relative to target object.
  101356. * This can help limiting how the Camera is able to move in the scene.
  101357. */
  101358. lowerHeightOffsetLimit: Nullable<number>;
  101359. /**
  101360. * Maximum allowed height of camera position relative to target object.
  101361. * This can help limiting how the Camera is able to move in the scene.
  101362. */
  101363. upperHeightOffsetLimit: Nullable<number>;
  101364. /**
  101365. * Define how fast the camera can accelerate to follow it s target.
  101366. */
  101367. cameraAcceleration: number;
  101368. /**
  101369. * Define the speed limit of the camera following an object.
  101370. */
  101371. maxCameraSpeed: number;
  101372. /**
  101373. * Define the target of the camera.
  101374. */
  101375. lockedTarget: Nullable<AbstractMesh>;
  101376. /**
  101377. * Defines the input associated with the camera.
  101378. */
  101379. inputs: FollowCameraInputsManager;
  101380. /**
  101381. * Instantiates the follow camera.
  101382. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101383. * @param name Define the name of the camera in the scene
  101384. * @param position Define the position of the camera
  101385. * @param scene Define the scene the camera belong to
  101386. * @param lockedTarget Define the target of the camera
  101387. */
  101388. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  101389. private _follow;
  101390. /**
  101391. * Attached controls to the current camera.
  101392. * @param element Defines the element the controls should be listened from
  101393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101394. */
  101395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101396. /**
  101397. * Detach the current controls from the camera.
  101398. * The camera will stop reacting to inputs.
  101399. * @param element Defines the element to stop listening the inputs from
  101400. */
  101401. detachControl(element: HTMLElement): void;
  101402. /** @hidden */
  101403. _checkInputs(): void;
  101404. private _checkLimits;
  101405. /**
  101406. * Gets the camera class name.
  101407. * @returns the class name
  101408. */
  101409. getClassName(): string;
  101410. }
  101411. /**
  101412. * Arc Rotate version of the follow camera.
  101413. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  101414. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101415. */
  101416. export class ArcFollowCamera extends TargetCamera {
  101417. /** The longitudinal angle of the camera */
  101418. alpha: number;
  101419. /** The latitudinal angle of the camera */
  101420. beta: number;
  101421. /** The radius of the camera from its target */
  101422. radius: number;
  101423. /** Define the camera target (the messh it should follow) */
  101424. target: Nullable<AbstractMesh>;
  101425. private _cartesianCoordinates;
  101426. /**
  101427. * Instantiates a new ArcFollowCamera
  101428. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  101429. * @param name Define the name of the camera
  101430. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  101431. * @param beta Define the rotation angle of the camera around the elevation axis
  101432. * @param radius Define the radius of the camera from its target point
  101433. * @param target Define the target of the camera
  101434. * @param scene Define the scene the camera belongs to
  101435. */
  101436. constructor(name: string,
  101437. /** The longitudinal angle of the camera */
  101438. alpha: number,
  101439. /** The latitudinal angle of the camera */
  101440. beta: number,
  101441. /** The radius of the camera from its target */
  101442. radius: number,
  101443. /** Define the camera target (the messh it should follow) */
  101444. target: Nullable<AbstractMesh>, scene: Scene);
  101445. private _follow;
  101446. /** @hidden */
  101447. _checkInputs(): void;
  101448. /**
  101449. * Returns the class name of the object.
  101450. * It is mostly used internally for serialization purposes.
  101451. */
  101452. getClassName(): string;
  101453. }
  101454. }
  101455. declare module BABYLON {
  101456. /**
  101457. * Manage the keyboard inputs to control the movement of a follow camera.
  101458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101459. */
  101460. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  101461. /**
  101462. * Defines the camera the input is attached to.
  101463. */
  101464. camera: FollowCamera;
  101465. /**
  101466. * Defines the list of key codes associated with the up action (increase heightOffset)
  101467. */
  101468. keysHeightOffsetIncr: number[];
  101469. /**
  101470. * Defines the list of key codes associated with the down action (decrease heightOffset)
  101471. */
  101472. keysHeightOffsetDecr: number[];
  101473. /**
  101474. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  101475. */
  101476. keysHeightOffsetModifierAlt: boolean;
  101477. /**
  101478. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  101479. */
  101480. keysHeightOffsetModifierCtrl: boolean;
  101481. /**
  101482. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  101483. */
  101484. keysHeightOffsetModifierShift: boolean;
  101485. /**
  101486. * Defines the list of key codes associated with the left action (increase rotationOffset)
  101487. */
  101488. keysRotationOffsetIncr: number[];
  101489. /**
  101490. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  101491. */
  101492. keysRotationOffsetDecr: number[];
  101493. /**
  101494. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  101495. */
  101496. keysRotationOffsetModifierAlt: boolean;
  101497. /**
  101498. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  101499. */
  101500. keysRotationOffsetModifierCtrl: boolean;
  101501. /**
  101502. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  101503. */
  101504. keysRotationOffsetModifierShift: boolean;
  101505. /**
  101506. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  101507. */
  101508. keysRadiusIncr: number[];
  101509. /**
  101510. * Defines the list of key codes associated with the zoom-out action (increase radius)
  101511. */
  101512. keysRadiusDecr: number[];
  101513. /**
  101514. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  101515. */
  101516. keysRadiusModifierAlt: boolean;
  101517. /**
  101518. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  101519. */
  101520. keysRadiusModifierCtrl: boolean;
  101521. /**
  101522. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  101523. */
  101524. keysRadiusModifierShift: boolean;
  101525. /**
  101526. * Defines the rate of change of heightOffset.
  101527. */
  101528. heightSensibility: number;
  101529. /**
  101530. * Defines the rate of change of rotationOffset.
  101531. */
  101532. rotationSensibility: number;
  101533. /**
  101534. * Defines the rate of change of radius.
  101535. */
  101536. radiusSensibility: number;
  101537. private _keys;
  101538. private _ctrlPressed;
  101539. private _altPressed;
  101540. private _shiftPressed;
  101541. private _onCanvasBlurObserver;
  101542. private _onKeyboardObserver;
  101543. private _engine;
  101544. private _scene;
  101545. /**
  101546. * Attach the input controls to a specific dom element to get the input from.
  101547. * @param element Defines the element the controls should be listened from
  101548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101549. */
  101550. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101551. /**
  101552. * Detach the current controls from the specified dom element.
  101553. * @param element Defines the element to stop listening the inputs from
  101554. */
  101555. detachControl(element: Nullable<HTMLElement>): void;
  101556. /**
  101557. * Update the current camera state depending on the inputs that have been used this frame.
  101558. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101559. */
  101560. checkInputs(): void;
  101561. /**
  101562. * Gets the class name of the current input.
  101563. * @returns the class name
  101564. */
  101565. getClassName(): string;
  101566. /**
  101567. * Get the friendly name associated with the input class.
  101568. * @returns the input friendly name
  101569. */
  101570. getSimpleName(): string;
  101571. /**
  101572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101573. * allow modification of the heightOffset value.
  101574. */
  101575. private _modifierHeightOffset;
  101576. /**
  101577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101578. * allow modification of the rotationOffset value.
  101579. */
  101580. private _modifierRotationOffset;
  101581. /**
  101582. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  101583. * allow modification of the radius value.
  101584. */
  101585. private _modifierRadius;
  101586. }
  101587. }
  101588. declare module BABYLON {
  101589. interface FreeCameraInputsManager {
  101590. /**
  101591. * @hidden
  101592. */
  101593. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  101594. /**
  101595. * Add orientation input support to the input manager.
  101596. * @returns the current input manager
  101597. */
  101598. addDeviceOrientation(): FreeCameraInputsManager;
  101599. }
  101600. /**
  101601. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  101602. * Screen rotation is taken into account.
  101603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101604. */
  101605. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  101606. private _camera;
  101607. private _screenOrientationAngle;
  101608. private _constantTranform;
  101609. private _screenQuaternion;
  101610. private _alpha;
  101611. private _beta;
  101612. private _gamma;
  101613. /**
  101614. * Can be used to detect if a device orientation sensor is availible on a device
  101615. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  101616. * @returns a promise that will resolve on orientation change
  101617. */
  101618. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  101619. /**
  101620. * @hidden
  101621. */
  101622. _onDeviceOrientationChangedObservable: Observable<void>;
  101623. /**
  101624. * Instantiates a new input
  101625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101626. */
  101627. constructor();
  101628. /**
  101629. * Define the camera controlled by the input.
  101630. */
  101631. camera: FreeCamera;
  101632. /**
  101633. * Attach the input controls to a specific dom element to get the input from.
  101634. * @param element Defines the element the controls should be listened from
  101635. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101636. */
  101637. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101638. private _orientationChanged;
  101639. private _deviceOrientation;
  101640. /**
  101641. * Detach the current controls from the specified dom element.
  101642. * @param element Defines the element to stop listening the inputs from
  101643. */
  101644. detachControl(element: Nullable<HTMLElement>): void;
  101645. /**
  101646. * Update the current camera state depending on the inputs that have been used this frame.
  101647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101648. */
  101649. checkInputs(): void;
  101650. /**
  101651. * Gets the class name of the current intput.
  101652. * @returns the class name
  101653. */
  101654. getClassName(): string;
  101655. /**
  101656. * Get the friendly name associated with the input class.
  101657. * @returns the input friendly name
  101658. */
  101659. getSimpleName(): string;
  101660. }
  101661. }
  101662. declare module BABYLON {
  101663. /**
  101664. * Manage the gamepad inputs to control a free camera.
  101665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101666. */
  101667. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  101668. /**
  101669. * Define the camera the input is attached to.
  101670. */
  101671. camera: FreeCamera;
  101672. /**
  101673. * Define the Gamepad controlling the input
  101674. */
  101675. gamepad: Nullable<Gamepad>;
  101676. /**
  101677. * Defines the gamepad rotation sensiblity.
  101678. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  101679. */
  101680. gamepadAngularSensibility: number;
  101681. /**
  101682. * Defines the gamepad move sensiblity.
  101683. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  101684. */
  101685. gamepadMoveSensibility: number;
  101686. private _onGamepadConnectedObserver;
  101687. private _onGamepadDisconnectedObserver;
  101688. private _cameraTransform;
  101689. private _deltaTransform;
  101690. private _vector3;
  101691. private _vector2;
  101692. /**
  101693. * Attach the input controls to a specific dom element to get the input from.
  101694. * @param element Defines the element the controls should be listened from
  101695. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101696. */
  101697. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101698. /**
  101699. * Detach the current controls from the specified dom element.
  101700. * @param element Defines the element to stop listening the inputs from
  101701. */
  101702. detachControl(element: Nullable<HTMLElement>): void;
  101703. /**
  101704. * Update the current camera state depending on the inputs that have been used this frame.
  101705. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101706. */
  101707. checkInputs(): void;
  101708. /**
  101709. * Gets the class name of the current intput.
  101710. * @returns the class name
  101711. */
  101712. getClassName(): string;
  101713. /**
  101714. * Get the friendly name associated with the input class.
  101715. * @returns the input friendly name
  101716. */
  101717. getSimpleName(): string;
  101718. }
  101719. }
  101720. declare module BABYLON {
  101721. /**
  101722. * Defines the potential axis of a Joystick
  101723. */
  101724. export enum JoystickAxis {
  101725. /** X axis */
  101726. X = 0,
  101727. /** Y axis */
  101728. Y = 1,
  101729. /** Z axis */
  101730. Z = 2
  101731. }
  101732. /**
  101733. * Class used to define virtual joystick (used in touch mode)
  101734. */
  101735. export class VirtualJoystick {
  101736. /**
  101737. * Gets or sets a boolean indicating that left and right values must be inverted
  101738. */
  101739. reverseLeftRight: boolean;
  101740. /**
  101741. * Gets or sets a boolean indicating that up and down values must be inverted
  101742. */
  101743. reverseUpDown: boolean;
  101744. /**
  101745. * Gets the offset value for the position (ie. the change of the position value)
  101746. */
  101747. deltaPosition: Vector3;
  101748. /**
  101749. * Gets a boolean indicating if the virtual joystick was pressed
  101750. */
  101751. pressed: boolean;
  101752. /**
  101753. * Canvas the virtual joystick will render onto, default z-index of this is 5
  101754. */
  101755. static Canvas: Nullable<HTMLCanvasElement>;
  101756. private static _globalJoystickIndex;
  101757. private static vjCanvasContext;
  101758. private static vjCanvasWidth;
  101759. private static vjCanvasHeight;
  101760. private static halfWidth;
  101761. private _action;
  101762. private _axisTargetedByLeftAndRight;
  101763. private _axisTargetedByUpAndDown;
  101764. private _joystickSensibility;
  101765. private _inversedSensibility;
  101766. private _joystickPointerID;
  101767. private _joystickColor;
  101768. private _joystickPointerPos;
  101769. private _joystickPreviousPointerPos;
  101770. private _joystickPointerStartPos;
  101771. private _deltaJoystickVector;
  101772. private _leftJoystick;
  101773. private _touches;
  101774. private _onPointerDownHandlerRef;
  101775. private _onPointerMoveHandlerRef;
  101776. private _onPointerUpHandlerRef;
  101777. private _onResize;
  101778. /**
  101779. * Creates a new virtual joystick
  101780. * @param leftJoystick defines that the joystick is for left hand (false by default)
  101781. */
  101782. constructor(leftJoystick?: boolean);
  101783. /**
  101784. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  101785. * @param newJoystickSensibility defines the new sensibility
  101786. */
  101787. setJoystickSensibility(newJoystickSensibility: number): void;
  101788. private _onPointerDown;
  101789. private _onPointerMove;
  101790. private _onPointerUp;
  101791. /**
  101792. * Change the color of the virtual joystick
  101793. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101794. */
  101795. setJoystickColor(newColor: string): void;
  101796. /**
  101797. * Defines a callback to call when the joystick is touched
  101798. * @param action defines the callback
  101799. */
  101800. setActionOnTouch(action: () => any): void;
  101801. /**
  101802. * Defines which axis you'd like to control for left & right
  101803. * @param axis defines the axis to use
  101804. */
  101805. setAxisForLeftRight(axis: JoystickAxis): void;
  101806. /**
  101807. * Defines which axis you'd like to control for up & down
  101808. * @param axis defines the axis to use
  101809. */
  101810. setAxisForUpDown(axis: JoystickAxis): void;
  101811. private _drawVirtualJoystick;
  101812. /**
  101813. * Release internal HTML canvas
  101814. */
  101815. releaseCanvas(): void;
  101816. }
  101817. }
  101818. declare module BABYLON {
  101819. interface FreeCameraInputsManager {
  101820. /**
  101821. * Add virtual joystick input support to the input manager.
  101822. * @returns the current input manager
  101823. */
  101824. addVirtualJoystick(): FreeCameraInputsManager;
  101825. }
  101826. /**
  101827. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  101828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  101829. */
  101830. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  101831. /**
  101832. * Defines the camera the input is attached to.
  101833. */
  101834. camera: FreeCamera;
  101835. private _leftjoystick;
  101836. private _rightjoystick;
  101837. /**
  101838. * Gets the left stick of the virtual joystick.
  101839. * @returns The virtual Joystick
  101840. */
  101841. getLeftJoystick(): VirtualJoystick;
  101842. /**
  101843. * Gets the right stick of the virtual joystick.
  101844. * @returns The virtual Joystick
  101845. */
  101846. getRightJoystick(): VirtualJoystick;
  101847. /**
  101848. * Update the current camera state depending on the inputs that have been used this frame.
  101849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  101850. */
  101851. checkInputs(): void;
  101852. /**
  101853. * Attach the input controls to a specific dom element to get the input from.
  101854. * @param element Defines the element the controls should be listened from
  101855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  101856. */
  101857. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101858. /**
  101859. * Detach the current controls from the specified dom element.
  101860. * @param element Defines the element to stop listening the inputs from
  101861. */
  101862. detachControl(element: Nullable<HTMLElement>): void;
  101863. /**
  101864. * Gets the class name of the current intput.
  101865. * @returns the class name
  101866. */
  101867. getClassName(): string;
  101868. /**
  101869. * Get the friendly name associated with the input class.
  101870. * @returns the input friendly name
  101871. */
  101872. getSimpleName(): string;
  101873. }
  101874. }
  101875. declare module BABYLON {
  101876. /**
  101877. * This represents a FPS type of camera controlled by touch.
  101878. * This is like a universal camera minus the Gamepad controls.
  101879. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101880. */
  101881. export class TouchCamera extends FreeCamera {
  101882. /**
  101883. * Defines the touch sensibility for rotation.
  101884. * The higher the faster.
  101885. */
  101886. touchAngularSensibility: number;
  101887. /**
  101888. * Defines the touch sensibility for move.
  101889. * The higher the faster.
  101890. */
  101891. touchMoveSensibility: number;
  101892. /**
  101893. * Instantiates a new touch camera.
  101894. * This represents a FPS type of camera controlled by touch.
  101895. * This is like a universal camera minus the Gamepad controls.
  101896. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  101897. * @param name Define the name of the camera in the scene
  101898. * @param position Define the start position of the camera in the scene
  101899. * @param scene Define the scene the camera belongs to
  101900. */
  101901. constructor(name: string, position: Vector3, scene: Scene);
  101902. /**
  101903. * Gets the current object class name.
  101904. * @return the class name
  101905. */
  101906. getClassName(): string;
  101907. /** @hidden */
  101908. _setupInputs(): void;
  101909. }
  101910. }
  101911. declare module BABYLON {
  101912. /**
  101913. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  101914. * being tilted forward or back and left or right.
  101915. */
  101916. export class DeviceOrientationCamera extends FreeCamera {
  101917. private _initialQuaternion;
  101918. private _quaternionCache;
  101919. private _tmpDragQuaternion;
  101920. /**
  101921. * Creates a new device orientation camera
  101922. * @param name The name of the camera
  101923. * @param position The start position camera
  101924. * @param scene The scene the camera belongs to
  101925. */
  101926. constructor(name: string, position: Vector3, scene: Scene);
  101927. /**
  101928. * @hidden
  101929. * Disabled pointer input on first orientation sensor update (Default: true)
  101930. */
  101931. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  101932. private _dragFactor;
  101933. /**
  101934. * Enabled turning on the y axis when the orientation sensor is active
  101935. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  101936. */
  101937. enableHorizontalDragging(dragFactor?: number): void;
  101938. /**
  101939. * Gets the current instance class name ("DeviceOrientationCamera").
  101940. * This helps avoiding instanceof at run time.
  101941. * @returns the class name
  101942. */
  101943. getClassName(): string;
  101944. /**
  101945. * @hidden
  101946. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  101947. */
  101948. _checkInputs(): void;
  101949. /**
  101950. * Reset the camera to its default orientation on the specified axis only.
  101951. * @param axis The axis to reset
  101952. */
  101953. resetToCurrentRotation(axis?: Axis): void;
  101954. }
  101955. }
  101956. declare module BABYLON {
  101957. /**
  101958. * Defines supported buttons for XBox360 compatible gamepads
  101959. */
  101960. export enum Xbox360Button {
  101961. /** A */
  101962. A = 0,
  101963. /** B */
  101964. B = 1,
  101965. /** X */
  101966. X = 2,
  101967. /** Y */
  101968. Y = 3,
  101969. /** Start */
  101970. Start = 4,
  101971. /** Back */
  101972. Back = 5,
  101973. /** Left button */
  101974. LB = 6,
  101975. /** Right button */
  101976. RB = 7,
  101977. /** Left stick */
  101978. LeftStick = 8,
  101979. /** Right stick */
  101980. RightStick = 9
  101981. }
  101982. /** Defines values for XBox360 DPad */
  101983. export enum Xbox360Dpad {
  101984. /** Up */
  101985. Up = 0,
  101986. /** Down */
  101987. Down = 1,
  101988. /** Left */
  101989. Left = 2,
  101990. /** Right */
  101991. Right = 3
  101992. }
  101993. /**
  101994. * Defines a XBox360 gamepad
  101995. */
  101996. export class Xbox360Pad extends Gamepad {
  101997. private _leftTrigger;
  101998. private _rightTrigger;
  101999. private _onlefttriggerchanged;
  102000. private _onrighttriggerchanged;
  102001. private _onbuttondown;
  102002. private _onbuttonup;
  102003. private _ondpaddown;
  102004. private _ondpadup;
  102005. /** Observable raised when a button is pressed */
  102006. onButtonDownObservable: Observable<Xbox360Button>;
  102007. /** Observable raised when a button is released */
  102008. onButtonUpObservable: Observable<Xbox360Button>;
  102009. /** Observable raised when a pad is pressed */
  102010. onPadDownObservable: Observable<Xbox360Dpad>;
  102011. /** Observable raised when a pad is released */
  102012. onPadUpObservable: Observable<Xbox360Dpad>;
  102013. private _buttonA;
  102014. private _buttonB;
  102015. private _buttonX;
  102016. private _buttonY;
  102017. private _buttonBack;
  102018. private _buttonStart;
  102019. private _buttonLB;
  102020. private _buttonRB;
  102021. private _buttonLeftStick;
  102022. private _buttonRightStick;
  102023. private _dPadUp;
  102024. private _dPadDown;
  102025. private _dPadLeft;
  102026. private _dPadRight;
  102027. private _isXboxOnePad;
  102028. /**
  102029. * Creates a new XBox360 gamepad object
  102030. * @param id defines the id of this gamepad
  102031. * @param index defines its index
  102032. * @param gamepad defines the internal HTML gamepad object
  102033. * @param xboxOne defines if it is a XBox One gamepad
  102034. */
  102035. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  102036. /**
  102037. * Defines the callback to call when left trigger is pressed
  102038. * @param callback defines the callback to use
  102039. */
  102040. onlefttriggerchanged(callback: (value: number) => void): void;
  102041. /**
  102042. * Defines the callback to call when right trigger is pressed
  102043. * @param callback defines the callback to use
  102044. */
  102045. onrighttriggerchanged(callback: (value: number) => void): void;
  102046. /**
  102047. * Gets the left trigger value
  102048. */
  102049. /**
  102050. * Sets the left trigger value
  102051. */
  102052. leftTrigger: number;
  102053. /**
  102054. * Gets the right trigger value
  102055. */
  102056. /**
  102057. * Sets the right trigger value
  102058. */
  102059. rightTrigger: number;
  102060. /**
  102061. * Defines the callback to call when a button is pressed
  102062. * @param callback defines the callback to use
  102063. */
  102064. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  102065. /**
  102066. * Defines the callback to call when a button is released
  102067. * @param callback defines the callback to use
  102068. */
  102069. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  102070. /**
  102071. * Defines the callback to call when a pad is pressed
  102072. * @param callback defines the callback to use
  102073. */
  102074. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  102075. /**
  102076. * Defines the callback to call when a pad is released
  102077. * @param callback defines the callback to use
  102078. */
  102079. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  102080. private _setButtonValue;
  102081. private _setDPadValue;
  102082. /**
  102083. * Gets the value of the `A` button
  102084. */
  102085. /**
  102086. * Sets the value of the `A` button
  102087. */
  102088. buttonA: number;
  102089. /**
  102090. * Gets the value of the `B` button
  102091. */
  102092. /**
  102093. * Sets the value of the `B` button
  102094. */
  102095. buttonB: number;
  102096. /**
  102097. * Gets the value of the `X` button
  102098. */
  102099. /**
  102100. * Sets the value of the `X` button
  102101. */
  102102. buttonX: number;
  102103. /**
  102104. * Gets the value of the `Y` button
  102105. */
  102106. /**
  102107. * Sets the value of the `Y` button
  102108. */
  102109. buttonY: number;
  102110. /**
  102111. * Gets the value of the `Start` button
  102112. */
  102113. /**
  102114. * Sets the value of the `Start` button
  102115. */
  102116. buttonStart: number;
  102117. /**
  102118. * Gets the value of the `Back` button
  102119. */
  102120. /**
  102121. * Sets the value of the `Back` button
  102122. */
  102123. buttonBack: number;
  102124. /**
  102125. * Gets the value of the `Left` button
  102126. */
  102127. /**
  102128. * Sets the value of the `Left` button
  102129. */
  102130. buttonLB: number;
  102131. /**
  102132. * Gets the value of the `Right` button
  102133. */
  102134. /**
  102135. * Sets the value of the `Right` button
  102136. */
  102137. buttonRB: number;
  102138. /**
  102139. * Gets the value of the Left joystick
  102140. */
  102141. /**
  102142. * Sets the value of the Left joystick
  102143. */
  102144. buttonLeftStick: number;
  102145. /**
  102146. * Gets the value of the Right joystick
  102147. */
  102148. /**
  102149. * Sets the value of the Right joystick
  102150. */
  102151. buttonRightStick: number;
  102152. /**
  102153. * Gets the value of D-pad up
  102154. */
  102155. /**
  102156. * Sets the value of D-pad up
  102157. */
  102158. dPadUp: number;
  102159. /**
  102160. * Gets the value of D-pad down
  102161. */
  102162. /**
  102163. * Sets the value of D-pad down
  102164. */
  102165. dPadDown: number;
  102166. /**
  102167. * Gets the value of D-pad left
  102168. */
  102169. /**
  102170. * Sets the value of D-pad left
  102171. */
  102172. dPadLeft: number;
  102173. /**
  102174. * Gets the value of D-pad right
  102175. */
  102176. /**
  102177. * Sets the value of D-pad right
  102178. */
  102179. dPadRight: number;
  102180. /**
  102181. * Force the gamepad to synchronize with device values
  102182. */
  102183. update(): void;
  102184. /**
  102185. * Disposes the gamepad
  102186. */
  102187. dispose(): void;
  102188. }
  102189. }
  102190. declare module BABYLON {
  102191. /**
  102192. * Manager for handling gamepads
  102193. */
  102194. export class GamepadManager {
  102195. private _scene?;
  102196. private _babylonGamepads;
  102197. private _oneGamepadConnected;
  102198. /** @hidden */
  102199. _isMonitoring: boolean;
  102200. private _gamepadEventSupported;
  102201. private _gamepadSupport;
  102202. /**
  102203. * observable to be triggered when the gamepad controller has been connected
  102204. */
  102205. onGamepadConnectedObservable: Observable<Gamepad>;
  102206. /**
  102207. * observable to be triggered when the gamepad controller has been disconnected
  102208. */
  102209. onGamepadDisconnectedObservable: Observable<Gamepad>;
  102210. private _onGamepadConnectedEvent;
  102211. private _onGamepadDisconnectedEvent;
  102212. /**
  102213. * Initializes the gamepad manager
  102214. * @param _scene BabylonJS scene
  102215. */
  102216. constructor(_scene?: Scene | undefined);
  102217. /**
  102218. * The gamepads in the game pad manager
  102219. */
  102220. readonly gamepads: Gamepad[];
  102221. /**
  102222. * Get the gamepad controllers based on type
  102223. * @param type The type of gamepad controller
  102224. * @returns Nullable gamepad
  102225. */
  102226. getGamepadByType(type?: number): Nullable<Gamepad>;
  102227. /**
  102228. * Disposes the gamepad manager
  102229. */
  102230. dispose(): void;
  102231. private _addNewGamepad;
  102232. private _startMonitoringGamepads;
  102233. private _stopMonitoringGamepads;
  102234. /** @hidden */
  102235. _checkGamepadsStatus(): void;
  102236. private _updateGamepadObjects;
  102237. }
  102238. }
  102239. declare module BABYLON {
  102240. interface Scene {
  102241. /** @hidden */
  102242. _gamepadManager: Nullable<GamepadManager>;
  102243. /**
  102244. * Gets the gamepad manager associated with the scene
  102245. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  102246. */
  102247. gamepadManager: GamepadManager;
  102248. }
  102249. /**
  102250. * Interface representing a free camera inputs manager
  102251. */
  102252. interface FreeCameraInputsManager {
  102253. /**
  102254. * Adds gamepad input support to the FreeCameraInputsManager.
  102255. * @returns the FreeCameraInputsManager
  102256. */
  102257. addGamepad(): FreeCameraInputsManager;
  102258. }
  102259. /**
  102260. * Interface representing an arc rotate camera inputs manager
  102261. */
  102262. interface ArcRotateCameraInputsManager {
  102263. /**
  102264. * Adds gamepad input support to the ArcRotateCamera InputManager.
  102265. * @returns the camera inputs manager
  102266. */
  102267. addGamepad(): ArcRotateCameraInputsManager;
  102268. }
  102269. /**
  102270. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  102271. */
  102272. export class GamepadSystemSceneComponent implements ISceneComponent {
  102273. /**
  102274. * The component name helpfull to identify the component in the list of scene components.
  102275. */
  102276. readonly name: string;
  102277. /**
  102278. * The scene the component belongs to.
  102279. */
  102280. scene: Scene;
  102281. /**
  102282. * Creates a new instance of the component for the given scene
  102283. * @param scene Defines the scene to register the component in
  102284. */
  102285. constructor(scene: Scene);
  102286. /**
  102287. * Registers the component in a given scene
  102288. */
  102289. register(): void;
  102290. /**
  102291. * Rebuilds the elements related to this component in case of
  102292. * context lost for instance.
  102293. */
  102294. rebuild(): void;
  102295. /**
  102296. * Disposes the component and the associated ressources
  102297. */
  102298. dispose(): void;
  102299. private _beforeCameraUpdate;
  102300. }
  102301. }
  102302. declare module BABYLON {
  102303. /**
  102304. * 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,
  102305. * which still works and will still be found in many Playgrounds.
  102306. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102307. */
  102308. export class UniversalCamera extends TouchCamera {
  102309. /**
  102310. * Defines the gamepad rotation sensiblity.
  102311. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  102312. */
  102313. gamepadAngularSensibility: number;
  102314. /**
  102315. * Defines the gamepad move sensiblity.
  102316. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  102317. */
  102318. gamepadMoveSensibility: number;
  102319. /**
  102320. * 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,
  102321. * which still works and will still be found in many Playgrounds.
  102322. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102323. * @param name Define the name of the camera in the scene
  102324. * @param position Define the start position of the camera in the scene
  102325. * @param scene Define the scene the camera belongs to
  102326. */
  102327. constructor(name: string, position: Vector3, scene: Scene);
  102328. /**
  102329. * Gets the current object class name.
  102330. * @return the class name
  102331. */
  102332. getClassName(): string;
  102333. }
  102334. }
  102335. declare module BABYLON {
  102336. /**
  102337. * This represents a FPS type of camera. This is only here for back compat purpose.
  102338. * Please use the UniversalCamera instead as both are identical.
  102339. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102340. */
  102341. export class GamepadCamera extends UniversalCamera {
  102342. /**
  102343. * Instantiates a new Gamepad Camera
  102344. * This represents a FPS type of camera. This is only here for back compat purpose.
  102345. * Please use the UniversalCamera instead as both are identical.
  102346. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  102347. * @param name Define the name of the camera in the scene
  102348. * @param position Define the start position of the camera in the scene
  102349. * @param scene Define the scene the camera belongs to
  102350. */
  102351. constructor(name: string, position: Vector3, scene: Scene);
  102352. /**
  102353. * Gets the current object class name.
  102354. * @return the class name
  102355. */
  102356. getClassName(): string;
  102357. }
  102358. }
  102359. declare module BABYLON {
  102360. /** @hidden */
  102361. export var passPixelShader: {
  102362. name: string;
  102363. shader: string;
  102364. };
  102365. }
  102366. declare module BABYLON {
  102367. /** @hidden */
  102368. export var passCubePixelShader: {
  102369. name: string;
  102370. shader: string;
  102371. };
  102372. }
  102373. declare module BABYLON {
  102374. /**
  102375. * PassPostProcess which produces an output the same as it's input
  102376. */
  102377. export class PassPostProcess extends PostProcess {
  102378. /**
  102379. * Creates the PassPostProcess
  102380. * @param name The name of the effect.
  102381. * @param options The required width/height ratio to downsize to before computing the render pass.
  102382. * @param camera The camera to apply the render pass to.
  102383. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102384. * @param engine The engine which the post process will be applied. (default: current engine)
  102385. * @param reusable If the post process can be reused on the same frame. (default: false)
  102386. * @param textureType The type of texture to be used when performing the post processing.
  102387. * @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)
  102388. */
  102389. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102390. }
  102391. /**
  102392. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  102393. */
  102394. export class PassCubePostProcess extends PostProcess {
  102395. private _face;
  102396. /**
  102397. * Gets or sets the cube face to display.
  102398. * * 0 is +X
  102399. * * 1 is -X
  102400. * * 2 is +Y
  102401. * * 3 is -Y
  102402. * * 4 is +Z
  102403. * * 5 is -Z
  102404. */
  102405. face: number;
  102406. /**
  102407. * Creates the PassCubePostProcess
  102408. * @param name The name of the effect.
  102409. * @param options The required width/height ratio to downsize to before computing the render pass.
  102410. * @param camera The camera to apply the render pass to.
  102411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102412. * @param engine The engine which the post process will be applied. (default: current engine)
  102413. * @param reusable If the post process can be reused on the same frame. (default: false)
  102414. * @param textureType The type of texture to be used when performing the post processing.
  102415. * @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)
  102416. */
  102417. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  102418. }
  102419. }
  102420. declare module BABYLON {
  102421. /** @hidden */
  102422. export var anaglyphPixelShader: {
  102423. name: string;
  102424. shader: string;
  102425. };
  102426. }
  102427. declare module BABYLON {
  102428. /**
  102429. * Postprocess used to generate anaglyphic rendering
  102430. */
  102431. export class AnaglyphPostProcess extends PostProcess {
  102432. private _passedProcess;
  102433. /**
  102434. * Creates a new AnaglyphPostProcess
  102435. * @param name defines postprocess name
  102436. * @param options defines creation options or target ratio scale
  102437. * @param rigCameras defines cameras using this postprocess
  102438. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  102439. * @param engine defines hosting engine
  102440. * @param reusable defines if the postprocess will be reused multiple times per frame
  102441. */
  102442. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  102443. }
  102444. }
  102445. declare module BABYLON {
  102446. /**
  102447. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  102448. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102449. */
  102450. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  102451. /**
  102452. * Creates a new AnaglyphArcRotateCamera
  102453. * @param name defines camera name
  102454. * @param alpha defines alpha angle (in radians)
  102455. * @param beta defines beta angle (in radians)
  102456. * @param radius defines radius
  102457. * @param target defines camera target
  102458. * @param interaxialDistance defines distance between each color axis
  102459. * @param scene defines the hosting scene
  102460. */
  102461. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  102462. /**
  102463. * Gets camera class name
  102464. * @returns AnaglyphArcRotateCamera
  102465. */
  102466. getClassName(): string;
  102467. }
  102468. }
  102469. declare module BABYLON {
  102470. /**
  102471. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  102472. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102473. */
  102474. export class AnaglyphFreeCamera extends FreeCamera {
  102475. /**
  102476. * Creates a new AnaglyphFreeCamera
  102477. * @param name defines camera name
  102478. * @param position defines initial position
  102479. * @param interaxialDistance defines distance between each color axis
  102480. * @param scene defines the hosting scene
  102481. */
  102482. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102483. /**
  102484. * Gets camera class name
  102485. * @returns AnaglyphFreeCamera
  102486. */
  102487. getClassName(): string;
  102488. }
  102489. }
  102490. declare module BABYLON {
  102491. /**
  102492. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  102493. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102494. */
  102495. export class AnaglyphGamepadCamera extends GamepadCamera {
  102496. /**
  102497. * Creates a new AnaglyphGamepadCamera
  102498. * @param name defines camera name
  102499. * @param position defines initial position
  102500. * @param interaxialDistance defines distance between each color axis
  102501. * @param scene defines the hosting scene
  102502. */
  102503. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102504. /**
  102505. * Gets camera class name
  102506. * @returns AnaglyphGamepadCamera
  102507. */
  102508. getClassName(): string;
  102509. }
  102510. }
  102511. declare module BABYLON {
  102512. /**
  102513. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  102514. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  102515. */
  102516. export class AnaglyphUniversalCamera extends UniversalCamera {
  102517. /**
  102518. * Creates a new AnaglyphUniversalCamera
  102519. * @param name defines camera name
  102520. * @param position defines initial position
  102521. * @param interaxialDistance defines distance between each color axis
  102522. * @param scene defines the hosting scene
  102523. */
  102524. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  102525. /**
  102526. * Gets camera class name
  102527. * @returns AnaglyphUniversalCamera
  102528. */
  102529. getClassName(): string;
  102530. }
  102531. }
  102532. declare module BABYLON {
  102533. /** @hidden */
  102534. export var stereoscopicInterlacePixelShader: {
  102535. name: string;
  102536. shader: string;
  102537. };
  102538. }
  102539. declare module BABYLON {
  102540. /**
  102541. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  102542. */
  102543. export class StereoscopicInterlacePostProcess extends PostProcess {
  102544. private _stepSize;
  102545. private _passedProcess;
  102546. /**
  102547. * Initializes a StereoscopicInterlacePostProcess
  102548. * @param name The name of the effect.
  102549. * @param rigCameras The rig cameras to be appled to the post process
  102550. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  102551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102552. * @param engine The engine which the post process will be applied. (default: current engine)
  102553. * @param reusable If the post process can be reused on the same frame. (default: false)
  102554. */
  102555. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  102556. }
  102557. }
  102558. declare module BABYLON {
  102559. /**
  102560. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  102561. * @see http://doc.babylonjs.com/features/cameras
  102562. */
  102563. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  102564. /**
  102565. * Creates a new StereoscopicArcRotateCamera
  102566. * @param name defines camera name
  102567. * @param alpha defines alpha angle (in radians)
  102568. * @param beta defines beta angle (in radians)
  102569. * @param radius defines radius
  102570. * @param target defines camera target
  102571. * @param interaxialDistance defines distance between each color axis
  102572. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102573. * @param scene defines the hosting scene
  102574. */
  102575. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102576. /**
  102577. * Gets camera class name
  102578. * @returns StereoscopicArcRotateCamera
  102579. */
  102580. getClassName(): string;
  102581. }
  102582. }
  102583. declare module BABYLON {
  102584. /**
  102585. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  102586. * @see http://doc.babylonjs.com/features/cameras
  102587. */
  102588. export class StereoscopicFreeCamera extends FreeCamera {
  102589. /**
  102590. * Creates a new StereoscopicFreeCamera
  102591. * @param name defines camera name
  102592. * @param position defines initial position
  102593. * @param interaxialDistance defines distance between each color axis
  102594. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102595. * @param scene defines the hosting scene
  102596. */
  102597. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102598. /**
  102599. * Gets camera class name
  102600. * @returns StereoscopicFreeCamera
  102601. */
  102602. getClassName(): string;
  102603. }
  102604. }
  102605. declare module BABYLON {
  102606. /**
  102607. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  102608. * @see http://doc.babylonjs.com/features/cameras
  102609. */
  102610. export class StereoscopicGamepadCamera extends GamepadCamera {
  102611. /**
  102612. * Creates a new StereoscopicGamepadCamera
  102613. * @param name defines camera name
  102614. * @param position defines initial position
  102615. * @param interaxialDistance defines distance between each color axis
  102616. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102617. * @param scene defines the hosting scene
  102618. */
  102619. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102620. /**
  102621. * Gets camera class name
  102622. * @returns StereoscopicGamepadCamera
  102623. */
  102624. getClassName(): string;
  102625. }
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  102630. * @see http://doc.babylonjs.com/features/cameras
  102631. */
  102632. export class StereoscopicUniversalCamera extends UniversalCamera {
  102633. /**
  102634. * Creates a new StereoscopicUniversalCamera
  102635. * @param name defines camera name
  102636. * @param position defines initial position
  102637. * @param interaxialDistance defines distance between each color axis
  102638. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  102639. * @param scene defines the hosting scene
  102640. */
  102641. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  102642. /**
  102643. * Gets camera class name
  102644. * @returns StereoscopicUniversalCamera
  102645. */
  102646. getClassName(): string;
  102647. }
  102648. }
  102649. declare module BABYLON {
  102650. /**
  102651. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  102652. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102653. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102654. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102655. */
  102656. export class VirtualJoysticksCamera extends FreeCamera {
  102657. /**
  102658. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  102659. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  102660. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  102661. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  102662. * @param name Define the name of the camera in the scene
  102663. * @param position Define the start position of the camera in the scene
  102664. * @param scene Define the scene the camera belongs to
  102665. */
  102666. constructor(name: string, position: Vector3, scene: Scene);
  102667. /**
  102668. * Gets the current object class name.
  102669. * @return the class name
  102670. */
  102671. getClassName(): string;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. /**
  102676. * This represents all the required metrics to create a VR camera.
  102677. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  102678. */
  102679. export class VRCameraMetrics {
  102680. /**
  102681. * Define the horizontal resolution off the screen.
  102682. */
  102683. hResolution: number;
  102684. /**
  102685. * Define the vertical resolution off the screen.
  102686. */
  102687. vResolution: number;
  102688. /**
  102689. * Define the horizontal screen size.
  102690. */
  102691. hScreenSize: number;
  102692. /**
  102693. * Define the vertical screen size.
  102694. */
  102695. vScreenSize: number;
  102696. /**
  102697. * Define the vertical screen center position.
  102698. */
  102699. vScreenCenter: number;
  102700. /**
  102701. * Define the distance of the eyes to the screen.
  102702. */
  102703. eyeToScreenDistance: number;
  102704. /**
  102705. * Define the distance between both lenses
  102706. */
  102707. lensSeparationDistance: number;
  102708. /**
  102709. * Define the distance between both viewer's eyes.
  102710. */
  102711. interpupillaryDistance: number;
  102712. /**
  102713. * Define the distortion factor of the VR postprocess.
  102714. * Please, touch with care.
  102715. */
  102716. distortionK: number[];
  102717. /**
  102718. * Define the chromatic aberration correction factors for the VR post process.
  102719. */
  102720. chromaAbCorrection: number[];
  102721. /**
  102722. * Define the scale factor of the post process.
  102723. * The smaller the better but the slower.
  102724. */
  102725. postProcessScaleFactor: number;
  102726. /**
  102727. * Define an offset for the lens center.
  102728. */
  102729. lensCenterOffset: number;
  102730. /**
  102731. * Define if the current vr camera should compensate the distortion of the lense or not.
  102732. */
  102733. compensateDistortion: boolean;
  102734. /**
  102735. * Defines if multiview should be enabled when rendering (Default: false)
  102736. */
  102737. multiviewEnabled: boolean;
  102738. /**
  102739. * Gets the rendering aspect ratio based on the provided resolutions.
  102740. */
  102741. readonly aspectRatio: number;
  102742. /**
  102743. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  102744. */
  102745. readonly aspectRatioFov: number;
  102746. /**
  102747. * @hidden
  102748. */
  102749. readonly leftHMatrix: Matrix;
  102750. /**
  102751. * @hidden
  102752. */
  102753. readonly rightHMatrix: Matrix;
  102754. /**
  102755. * @hidden
  102756. */
  102757. readonly leftPreViewMatrix: Matrix;
  102758. /**
  102759. * @hidden
  102760. */
  102761. readonly rightPreViewMatrix: Matrix;
  102762. /**
  102763. * Get the default VRMetrics based on the most generic setup.
  102764. * @returns the default vr metrics
  102765. */
  102766. static GetDefault(): VRCameraMetrics;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /** @hidden */
  102771. export var vrDistortionCorrectionPixelShader: {
  102772. name: string;
  102773. shader: string;
  102774. };
  102775. }
  102776. declare module BABYLON {
  102777. /**
  102778. * VRDistortionCorrectionPostProcess used for mobile VR
  102779. */
  102780. export class VRDistortionCorrectionPostProcess extends PostProcess {
  102781. private _isRightEye;
  102782. private _distortionFactors;
  102783. private _postProcessScaleFactor;
  102784. private _lensCenterOffset;
  102785. private _scaleIn;
  102786. private _scaleFactor;
  102787. private _lensCenter;
  102788. /**
  102789. * Initializes the VRDistortionCorrectionPostProcess
  102790. * @param name The name of the effect.
  102791. * @param camera The camera to apply the render pass to.
  102792. * @param isRightEye If this is for the right eye distortion
  102793. * @param vrMetrics All the required metrics for the VR camera
  102794. */
  102795. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  102796. }
  102797. }
  102798. declare module BABYLON {
  102799. /**
  102800. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  102801. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102802. */
  102803. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  102804. /**
  102805. * Creates a new VRDeviceOrientationArcRotateCamera
  102806. * @param name defines camera name
  102807. * @param alpha defines the camera rotation along the logitudinal axis
  102808. * @param beta defines the camera rotation along the latitudinal axis
  102809. * @param radius defines the camera distance from its target
  102810. * @param target defines the camera target
  102811. * @param scene defines the scene the camera belongs to
  102812. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102813. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102814. */
  102815. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102816. /**
  102817. * Gets camera class name
  102818. * @returns VRDeviceOrientationArcRotateCamera
  102819. */
  102820. getClassName(): string;
  102821. }
  102822. }
  102823. declare module BABYLON {
  102824. /**
  102825. * Camera used to simulate VR rendering (based on FreeCamera)
  102826. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102827. */
  102828. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  102829. /**
  102830. * Creates a new VRDeviceOrientationFreeCamera
  102831. * @param name defines camera name
  102832. * @param position defines the start position of the camera
  102833. * @param scene defines the scene the camera belongs to
  102834. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102835. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102836. */
  102837. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102838. /**
  102839. * Gets camera class name
  102840. * @returns VRDeviceOrientationFreeCamera
  102841. */
  102842. getClassName(): string;
  102843. }
  102844. }
  102845. declare module BABYLON {
  102846. /**
  102847. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  102848. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  102849. */
  102850. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  102851. /**
  102852. * Creates a new VRDeviceOrientationGamepadCamera
  102853. * @param name defines camera name
  102854. * @param position defines the start position of the camera
  102855. * @param scene defines the scene the camera belongs to
  102856. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  102857. * @param vrCameraMetrics defines the vr metrics associated to the camera
  102858. */
  102859. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  102860. /**
  102861. * Gets camera class name
  102862. * @returns VRDeviceOrientationGamepadCamera
  102863. */
  102864. getClassName(): string;
  102865. }
  102866. }
  102867. declare module BABYLON {
  102868. /**
  102869. * Base class of materials working in push mode in babylon JS
  102870. * @hidden
  102871. */
  102872. export class PushMaterial extends Material {
  102873. protected _activeEffect: Effect;
  102874. protected _normalMatrix: Matrix;
  102875. /**
  102876. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  102877. * This means that the material can keep using a previous shader while a new one is being compiled.
  102878. * This is mostly used when shader parallel compilation is supported (true by default)
  102879. */
  102880. allowShaderHotSwapping: boolean;
  102881. constructor(name: string, scene: Scene);
  102882. getEffect(): Effect;
  102883. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102884. /**
  102885. * Binds the given world matrix to the active effect
  102886. *
  102887. * @param world the matrix to bind
  102888. */
  102889. bindOnlyWorldMatrix(world: Matrix): void;
  102890. /**
  102891. * Binds the given normal matrix to the active effect
  102892. *
  102893. * @param normalMatrix the matrix to bind
  102894. */
  102895. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102896. bind(world: Matrix, mesh?: Mesh): void;
  102897. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102898. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102899. }
  102900. }
  102901. declare module BABYLON {
  102902. /**
  102903. * This groups all the flags used to control the materials channel.
  102904. */
  102905. export class MaterialFlags {
  102906. private static _DiffuseTextureEnabled;
  102907. /**
  102908. * Are diffuse textures enabled in the application.
  102909. */
  102910. static DiffuseTextureEnabled: boolean;
  102911. private static _AmbientTextureEnabled;
  102912. /**
  102913. * Are ambient textures enabled in the application.
  102914. */
  102915. static AmbientTextureEnabled: boolean;
  102916. private static _OpacityTextureEnabled;
  102917. /**
  102918. * Are opacity textures enabled in the application.
  102919. */
  102920. static OpacityTextureEnabled: boolean;
  102921. private static _ReflectionTextureEnabled;
  102922. /**
  102923. * Are reflection textures enabled in the application.
  102924. */
  102925. static ReflectionTextureEnabled: boolean;
  102926. private static _EmissiveTextureEnabled;
  102927. /**
  102928. * Are emissive textures enabled in the application.
  102929. */
  102930. static EmissiveTextureEnabled: boolean;
  102931. private static _SpecularTextureEnabled;
  102932. /**
  102933. * Are specular textures enabled in the application.
  102934. */
  102935. static SpecularTextureEnabled: boolean;
  102936. private static _BumpTextureEnabled;
  102937. /**
  102938. * Are bump textures enabled in the application.
  102939. */
  102940. static BumpTextureEnabled: boolean;
  102941. private static _LightmapTextureEnabled;
  102942. /**
  102943. * Are lightmap textures enabled in the application.
  102944. */
  102945. static LightmapTextureEnabled: boolean;
  102946. private static _RefractionTextureEnabled;
  102947. /**
  102948. * Are refraction textures enabled in the application.
  102949. */
  102950. static RefractionTextureEnabled: boolean;
  102951. private static _ColorGradingTextureEnabled;
  102952. /**
  102953. * Are color grading textures enabled in the application.
  102954. */
  102955. static ColorGradingTextureEnabled: boolean;
  102956. private static _FresnelEnabled;
  102957. /**
  102958. * Are fresnels enabled in the application.
  102959. */
  102960. static FresnelEnabled: boolean;
  102961. private static _ClearCoatTextureEnabled;
  102962. /**
  102963. * Are clear coat textures enabled in the application.
  102964. */
  102965. static ClearCoatTextureEnabled: boolean;
  102966. private static _ClearCoatBumpTextureEnabled;
  102967. /**
  102968. * Are clear coat bump textures enabled in the application.
  102969. */
  102970. static ClearCoatBumpTextureEnabled: boolean;
  102971. private static _ClearCoatTintTextureEnabled;
  102972. /**
  102973. * Are clear coat tint textures enabled in the application.
  102974. */
  102975. static ClearCoatTintTextureEnabled: boolean;
  102976. private static _SheenTextureEnabled;
  102977. /**
  102978. * Are sheen textures enabled in the application.
  102979. */
  102980. static SheenTextureEnabled: boolean;
  102981. private static _AnisotropicTextureEnabled;
  102982. /**
  102983. * Are anisotropic textures enabled in the application.
  102984. */
  102985. static AnisotropicTextureEnabled: boolean;
  102986. private static _ThicknessTextureEnabled;
  102987. /**
  102988. * Are thickness textures enabled in the application.
  102989. */
  102990. static ThicknessTextureEnabled: boolean;
  102991. }
  102992. }
  102993. declare module BABYLON {
  102994. /** @hidden */
  102995. export var defaultFragmentDeclaration: {
  102996. name: string;
  102997. shader: string;
  102998. };
  102999. }
  103000. declare module BABYLON {
  103001. /** @hidden */
  103002. export var defaultUboDeclaration: {
  103003. name: string;
  103004. shader: string;
  103005. };
  103006. }
  103007. declare module BABYLON {
  103008. /** @hidden */
  103009. export var lightFragmentDeclaration: {
  103010. name: string;
  103011. shader: string;
  103012. };
  103013. }
  103014. declare module BABYLON {
  103015. /** @hidden */
  103016. export var lightUboDeclaration: {
  103017. name: string;
  103018. shader: string;
  103019. };
  103020. }
  103021. declare module BABYLON {
  103022. /** @hidden */
  103023. export var lightsFragmentFunctions: {
  103024. name: string;
  103025. shader: string;
  103026. };
  103027. }
  103028. declare module BABYLON {
  103029. /** @hidden */
  103030. export var shadowsFragmentFunctions: {
  103031. name: string;
  103032. shader: string;
  103033. };
  103034. }
  103035. declare module BABYLON {
  103036. /** @hidden */
  103037. export var fresnelFunction: {
  103038. name: string;
  103039. shader: string;
  103040. };
  103041. }
  103042. declare module BABYLON {
  103043. /** @hidden */
  103044. export var reflectionFunction: {
  103045. name: string;
  103046. shader: string;
  103047. };
  103048. }
  103049. declare module BABYLON {
  103050. /** @hidden */
  103051. export var bumpFragmentFunctions: {
  103052. name: string;
  103053. shader: string;
  103054. };
  103055. }
  103056. declare module BABYLON {
  103057. /** @hidden */
  103058. export var logDepthDeclaration: {
  103059. name: string;
  103060. shader: string;
  103061. };
  103062. }
  103063. declare module BABYLON {
  103064. /** @hidden */
  103065. export var bumpFragment: {
  103066. name: string;
  103067. shader: string;
  103068. };
  103069. }
  103070. declare module BABYLON {
  103071. /** @hidden */
  103072. export var depthPrePass: {
  103073. name: string;
  103074. shader: string;
  103075. };
  103076. }
  103077. declare module BABYLON {
  103078. /** @hidden */
  103079. export var lightFragment: {
  103080. name: string;
  103081. shader: string;
  103082. };
  103083. }
  103084. declare module BABYLON {
  103085. /** @hidden */
  103086. export var logDepthFragment: {
  103087. name: string;
  103088. shader: string;
  103089. };
  103090. }
  103091. declare module BABYLON {
  103092. /** @hidden */
  103093. export var defaultPixelShader: {
  103094. name: string;
  103095. shader: string;
  103096. };
  103097. }
  103098. declare module BABYLON {
  103099. /** @hidden */
  103100. export var defaultVertexDeclaration: {
  103101. name: string;
  103102. shader: string;
  103103. };
  103104. }
  103105. declare module BABYLON {
  103106. /** @hidden */
  103107. export var bumpVertexDeclaration: {
  103108. name: string;
  103109. shader: string;
  103110. };
  103111. }
  103112. declare module BABYLON {
  103113. /** @hidden */
  103114. export var bumpVertex: {
  103115. name: string;
  103116. shader: string;
  103117. };
  103118. }
  103119. declare module BABYLON {
  103120. /** @hidden */
  103121. export var fogVertex: {
  103122. name: string;
  103123. shader: string;
  103124. };
  103125. }
  103126. declare module BABYLON {
  103127. /** @hidden */
  103128. export var shadowsVertex: {
  103129. name: string;
  103130. shader: string;
  103131. };
  103132. }
  103133. declare module BABYLON {
  103134. /** @hidden */
  103135. export var pointCloudVertex: {
  103136. name: string;
  103137. shader: string;
  103138. };
  103139. }
  103140. declare module BABYLON {
  103141. /** @hidden */
  103142. export var logDepthVertex: {
  103143. name: string;
  103144. shader: string;
  103145. };
  103146. }
  103147. declare module BABYLON {
  103148. /** @hidden */
  103149. export var defaultVertexShader: {
  103150. name: string;
  103151. shader: string;
  103152. };
  103153. }
  103154. declare module BABYLON {
  103155. /** @hidden */
  103156. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103157. MAINUV1: boolean;
  103158. MAINUV2: boolean;
  103159. DIFFUSE: boolean;
  103160. DIFFUSEDIRECTUV: number;
  103161. AMBIENT: boolean;
  103162. AMBIENTDIRECTUV: number;
  103163. OPACITY: boolean;
  103164. OPACITYDIRECTUV: number;
  103165. OPACITYRGB: boolean;
  103166. REFLECTION: boolean;
  103167. EMISSIVE: boolean;
  103168. EMISSIVEDIRECTUV: number;
  103169. SPECULAR: boolean;
  103170. SPECULARDIRECTUV: number;
  103171. BUMP: boolean;
  103172. BUMPDIRECTUV: number;
  103173. PARALLAX: boolean;
  103174. PARALLAXOCCLUSION: boolean;
  103175. SPECULAROVERALPHA: boolean;
  103176. CLIPPLANE: boolean;
  103177. CLIPPLANE2: boolean;
  103178. CLIPPLANE3: boolean;
  103179. CLIPPLANE4: boolean;
  103180. ALPHATEST: boolean;
  103181. DEPTHPREPASS: boolean;
  103182. ALPHAFROMDIFFUSE: boolean;
  103183. POINTSIZE: boolean;
  103184. FOG: boolean;
  103185. SPECULARTERM: boolean;
  103186. DIFFUSEFRESNEL: boolean;
  103187. OPACITYFRESNEL: boolean;
  103188. REFLECTIONFRESNEL: boolean;
  103189. REFRACTIONFRESNEL: boolean;
  103190. EMISSIVEFRESNEL: boolean;
  103191. FRESNEL: boolean;
  103192. NORMAL: boolean;
  103193. UV1: boolean;
  103194. UV2: boolean;
  103195. VERTEXCOLOR: boolean;
  103196. VERTEXALPHA: boolean;
  103197. NUM_BONE_INFLUENCERS: number;
  103198. BonesPerMesh: number;
  103199. BONETEXTURE: boolean;
  103200. INSTANCES: boolean;
  103201. GLOSSINESS: boolean;
  103202. ROUGHNESS: boolean;
  103203. EMISSIVEASILLUMINATION: boolean;
  103204. LINKEMISSIVEWITHDIFFUSE: boolean;
  103205. REFLECTIONFRESNELFROMSPECULAR: boolean;
  103206. LIGHTMAP: boolean;
  103207. LIGHTMAPDIRECTUV: number;
  103208. OBJECTSPACE_NORMALMAP: boolean;
  103209. USELIGHTMAPASSHADOWMAP: boolean;
  103210. REFLECTIONMAP_3D: boolean;
  103211. REFLECTIONMAP_SPHERICAL: boolean;
  103212. REFLECTIONMAP_PLANAR: boolean;
  103213. REFLECTIONMAP_CUBIC: boolean;
  103214. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  103215. REFLECTIONMAP_PROJECTION: boolean;
  103216. REFLECTIONMAP_SKYBOX: boolean;
  103217. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  103218. REFLECTIONMAP_EXPLICIT: boolean;
  103219. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  103220. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  103221. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  103222. INVERTCUBICMAP: boolean;
  103223. LOGARITHMICDEPTH: boolean;
  103224. REFRACTION: boolean;
  103225. REFRACTIONMAP_3D: boolean;
  103226. REFLECTIONOVERALPHA: boolean;
  103227. TWOSIDEDLIGHTING: boolean;
  103228. SHADOWFLOAT: boolean;
  103229. MORPHTARGETS: boolean;
  103230. MORPHTARGETS_NORMAL: boolean;
  103231. MORPHTARGETS_TANGENT: boolean;
  103232. MORPHTARGETS_UV: boolean;
  103233. NUM_MORPH_INFLUENCERS: number;
  103234. NONUNIFORMSCALING: boolean;
  103235. PREMULTIPLYALPHA: boolean;
  103236. IMAGEPROCESSING: boolean;
  103237. VIGNETTE: boolean;
  103238. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103239. VIGNETTEBLENDMODEOPAQUE: boolean;
  103240. TONEMAPPING: boolean;
  103241. TONEMAPPING_ACES: boolean;
  103242. CONTRAST: boolean;
  103243. COLORCURVES: boolean;
  103244. COLORGRADING: boolean;
  103245. COLORGRADING3D: boolean;
  103246. SAMPLER3DGREENDEPTH: boolean;
  103247. SAMPLER3DBGRMAP: boolean;
  103248. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103249. MULTIVIEW: boolean;
  103250. /**
  103251. * If the reflection texture on this material is in linear color space
  103252. * @hidden
  103253. */
  103254. IS_REFLECTION_LINEAR: boolean;
  103255. /**
  103256. * If the refraction texture on this material is in linear color space
  103257. * @hidden
  103258. */
  103259. IS_REFRACTION_LINEAR: boolean;
  103260. EXPOSURE: boolean;
  103261. constructor();
  103262. setReflectionMode(modeToEnable: string): void;
  103263. }
  103264. /**
  103265. * This is the default material used in Babylon. It is the best trade off between quality
  103266. * and performances.
  103267. * @see http://doc.babylonjs.com/babylon101/materials
  103268. */
  103269. export class StandardMaterial extends PushMaterial {
  103270. private _diffuseTexture;
  103271. /**
  103272. * The basic texture of the material as viewed under a light.
  103273. */
  103274. diffuseTexture: Nullable<BaseTexture>;
  103275. private _ambientTexture;
  103276. /**
  103277. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  103278. */
  103279. ambientTexture: Nullable<BaseTexture>;
  103280. private _opacityTexture;
  103281. /**
  103282. * Define the transparency of the material from a texture.
  103283. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  103284. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  103285. */
  103286. opacityTexture: Nullable<BaseTexture>;
  103287. private _reflectionTexture;
  103288. /**
  103289. * Define the texture used to display the reflection.
  103290. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103291. */
  103292. reflectionTexture: Nullable<BaseTexture>;
  103293. private _emissiveTexture;
  103294. /**
  103295. * Define texture of the material as if self lit.
  103296. * This will be mixed in the final result even in the absence of light.
  103297. */
  103298. emissiveTexture: Nullable<BaseTexture>;
  103299. private _specularTexture;
  103300. /**
  103301. * Define how the color and intensity of the highlight given by the light in the material.
  103302. */
  103303. specularTexture: Nullable<BaseTexture>;
  103304. private _bumpTexture;
  103305. /**
  103306. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  103307. * 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.
  103308. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  103309. */
  103310. bumpTexture: Nullable<BaseTexture>;
  103311. private _lightmapTexture;
  103312. /**
  103313. * Complex lighting can be computationally expensive to compute at runtime.
  103314. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  103315. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  103316. */
  103317. lightmapTexture: Nullable<BaseTexture>;
  103318. private _refractionTexture;
  103319. /**
  103320. * Define the texture used to display the refraction.
  103321. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103322. */
  103323. refractionTexture: Nullable<BaseTexture>;
  103324. /**
  103325. * The color of the material lit by the environmental background lighting.
  103326. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  103327. */
  103328. ambientColor: Color3;
  103329. /**
  103330. * The basic color of the material as viewed under a light.
  103331. */
  103332. diffuseColor: Color3;
  103333. /**
  103334. * Define how the color and intensity of the highlight given by the light in the material.
  103335. */
  103336. specularColor: Color3;
  103337. /**
  103338. * Define the color of the material as if self lit.
  103339. * This will be mixed in the final result even in the absence of light.
  103340. */
  103341. emissiveColor: Color3;
  103342. /**
  103343. * Defines how sharp are the highlights in the material.
  103344. * The bigger the value the sharper giving a more glossy feeling to the result.
  103345. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  103346. */
  103347. specularPower: number;
  103348. private _useAlphaFromDiffuseTexture;
  103349. /**
  103350. * Does the transparency come from the diffuse texture alpha channel.
  103351. */
  103352. useAlphaFromDiffuseTexture: boolean;
  103353. private _useEmissiveAsIllumination;
  103354. /**
  103355. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  103356. */
  103357. useEmissiveAsIllumination: boolean;
  103358. private _linkEmissiveWithDiffuse;
  103359. /**
  103360. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  103361. * the emissive level when the final color is close to one.
  103362. */
  103363. linkEmissiveWithDiffuse: boolean;
  103364. private _useSpecularOverAlpha;
  103365. /**
  103366. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  103367. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  103368. */
  103369. useSpecularOverAlpha: boolean;
  103370. private _useReflectionOverAlpha;
  103371. /**
  103372. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  103373. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  103374. */
  103375. useReflectionOverAlpha: boolean;
  103376. private _disableLighting;
  103377. /**
  103378. * Does lights from the scene impacts this material.
  103379. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  103380. */
  103381. disableLighting: boolean;
  103382. private _useObjectSpaceNormalMap;
  103383. /**
  103384. * Allows using an object space normal map (instead of tangent space).
  103385. */
  103386. useObjectSpaceNormalMap: boolean;
  103387. private _useParallax;
  103388. /**
  103389. * Is parallax enabled or not.
  103390. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103391. */
  103392. useParallax: boolean;
  103393. private _useParallaxOcclusion;
  103394. /**
  103395. * Is parallax occlusion enabled or not.
  103396. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  103397. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  103398. */
  103399. useParallaxOcclusion: boolean;
  103400. /**
  103401. * 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.
  103402. */
  103403. parallaxScaleBias: number;
  103404. private _roughness;
  103405. /**
  103406. * Helps to define how blurry the reflections should appears in the material.
  103407. */
  103408. roughness: number;
  103409. /**
  103410. * In case of refraction, define the value of the index of refraction.
  103411. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103412. */
  103413. indexOfRefraction: number;
  103414. /**
  103415. * Invert the refraction texture alongside the y axis.
  103416. * It can be useful with procedural textures or probe for instance.
  103417. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  103418. */
  103419. invertRefractionY: boolean;
  103420. /**
  103421. * Defines the alpha limits in alpha test mode.
  103422. */
  103423. alphaCutOff: number;
  103424. private _useLightmapAsShadowmap;
  103425. /**
  103426. * In case of light mapping, define whether the map contains light or shadow informations.
  103427. */
  103428. useLightmapAsShadowmap: boolean;
  103429. private _diffuseFresnelParameters;
  103430. /**
  103431. * Define the diffuse fresnel parameters of the material.
  103432. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103433. */
  103434. diffuseFresnelParameters: FresnelParameters;
  103435. private _opacityFresnelParameters;
  103436. /**
  103437. * Define the opacity fresnel parameters of the material.
  103438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103439. */
  103440. opacityFresnelParameters: FresnelParameters;
  103441. private _reflectionFresnelParameters;
  103442. /**
  103443. * Define the reflection fresnel parameters of the material.
  103444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103445. */
  103446. reflectionFresnelParameters: FresnelParameters;
  103447. private _refractionFresnelParameters;
  103448. /**
  103449. * Define the refraction fresnel parameters of the material.
  103450. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103451. */
  103452. refractionFresnelParameters: FresnelParameters;
  103453. private _emissiveFresnelParameters;
  103454. /**
  103455. * Define the emissive fresnel parameters of the material.
  103456. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103457. */
  103458. emissiveFresnelParameters: FresnelParameters;
  103459. private _useReflectionFresnelFromSpecular;
  103460. /**
  103461. * If true automatically deducts the fresnels values from the material specularity.
  103462. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  103463. */
  103464. useReflectionFresnelFromSpecular: boolean;
  103465. private _useGlossinessFromSpecularMapAlpha;
  103466. /**
  103467. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  103468. */
  103469. useGlossinessFromSpecularMapAlpha: boolean;
  103470. private _maxSimultaneousLights;
  103471. /**
  103472. * Defines the maximum number of lights that can be used in the material
  103473. */
  103474. maxSimultaneousLights: number;
  103475. private _invertNormalMapX;
  103476. /**
  103477. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  103478. */
  103479. invertNormalMapX: boolean;
  103480. private _invertNormalMapY;
  103481. /**
  103482. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  103483. */
  103484. invertNormalMapY: boolean;
  103485. private _twoSidedLighting;
  103486. /**
  103487. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  103488. */
  103489. twoSidedLighting: boolean;
  103490. /**
  103491. * Default configuration related to image processing available in the standard Material.
  103492. */
  103493. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103494. /**
  103495. * Gets the image processing configuration used either in this material.
  103496. */
  103497. /**
  103498. * Sets the Default image processing configuration used either in the this material.
  103499. *
  103500. * If sets to null, the scene one is in use.
  103501. */
  103502. imageProcessingConfiguration: ImageProcessingConfiguration;
  103503. /**
  103504. * Keep track of the image processing observer to allow dispose and replace.
  103505. */
  103506. private _imageProcessingObserver;
  103507. /**
  103508. * Attaches a new image processing configuration to the Standard Material.
  103509. * @param configuration
  103510. */
  103511. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103512. /**
  103513. * Gets wether the color curves effect is enabled.
  103514. */
  103515. /**
  103516. * Sets wether the color curves effect is enabled.
  103517. */
  103518. cameraColorCurvesEnabled: boolean;
  103519. /**
  103520. * Gets wether the color grading effect is enabled.
  103521. */
  103522. /**
  103523. * Gets wether the color grading effect is enabled.
  103524. */
  103525. cameraColorGradingEnabled: boolean;
  103526. /**
  103527. * Gets wether tonemapping is enabled or not.
  103528. */
  103529. /**
  103530. * Sets wether tonemapping is enabled or not
  103531. */
  103532. cameraToneMappingEnabled: boolean;
  103533. /**
  103534. * The camera exposure used on this material.
  103535. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103536. * This corresponds to a photographic exposure.
  103537. */
  103538. /**
  103539. * The camera exposure used on this material.
  103540. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  103541. * This corresponds to a photographic exposure.
  103542. */
  103543. cameraExposure: number;
  103544. /**
  103545. * Gets The camera contrast used on this material.
  103546. */
  103547. /**
  103548. * Sets The camera contrast used on this material.
  103549. */
  103550. cameraContrast: number;
  103551. /**
  103552. * Gets the Color Grading 2D Lookup Texture.
  103553. */
  103554. /**
  103555. * Sets the Color Grading 2D Lookup Texture.
  103556. */
  103557. cameraColorGradingTexture: Nullable<BaseTexture>;
  103558. /**
  103559. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103560. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103561. * 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;
  103562. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103563. */
  103564. /**
  103565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  103566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  103567. * 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;
  103568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  103569. */
  103570. cameraColorCurves: Nullable<ColorCurves>;
  103571. /**
  103572. * Custom callback helping to override the default shader used in the material.
  103573. */
  103574. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  103575. protected _renderTargets: SmartArray<RenderTargetTexture>;
  103576. protected _worldViewProjectionMatrix: Matrix;
  103577. protected _globalAmbientColor: Color3;
  103578. protected _useLogarithmicDepth: boolean;
  103579. /**
  103580. * Instantiates a new standard material.
  103581. * This is the default material used in Babylon. It is the best trade off between quality
  103582. * and performances.
  103583. * @see http://doc.babylonjs.com/babylon101/materials
  103584. * @param name Define the name of the material in the scene
  103585. * @param scene Define the scene the material belong to
  103586. */
  103587. constructor(name: string, scene: Scene);
  103588. /**
  103589. * Gets a boolean indicating that current material needs to register RTT
  103590. */
  103591. readonly hasRenderTargetTextures: boolean;
  103592. /**
  103593. * Gets the current class name of the material e.g. "StandardMaterial"
  103594. * Mainly use in serialization.
  103595. * @returns the class name
  103596. */
  103597. getClassName(): string;
  103598. /**
  103599. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  103600. * You can try switching to logarithmic depth.
  103601. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  103602. */
  103603. useLogarithmicDepth: boolean;
  103604. /**
  103605. * Specifies if the material will require alpha blending
  103606. * @returns a boolean specifying if alpha blending is needed
  103607. */
  103608. needAlphaBlending(): boolean;
  103609. /**
  103610. * Specifies if this material should be rendered in alpha test mode
  103611. * @returns a boolean specifying if an alpha test is needed.
  103612. */
  103613. needAlphaTesting(): boolean;
  103614. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  103615. /**
  103616. * Get the texture used for alpha test purpose.
  103617. * @returns the diffuse texture in case of the standard material.
  103618. */
  103619. getAlphaTestTexture(): Nullable<BaseTexture>;
  103620. /**
  103621. * Get if the submesh is ready to be used and all its information available.
  103622. * Child classes can use it to update shaders
  103623. * @param mesh defines the mesh to check
  103624. * @param subMesh defines which submesh to check
  103625. * @param useInstances specifies that instances should be used
  103626. * @returns a boolean indicating that the submesh is ready or not
  103627. */
  103628. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103629. /**
  103630. * Builds the material UBO layouts.
  103631. * Used internally during the effect preparation.
  103632. */
  103633. buildUniformLayout(): void;
  103634. /**
  103635. * Unbinds the material from the mesh
  103636. */
  103637. unbind(): void;
  103638. /**
  103639. * Binds the submesh to this material by preparing the effect and shader to draw
  103640. * @param world defines the world transformation matrix
  103641. * @param mesh defines the mesh containing the submesh
  103642. * @param subMesh defines the submesh to bind the material to
  103643. */
  103644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103645. /**
  103646. * Get the list of animatables in the material.
  103647. * @returns the list of animatables object used in the material
  103648. */
  103649. getAnimatables(): IAnimatable[];
  103650. /**
  103651. * Gets the active textures from the material
  103652. * @returns an array of textures
  103653. */
  103654. getActiveTextures(): BaseTexture[];
  103655. /**
  103656. * Specifies if the material uses a texture
  103657. * @param texture defines the texture to check against the material
  103658. * @returns a boolean specifying if the material uses the texture
  103659. */
  103660. hasTexture(texture: BaseTexture): boolean;
  103661. /**
  103662. * Disposes the material
  103663. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103664. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103665. */
  103666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  103667. /**
  103668. * Makes a duplicate of the material, and gives it a new name
  103669. * @param name defines the new name for the duplicated material
  103670. * @returns the cloned material
  103671. */
  103672. clone(name: string): StandardMaterial;
  103673. /**
  103674. * Serializes this material in a JSON representation
  103675. * @returns the serialized material object
  103676. */
  103677. serialize(): any;
  103678. /**
  103679. * Creates a standard material from parsed material data
  103680. * @param source defines the JSON representation of the material
  103681. * @param scene defines the hosting scene
  103682. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103683. * @returns a new standard material
  103684. */
  103685. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  103686. /**
  103687. * Are diffuse textures enabled in the application.
  103688. */
  103689. static DiffuseTextureEnabled: boolean;
  103690. /**
  103691. * Are ambient textures enabled in the application.
  103692. */
  103693. static AmbientTextureEnabled: boolean;
  103694. /**
  103695. * Are opacity textures enabled in the application.
  103696. */
  103697. static OpacityTextureEnabled: boolean;
  103698. /**
  103699. * Are reflection textures enabled in the application.
  103700. */
  103701. static ReflectionTextureEnabled: boolean;
  103702. /**
  103703. * Are emissive textures enabled in the application.
  103704. */
  103705. static EmissiveTextureEnabled: boolean;
  103706. /**
  103707. * Are specular textures enabled in the application.
  103708. */
  103709. static SpecularTextureEnabled: boolean;
  103710. /**
  103711. * Are bump textures enabled in the application.
  103712. */
  103713. static BumpTextureEnabled: boolean;
  103714. /**
  103715. * Are lightmap textures enabled in the application.
  103716. */
  103717. static LightmapTextureEnabled: boolean;
  103718. /**
  103719. * Are refraction textures enabled in the application.
  103720. */
  103721. static RefractionTextureEnabled: boolean;
  103722. /**
  103723. * Are color grading textures enabled in the application.
  103724. */
  103725. static ColorGradingTextureEnabled: boolean;
  103726. /**
  103727. * Are fresnels enabled in the application.
  103728. */
  103729. static FresnelEnabled: boolean;
  103730. }
  103731. }
  103732. declare module BABYLON {
  103733. /**
  103734. * A class extending Texture allowing drawing on a texture
  103735. * @see http://doc.babylonjs.com/how_to/dynamictexture
  103736. */
  103737. export class DynamicTexture extends Texture {
  103738. private _generateMipMaps;
  103739. private _canvas;
  103740. private _context;
  103741. private _engine;
  103742. /**
  103743. * Creates a DynamicTexture
  103744. * @param name defines the name of the texture
  103745. * @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
  103746. * @param scene defines the scene where you want the texture
  103747. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  103748. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  103749. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  103750. */
  103751. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  103752. /**
  103753. * Get the current class name of the texture useful for serialization or dynamic coding.
  103754. * @returns "DynamicTexture"
  103755. */
  103756. getClassName(): string;
  103757. /**
  103758. * Gets the current state of canRescale
  103759. */
  103760. readonly canRescale: boolean;
  103761. private _recreate;
  103762. /**
  103763. * Scales the texture
  103764. * @param ratio the scale factor to apply to both width and height
  103765. */
  103766. scale(ratio: number): void;
  103767. /**
  103768. * Resizes the texture
  103769. * @param width the new width
  103770. * @param height the new height
  103771. */
  103772. scaleTo(width: number, height: number): void;
  103773. /**
  103774. * Gets the context of the canvas used by the texture
  103775. * @returns the canvas context of the dynamic texture
  103776. */
  103777. getContext(): CanvasRenderingContext2D;
  103778. /**
  103779. * Clears the texture
  103780. */
  103781. clear(): void;
  103782. /**
  103783. * Updates the texture
  103784. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103785. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  103786. */
  103787. update(invertY?: boolean, premulAlpha?: boolean): void;
  103788. /**
  103789. * Draws text onto the texture
  103790. * @param text defines the text to be drawn
  103791. * @param x defines the placement of the text from the left
  103792. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  103793. * @param font defines the font to be used with font-style, font-size, font-name
  103794. * @param color defines the color used for the text
  103795. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  103796. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  103797. * @param update defines whether texture is immediately update (default is true)
  103798. */
  103799. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  103800. /**
  103801. * Clones the texture
  103802. * @returns the clone of the texture.
  103803. */
  103804. clone(): DynamicTexture;
  103805. /**
  103806. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  103807. * @returns a serialized dynamic texture object
  103808. */
  103809. serialize(): any;
  103810. /** @hidden */
  103811. _rebuild(): void;
  103812. }
  103813. }
  103814. declare module BABYLON {
  103815. /** @hidden */
  103816. export var imageProcessingPixelShader: {
  103817. name: string;
  103818. shader: string;
  103819. };
  103820. }
  103821. declare module BABYLON {
  103822. /**
  103823. * ImageProcessingPostProcess
  103824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103825. */
  103826. export class ImageProcessingPostProcess extends PostProcess {
  103827. /**
  103828. * Default configuration related to image processing available in the PBR Material.
  103829. */
  103830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103831. /**
  103832. * Gets the image processing configuration used either in this material.
  103833. */
  103834. /**
  103835. * Sets the Default image processing configuration used either in the this material.
  103836. *
  103837. * If sets to null, the scene one is in use.
  103838. */
  103839. imageProcessingConfiguration: ImageProcessingConfiguration;
  103840. /**
  103841. * Keep track of the image processing observer to allow dispose and replace.
  103842. */
  103843. private _imageProcessingObserver;
  103844. /**
  103845. * Attaches a new image processing configuration to the PBR Material.
  103846. * @param configuration
  103847. */
  103848. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103849. /**
  103850. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103851. */
  103852. /**
  103853. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103854. */
  103855. colorCurves: Nullable<ColorCurves>;
  103856. /**
  103857. * Gets wether the color curves effect is enabled.
  103858. */
  103859. /**
  103860. * Sets wether the color curves effect is enabled.
  103861. */
  103862. colorCurvesEnabled: boolean;
  103863. /**
  103864. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103865. */
  103866. /**
  103867. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103868. */
  103869. colorGradingTexture: Nullable<BaseTexture>;
  103870. /**
  103871. * Gets wether the color grading effect is enabled.
  103872. */
  103873. /**
  103874. * Gets wether the color grading effect is enabled.
  103875. */
  103876. colorGradingEnabled: boolean;
  103877. /**
  103878. * Gets exposure used in the effect.
  103879. */
  103880. /**
  103881. * Sets exposure used in the effect.
  103882. */
  103883. exposure: number;
  103884. /**
  103885. * Gets wether tonemapping is enabled or not.
  103886. */
  103887. /**
  103888. * Sets wether tonemapping is enabled or not
  103889. */
  103890. toneMappingEnabled: boolean;
  103891. /**
  103892. * Gets the type of tone mapping effect.
  103893. */
  103894. /**
  103895. * Sets the type of tone mapping effect.
  103896. */
  103897. toneMappingType: number;
  103898. /**
  103899. * Gets contrast used in the effect.
  103900. */
  103901. /**
  103902. * Sets contrast used in the effect.
  103903. */
  103904. contrast: number;
  103905. /**
  103906. * Gets Vignette stretch size.
  103907. */
  103908. /**
  103909. * Sets Vignette stretch size.
  103910. */
  103911. vignetteStretch: number;
  103912. /**
  103913. * Gets Vignette centre X Offset.
  103914. */
  103915. /**
  103916. * Sets Vignette centre X Offset.
  103917. */
  103918. vignetteCentreX: number;
  103919. /**
  103920. * Gets Vignette centre Y Offset.
  103921. */
  103922. /**
  103923. * Sets Vignette centre Y Offset.
  103924. */
  103925. vignetteCentreY: number;
  103926. /**
  103927. * Gets Vignette weight or intensity of the vignette effect.
  103928. */
  103929. /**
  103930. * Sets Vignette weight or intensity of the vignette effect.
  103931. */
  103932. vignetteWeight: number;
  103933. /**
  103934. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103935. * if vignetteEnabled is set to true.
  103936. */
  103937. /**
  103938. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103939. * if vignetteEnabled is set to true.
  103940. */
  103941. vignetteColor: Color4;
  103942. /**
  103943. * Gets Camera field of view used by the Vignette effect.
  103944. */
  103945. /**
  103946. * Sets Camera field of view used by the Vignette effect.
  103947. */
  103948. vignetteCameraFov: number;
  103949. /**
  103950. * Gets the vignette blend mode allowing different kind of effect.
  103951. */
  103952. /**
  103953. * Sets the vignette blend mode allowing different kind of effect.
  103954. */
  103955. vignetteBlendMode: number;
  103956. /**
  103957. * Gets wether the vignette effect is enabled.
  103958. */
  103959. /**
  103960. * Sets wether the vignette effect is enabled.
  103961. */
  103962. vignetteEnabled: boolean;
  103963. private _fromLinearSpace;
  103964. /**
  103965. * Gets wether the input of the processing is in Gamma or Linear Space.
  103966. */
  103967. /**
  103968. * Sets wether the input of the processing is in Gamma or Linear Space.
  103969. */
  103970. fromLinearSpace: boolean;
  103971. /**
  103972. * Defines cache preventing GC.
  103973. */
  103974. private _defines;
  103975. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103976. /**
  103977. * "ImageProcessingPostProcess"
  103978. * @returns "ImageProcessingPostProcess"
  103979. */
  103980. getClassName(): string;
  103981. protected _updateParameters(): void;
  103982. dispose(camera?: Camera): void;
  103983. }
  103984. }
  103985. declare module BABYLON {
  103986. /**
  103987. * Class containing static functions to help procedurally build meshes
  103988. */
  103989. export class GroundBuilder {
  103990. /**
  103991. * Creates a ground mesh
  103992. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103993. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103995. * @param name defines the name of the mesh
  103996. * @param options defines the options used to create the mesh
  103997. * @param scene defines the hosting scene
  103998. * @returns the ground mesh
  103999. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  104000. */
  104001. static CreateGround(name: string, options: {
  104002. width?: number;
  104003. height?: number;
  104004. subdivisions?: number;
  104005. subdivisionsX?: number;
  104006. subdivisionsY?: number;
  104007. updatable?: boolean;
  104008. }, scene: any): Mesh;
  104009. /**
  104010. * Creates a tiled ground mesh
  104011. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  104012. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  104013. * * 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
  104014. * * 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
  104015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104016. * @param name defines the name of the mesh
  104017. * @param options defines the options used to create the mesh
  104018. * @param scene defines the hosting scene
  104019. * @returns the tiled ground mesh
  104020. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  104021. */
  104022. static CreateTiledGround(name: string, options: {
  104023. xmin: number;
  104024. zmin: number;
  104025. xmax: number;
  104026. zmax: number;
  104027. subdivisions?: {
  104028. w: number;
  104029. h: number;
  104030. };
  104031. precision?: {
  104032. w: number;
  104033. h: number;
  104034. };
  104035. updatable?: boolean;
  104036. }, scene?: Nullable<Scene>): Mesh;
  104037. /**
  104038. * Creates a ground mesh from a height map
  104039. * * The parameter `url` sets the URL of the height map image resource.
  104040. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  104041. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  104042. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  104043. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  104044. * * 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.
  104045. * * 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).
  104046. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104048. * @param name defines the name of the mesh
  104049. * @param url defines the url to the height map
  104050. * @param options defines the options used to create the mesh
  104051. * @param scene defines the hosting scene
  104052. * @returns the ground mesh
  104053. * @see https://doc.babylonjs.com/babylon101/height_map
  104054. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104055. */
  104056. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104057. width?: number;
  104058. height?: number;
  104059. subdivisions?: number;
  104060. minHeight?: number;
  104061. maxHeight?: number;
  104062. colorFilter?: Color3;
  104063. alphaFilter?: number;
  104064. updatable?: boolean;
  104065. onReady?: (mesh: GroundMesh) => void;
  104066. }, scene?: Nullable<Scene>): GroundMesh;
  104067. }
  104068. }
  104069. declare module BABYLON {
  104070. /**
  104071. * Class containing static functions to help procedurally build meshes
  104072. */
  104073. export class TorusBuilder {
  104074. /**
  104075. * Creates a torus mesh
  104076. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  104077. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  104078. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  104079. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104082. * @param name defines the name of the mesh
  104083. * @param options defines the options used to create the mesh
  104084. * @param scene defines the hosting scene
  104085. * @returns the torus mesh
  104086. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  104087. */
  104088. static CreateTorus(name: string, options: {
  104089. diameter?: number;
  104090. thickness?: number;
  104091. tessellation?: number;
  104092. updatable?: boolean;
  104093. sideOrientation?: number;
  104094. frontUVs?: Vector4;
  104095. backUVs?: Vector4;
  104096. }, scene: any): Mesh;
  104097. }
  104098. }
  104099. declare module BABYLON {
  104100. /**
  104101. * Class containing static functions to help procedurally build meshes
  104102. */
  104103. export class CylinderBuilder {
  104104. /**
  104105. * Creates a cylinder or a cone mesh
  104106. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  104107. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  104108. * * 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.
  104109. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  104110. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  104111. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  104112. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  104113. * * 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).
  104114. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  104115. * * 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).
  104116. * * 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
  104117. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  104118. * * 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
  104119. * * 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.
  104120. * * If `enclose` is false, a ring surface is one element.
  104121. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  104122. * * 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
  104123. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104124. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104126. * @param name defines the name of the mesh
  104127. * @param options defines the options used to create the mesh
  104128. * @param scene defines the hosting scene
  104129. * @returns the cylinder mesh
  104130. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  104131. */
  104132. static CreateCylinder(name: string, options: {
  104133. height?: number;
  104134. diameterTop?: number;
  104135. diameterBottom?: number;
  104136. diameter?: number;
  104137. tessellation?: number;
  104138. subdivisions?: number;
  104139. arc?: number;
  104140. faceColors?: Color4[];
  104141. faceUV?: Vector4[];
  104142. updatable?: boolean;
  104143. hasRings?: boolean;
  104144. enclose?: boolean;
  104145. cap?: number;
  104146. sideOrientation?: number;
  104147. frontUVs?: Vector4;
  104148. backUVs?: Vector4;
  104149. }, scene: any): Mesh;
  104150. }
  104151. }
  104152. declare module BABYLON {
  104153. /**
  104154. * Options to modify the vr teleportation behavior.
  104155. */
  104156. export interface VRTeleportationOptions {
  104157. /**
  104158. * The name of the mesh which should be used as the teleportation floor. (default: null)
  104159. */
  104160. floorMeshName?: string;
  104161. /**
  104162. * A list of meshes to be used as the teleportation floor. (default: empty)
  104163. */
  104164. floorMeshes?: Mesh[];
  104165. }
  104166. /**
  104167. * Options to modify the vr experience helper's behavior.
  104168. */
  104169. export interface VRExperienceHelperOptions extends WebVROptions {
  104170. /**
  104171. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  104172. */
  104173. createDeviceOrientationCamera?: boolean;
  104174. /**
  104175. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  104176. */
  104177. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  104178. /**
  104179. * Uses the main button on the controller to toggle the laser casted. (default: true)
  104180. */
  104181. laserToggle?: boolean;
  104182. /**
  104183. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  104184. */
  104185. floorMeshes?: Mesh[];
  104186. /**
  104187. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  104188. */
  104189. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  104190. }
  104191. /**
  104192. * Event containing information after VR has been entered
  104193. */
  104194. export class OnAfterEnteringVRObservableEvent {
  104195. /**
  104196. * If entering vr was successful
  104197. */
  104198. success: boolean;
  104199. }
  104200. /**
  104201. * Helps to quickly add VR support to an existing scene.
  104202. * See http://doc.babylonjs.com/how_to/webvr_helper
  104203. */
  104204. export class VRExperienceHelper {
  104205. /** Options to modify the vr experience helper's behavior. */
  104206. webVROptions: VRExperienceHelperOptions;
  104207. private _scene;
  104208. private _position;
  104209. private _btnVR;
  104210. private _btnVRDisplayed;
  104211. private _webVRsupported;
  104212. private _webVRready;
  104213. private _webVRrequesting;
  104214. private _webVRpresenting;
  104215. private _hasEnteredVR;
  104216. private _fullscreenVRpresenting;
  104217. private _canvas;
  104218. private _webVRCamera;
  104219. private _vrDeviceOrientationCamera;
  104220. private _deviceOrientationCamera;
  104221. private _existingCamera;
  104222. private _onKeyDown;
  104223. private _onVrDisplayPresentChange;
  104224. private _onVRDisplayChanged;
  104225. private _onVRRequestPresentStart;
  104226. private _onVRRequestPresentComplete;
  104227. /**
  104228. * Gets or sets a boolean indicating that gaze can be enabled even if pointer lock is not engage (useful on iOS where fullscreen mode and pointer lock are not supported)
  104229. */
  104230. enableGazeEvenWhenNoPointerLock: boolean;
  104231. /**
  104232. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  104233. */
  104234. exitVROnDoubleTap: boolean;
  104235. /**
  104236. * Observable raised right before entering VR.
  104237. */
  104238. onEnteringVRObservable: Observable<VRExperienceHelper>;
  104239. /**
  104240. * Observable raised when entering VR has completed.
  104241. */
  104242. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  104243. /**
  104244. * Observable raised when exiting VR.
  104245. */
  104246. onExitingVRObservable: Observable<VRExperienceHelper>;
  104247. /**
  104248. * Observable raised when controller mesh is loaded.
  104249. */
  104250. onControllerMeshLoadedObservable: Observable<WebVRController>;
  104251. /** Return this.onEnteringVRObservable
  104252. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  104253. */
  104254. readonly onEnteringVR: Observable<VRExperienceHelper>;
  104255. /** Return this.onExitingVRObservable
  104256. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  104257. */
  104258. readonly onExitingVR: Observable<VRExperienceHelper>;
  104259. /** Return this.onControllerMeshLoadedObservable
  104260. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  104261. */
  104262. readonly onControllerMeshLoaded: Observable<WebVRController>;
  104263. private _rayLength;
  104264. private _useCustomVRButton;
  104265. private _teleportationRequested;
  104266. private _teleportActive;
  104267. private _floorMeshName;
  104268. private _floorMeshesCollection;
  104269. private _rotationAllowed;
  104270. private _teleportBackwardsVector;
  104271. private _teleportationTarget;
  104272. private _isDefaultTeleportationTarget;
  104273. private _postProcessMove;
  104274. private _teleportationFillColor;
  104275. private _teleportationBorderColor;
  104276. private _rotationAngle;
  104277. private _haloCenter;
  104278. private _cameraGazer;
  104279. private _padSensibilityUp;
  104280. private _padSensibilityDown;
  104281. private _leftController;
  104282. private _rightController;
  104283. /**
  104284. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  104285. */
  104286. onNewMeshSelected: Observable<AbstractMesh>;
  104287. /**
  104288. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  104289. */
  104290. onNewMeshPicked: Observable<PickingInfo>;
  104291. private _circleEase;
  104292. /**
  104293. * Observable raised before camera teleportation
  104294. */
  104295. onBeforeCameraTeleport: Observable<Vector3>;
  104296. /**
  104297. * Observable raised after camera teleportation
  104298. */
  104299. onAfterCameraTeleport: Observable<Vector3>;
  104300. /**
  104301. * Observable raised when current selected mesh gets unselected
  104302. */
  104303. onSelectedMeshUnselected: Observable<AbstractMesh>;
  104304. private _raySelectionPredicate;
  104305. /**
  104306. * To be optionaly changed by user to define custom ray selection
  104307. */
  104308. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  104309. /**
  104310. * To be optionaly changed by user to define custom selection logic (after ray selection)
  104311. */
  104312. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  104313. /**
  104314. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  104315. */
  104316. teleportationEnabled: boolean;
  104317. private _defaultHeight;
  104318. private _teleportationInitialized;
  104319. private _interactionsEnabled;
  104320. private _interactionsRequested;
  104321. private _displayGaze;
  104322. private _displayLaserPointer;
  104323. /**
  104324. * The mesh used to display where the user is going to teleport.
  104325. */
  104326. /**
  104327. * Sets the mesh to be used to display where the user is going to teleport.
  104328. */
  104329. teleportationTarget: Mesh;
  104330. /**
  104331. * 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
  104332. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  104333. * See http://doc.babylonjs.com/resources/baking_transformations
  104334. */
  104335. gazeTrackerMesh: Mesh;
  104336. /**
  104337. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  104338. */
  104339. updateGazeTrackerScale: boolean;
  104340. /**
  104341. * If the gaze trackers color should be updated when selecting meshes
  104342. */
  104343. updateGazeTrackerColor: boolean;
  104344. /**
  104345. * The gaze tracking mesh corresponding to the left controller
  104346. */
  104347. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  104348. /**
  104349. * The gaze tracking mesh corresponding to the right controller
  104350. */
  104351. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  104352. /**
  104353. * If the ray of the gaze should be displayed.
  104354. */
  104355. /**
  104356. * Sets if the ray of the gaze should be displayed.
  104357. */
  104358. displayGaze: boolean;
  104359. /**
  104360. * If the ray of the LaserPointer should be displayed.
  104361. */
  104362. /**
  104363. * Sets if the ray of the LaserPointer should be displayed.
  104364. */
  104365. displayLaserPointer: boolean;
  104366. /**
  104367. * The deviceOrientationCamera used as the camera when not in VR.
  104368. */
  104369. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  104370. /**
  104371. * Based on the current WebVR support, returns the current VR camera used.
  104372. */
  104373. readonly currentVRCamera: Nullable<Camera>;
  104374. /**
  104375. * The webVRCamera which is used when in VR.
  104376. */
  104377. readonly webVRCamera: WebVRFreeCamera;
  104378. /**
  104379. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  104380. */
  104381. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  104382. /**
  104383. * The html button that is used to trigger entering into VR.
  104384. */
  104385. readonly vrButton: Nullable<HTMLButtonElement>;
  104386. private readonly _teleportationRequestInitiated;
  104387. /**
  104388. * Defines wether or not Pointer lock should be requested when switching to
  104389. * full screen.
  104390. */
  104391. requestPointerLockOnFullScreen: boolean;
  104392. /**
  104393. * Instantiates a VRExperienceHelper.
  104394. * Helps to quickly add VR support to an existing scene.
  104395. * @param scene The scene the VRExperienceHelper belongs to.
  104396. * @param webVROptions Options to modify the vr experience helper's behavior.
  104397. */
  104398. constructor(scene: Scene,
  104399. /** Options to modify the vr experience helper's behavior. */
  104400. webVROptions?: VRExperienceHelperOptions);
  104401. private _onDefaultMeshLoaded;
  104402. private _onResize;
  104403. private _onFullscreenChange;
  104404. /**
  104405. * Gets a value indicating if we are currently in VR mode.
  104406. */
  104407. readonly isInVRMode: boolean;
  104408. private onVrDisplayPresentChange;
  104409. private onVRDisplayChanged;
  104410. private moveButtonToBottomRight;
  104411. private displayVRButton;
  104412. private updateButtonVisibility;
  104413. private _cachedAngularSensibility;
  104414. /**
  104415. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  104416. * Otherwise, will use the fullscreen API.
  104417. */
  104418. enterVR(): void;
  104419. /**
  104420. * Attempt to exit VR, or fullscreen.
  104421. */
  104422. exitVR(): void;
  104423. /**
  104424. * The position of the vr experience helper.
  104425. */
  104426. /**
  104427. * Sets the position of the vr experience helper.
  104428. */
  104429. position: Vector3;
  104430. /**
  104431. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  104432. */
  104433. enableInteractions(): void;
  104434. private readonly _noControllerIsActive;
  104435. private beforeRender;
  104436. private _isTeleportationFloor;
  104437. /**
  104438. * Adds a floor mesh to be used for teleportation.
  104439. * @param floorMesh the mesh to be used for teleportation.
  104440. */
  104441. addFloorMesh(floorMesh: Mesh): void;
  104442. /**
  104443. * Removes a floor mesh from being used for teleportation.
  104444. * @param floorMesh the mesh to be removed.
  104445. */
  104446. removeFloorMesh(floorMesh: Mesh): void;
  104447. /**
  104448. * Enables interactions and teleportation using the VR controllers and gaze.
  104449. * @param vrTeleportationOptions options to modify teleportation behavior.
  104450. */
  104451. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  104452. private _onNewGamepadConnected;
  104453. private _tryEnableInteractionOnController;
  104454. private _onNewGamepadDisconnected;
  104455. private _enableInteractionOnController;
  104456. private _checkTeleportWithRay;
  104457. private _checkRotate;
  104458. private _checkTeleportBackwards;
  104459. private _enableTeleportationOnController;
  104460. private _createTeleportationCircles;
  104461. private _displayTeleportationTarget;
  104462. private _hideTeleportationTarget;
  104463. private _rotateCamera;
  104464. private _moveTeleportationSelectorTo;
  104465. private _workingVector;
  104466. private _workingQuaternion;
  104467. private _workingMatrix;
  104468. /**
  104469. * Teleports the users feet to the desired location
  104470. * @param location The location where the user's feet should be placed
  104471. */
  104472. teleportCamera(location: Vector3): void;
  104473. private _convertNormalToDirectionOfRay;
  104474. private _castRayAndSelectObject;
  104475. private _notifySelectedMeshUnselected;
  104476. /**
  104477. * Sets the color of the laser ray from the vr controllers.
  104478. * @param color new color for the ray.
  104479. */
  104480. changeLaserColor(color: Color3): void;
  104481. /**
  104482. * Sets the color of the ray from the vr headsets gaze.
  104483. * @param color new color for the ray.
  104484. */
  104485. changeGazeColor(color: Color3): void;
  104486. /**
  104487. * Exits VR and disposes of the vr experience helper
  104488. */
  104489. dispose(): void;
  104490. /**
  104491. * Gets the name of the VRExperienceHelper class
  104492. * @returns "VRExperienceHelper"
  104493. */
  104494. getClassName(): string;
  104495. }
  104496. }
  104497. declare module BABYLON {
  104498. /**
  104499. * Manages an XRSession to work with Babylon's engine
  104500. * @see https://doc.babylonjs.com/how_to/webxr
  104501. */
  104502. export class WebXRSessionManager implements IDisposable {
  104503. private scene;
  104504. /**
  104505. * Fires every time a new xrFrame arrives which can be used to update the camera
  104506. */
  104507. onXRFrameObservable: Observable<any>;
  104508. /**
  104509. * Fires when the xr session is ended either by the device or manually done
  104510. */
  104511. onXRSessionEnded: Observable<any>;
  104512. /**
  104513. * Underlying xr session
  104514. */
  104515. session: XRSession;
  104516. /**
  104517. * Type of reference space used when creating the session
  104518. */
  104519. referenceSpace: XRReferenceSpace;
  104520. /** @hidden */
  104521. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  104522. /**
  104523. * Current XR frame
  104524. */
  104525. currentFrame: Nullable<XRFrame>;
  104526. private _xrNavigator;
  104527. private baseLayer;
  104528. /**
  104529. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  104530. * @param scene The scene which the session should be created for
  104531. */
  104532. constructor(scene: Scene);
  104533. /**
  104534. * Initializes the manager
  104535. * After initialization enterXR can be called to start an XR session
  104536. * @returns Promise which resolves after it is initialized
  104537. */
  104538. initializeAsync(): Promise<void>;
  104539. /**
  104540. * Initializes an xr session
  104541. * @param xrSessionMode mode to initialize
  104542. * @returns a promise which will resolve once the session has been initialized
  104543. */
  104544. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  104545. /**
  104546. * Sets the reference space on the xr session
  104547. * @param referenceSpace space to set
  104548. * @returns a promise that will resolve once the reference space has been set
  104549. */
  104550. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  104551. /**
  104552. * Updates the render state of the session
  104553. * @param state state to set
  104554. * @returns a promise that resolves once the render state has been updated
  104555. */
  104556. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  104557. /**
  104558. * Starts rendering to the xr layer
  104559. * @returns a promise that will resolve once rendering has started
  104560. */
  104561. startRenderingToXRAsync(): Promise<void>;
  104562. /**
  104563. * Stops the xrSession and restores the renderloop
  104564. * @returns Promise which resolves after it exits XR
  104565. */
  104566. exitXRAsync(): Promise<unknown>;
  104567. /**
  104568. * Checks if a session would be supported for the creation options specified
  104569. * @param sessionMode session mode to check if supported eg. immersive-vr
  104570. * @returns true if supported
  104571. */
  104572. supportsSessionAsync(sessionMode: XRSessionMode): any;
  104573. /**
  104574. * @hidden
  104575. * Converts the render layer of xrSession to a render target
  104576. * @param session session to create render target for
  104577. * @param scene scene the new render target should be created for
  104578. */
  104579. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  104580. /**
  104581. * Disposes of the session manager
  104582. */
  104583. dispose(): void;
  104584. }
  104585. }
  104586. declare module BABYLON {
  104587. /**
  104588. * WebXR Camera which holds the views for the xrSession
  104589. * @see https://doc.babylonjs.com/how_to/webxr
  104590. */
  104591. export class WebXRCamera extends FreeCamera {
  104592. private static _TmpMatrix;
  104593. /**
  104594. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  104595. * @param name the name of the camera
  104596. * @param scene the scene to add the camera to
  104597. */
  104598. constructor(name: string, scene: Scene);
  104599. private _updateNumberOfRigCameras;
  104600. /** @hidden */
  104601. _updateForDualEyeDebugging(pupilDistance?: number): void;
  104602. /**
  104603. * Updates the cameras position from the current pose information of the XR session
  104604. * @param xrSessionManager the session containing pose information
  104605. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  104606. */
  104607. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  104608. }
  104609. }
  104610. declare module BABYLON {
  104611. /**
  104612. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  104613. */
  104614. export class WebXRManagedOutputCanvas implements IDisposable {
  104615. private helper;
  104616. private _canvas;
  104617. /**
  104618. * xrpresent context of the canvas which can be used to display/mirror xr content
  104619. */
  104620. canvasContext: WebGLRenderingContext;
  104621. /**
  104622. * xr layer for the canvas
  104623. */
  104624. xrLayer: Nullable<XRWebGLLayer>;
  104625. /**
  104626. * Initializes the xr layer for the session
  104627. * @param xrSession xr session
  104628. * @returns a promise that will resolve once the XR Layer has been created
  104629. */
  104630. initializeXRLayerAsync(xrSession: any): any;
  104631. /**
  104632. * Initializes the canvas to be added/removed upon entering/exiting xr
  104633. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  104634. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  104635. */
  104636. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  104637. /**
  104638. * Disposes of the object
  104639. */
  104640. dispose(): void;
  104641. private _setManagedOutputCanvas;
  104642. private _addCanvas;
  104643. private _removeCanvas;
  104644. }
  104645. }
  104646. declare module BABYLON {
  104647. /**
  104648. * States of the webXR experience
  104649. */
  104650. export enum WebXRState {
  104651. /**
  104652. * Transitioning to being in XR mode
  104653. */
  104654. ENTERING_XR = 0,
  104655. /**
  104656. * Transitioning to non XR mode
  104657. */
  104658. EXITING_XR = 1,
  104659. /**
  104660. * In XR mode and presenting
  104661. */
  104662. IN_XR = 2,
  104663. /**
  104664. * Not entered XR mode
  104665. */
  104666. NOT_IN_XR = 3
  104667. }
  104668. /**
  104669. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  104670. * @see https://doc.babylonjs.com/how_to/webxr
  104671. */
  104672. export class WebXRExperienceHelper implements IDisposable {
  104673. private scene;
  104674. /**
  104675. * 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
  104676. */
  104677. container: AbstractMesh;
  104678. /**
  104679. * Camera used to render xr content
  104680. */
  104681. camera: WebXRCamera;
  104682. /**
  104683. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  104684. */
  104685. state: WebXRState;
  104686. private _setState;
  104687. private static _TmpVector;
  104688. /**
  104689. * Fires when the state of the experience helper has changed
  104690. */
  104691. onStateChangedObservable: Observable<WebXRState>;
  104692. /** Session manager used to keep track of xr session */
  104693. sessionManager: WebXRSessionManager;
  104694. private _nonVRCamera;
  104695. private _originalSceneAutoClear;
  104696. private _supported;
  104697. /**
  104698. * Creates the experience helper
  104699. * @param scene the scene to attach the experience helper to
  104700. * @returns a promise for the experience helper
  104701. */
  104702. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  104703. /**
  104704. * Creates a WebXRExperienceHelper
  104705. * @param scene The scene the helper should be created in
  104706. */
  104707. private constructor();
  104708. /**
  104709. * Exits XR mode and returns the scene to its original state
  104710. * @returns promise that resolves after xr mode has exited
  104711. */
  104712. exitXRAsync(): Promise<unknown>;
  104713. /**
  104714. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  104715. * @param sessionCreationOptions options for the XR session
  104716. * @param referenceSpaceType frame of reference of the XR session
  104717. * @param outputCanvas the output canvas that will be used to enter XR mode
  104718. * @returns promise that resolves after xr mode has entered
  104719. */
  104720. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  104721. /**
  104722. * Updates the global position of the camera by moving the camera's container
  104723. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  104724. * @param position The desired global position of the camera
  104725. */
  104726. setPositionOfCameraUsingContainer(position: Vector3): void;
  104727. /**
  104728. * Rotates the xr camera by rotating the camera's container around the camera's position
  104729. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  104730. * @param rotation the desired quaternion rotation to apply to the camera
  104731. */
  104732. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  104733. /**
  104734. * Disposes of the experience helper
  104735. */
  104736. dispose(): void;
  104737. }
  104738. }
  104739. declare module BABYLON {
  104740. /**
  104741. * Button which can be used to enter a different mode of XR
  104742. */
  104743. export class WebXREnterExitUIButton {
  104744. /** button element */
  104745. element: HTMLElement;
  104746. /** XR initialization options for the button */
  104747. sessionMode: XRSessionMode;
  104748. /** Reference space type */
  104749. referenceSpaceType: XRReferenceSpaceType;
  104750. /**
  104751. * Creates a WebXREnterExitUIButton
  104752. * @param element button element
  104753. * @param sessionMode XR initialization session mode
  104754. * @param referenceSpaceType the type of reference space to be used
  104755. */
  104756. constructor(
  104757. /** button element */
  104758. element: HTMLElement,
  104759. /** XR initialization options for the button */
  104760. sessionMode: XRSessionMode,
  104761. /** Reference space type */
  104762. referenceSpaceType: XRReferenceSpaceType);
  104763. /**
  104764. * Overwritable function which can be used to update the button's visuals when the state changes
  104765. * @param activeButton the current active button in the UI
  104766. */
  104767. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  104768. }
  104769. /**
  104770. * Options to create the webXR UI
  104771. */
  104772. export class WebXREnterExitUIOptions {
  104773. /**
  104774. * Context to enter xr with
  104775. */
  104776. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  104777. /**
  104778. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  104779. */
  104780. customButtons?: Array<WebXREnterExitUIButton>;
  104781. }
  104782. /**
  104783. * UI to allow the user to enter/exit XR mode
  104784. */
  104785. export class WebXREnterExitUI implements IDisposable {
  104786. private scene;
  104787. private _overlay;
  104788. private _buttons;
  104789. private _activeButton;
  104790. /**
  104791. * Fired every time the active button is changed.
  104792. *
  104793. * When xr is entered via a button that launches xr that button will be the callback parameter
  104794. *
  104795. * When exiting xr the callback parameter will be null)
  104796. */
  104797. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  104798. /**
  104799. * Creates UI to allow the user to enter/exit XR mode
  104800. * @param scene the scene to add the ui to
  104801. * @param helper the xr experience helper to enter/exit xr with
  104802. * @param options options to configure the UI
  104803. * @returns the created ui
  104804. */
  104805. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  104806. private constructor();
  104807. private _updateButtons;
  104808. /**
  104809. * Disposes of the object
  104810. */
  104811. dispose(): void;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. /**
  104816. * Represents an XR input
  104817. */
  104818. export class WebXRController {
  104819. private scene;
  104820. /** The underlying input source for the controller */
  104821. inputSource: XRInputSource;
  104822. private parentContainer;
  104823. /**
  104824. * 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
  104825. */
  104826. grip?: AbstractMesh;
  104827. /**
  104828. * Pointer which can be used to select objects or attach a visible laser to
  104829. */
  104830. pointer: AbstractMesh;
  104831. /**
  104832. * Event that fires when the controller is removed/disposed
  104833. */
  104834. onDisposeObservable: Observable<{}>;
  104835. private _tmpMatrix;
  104836. private _tmpQuaternion;
  104837. private _tmpVector;
  104838. /**
  104839. * Creates the controller
  104840. * @see https://doc.babylonjs.com/how_to/webxr
  104841. * @param scene the scene which the controller should be associated to
  104842. * @param inputSource the underlying input source for the controller
  104843. * @param parentContainer parent that the controller meshes should be children of
  104844. */
  104845. constructor(scene: Scene,
  104846. /** The underlying input source for the controller */
  104847. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  104848. /**
  104849. * Updates the controller pose based on the given XRFrame
  104850. * @param xrFrame xr frame to update the pose with
  104851. * @param referenceSpace reference space to use
  104852. */
  104853. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  104854. /**
  104855. * Gets a world space ray coming from the controller
  104856. * @param result the resulting ray
  104857. */
  104858. getWorldPointerRayToRef(result: Ray): void;
  104859. /**
  104860. * Disposes of the object
  104861. */
  104862. dispose(): void;
  104863. }
  104864. }
  104865. declare module BABYLON {
  104866. /**
  104867. * XR input used to track XR inputs such as controllers/rays
  104868. */
  104869. export class WebXRInput implements IDisposable {
  104870. /**
  104871. * Base experience the input listens to
  104872. */
  104873. baseExperience: WebXRExperienceHelper;
  104874. /**
  104875. * XR controllers being tracked
  104876. */
  104877. controllers: Array<WebXRController>;
  104878. private _frameObserver;
  104879. private _stateObserver;
  104880. /**
  104881. * Event when a controller has been connected/added
  104882. */
  104883. onControllerAddedObservable: Observable<WebXRController>;
  104884. /**
  104885. * Event when a controller has been removed/disconnected
  104886. */
  104887. onControllerRemovedObservable: Observable<WebXRController>;
  104888. /**
  104889. * Initializes the WebXRInput
  104890. * @param baseExperience experience helper which the input should be created for
  104891. */
  104892. constructor(
  104893. /**
  104894. * Base experience the input listens to
  104895. */
  104896. baseExperience: WebXRExperienceHelper);
  104897. private _onInputSourcesChange;
  104898. private _addAndRemoveControllers;
  104899. /**
  104900. * Disposes of the object
  104901. */
  104902. dispose(): void;
  104903. }
  104904. }
  104905. declare module BABYLON {
  104906. /**
  104907. * Enables teleportation
  104908. */
  104909. export class WebXRControllerTeleportation {
  104910. private _teleportationFillColor;
  104911. private _teleportationBorderColor;
  104912. private _tmpRay;
  104913. private _tmpVector;
  104914. /**
  104915. * Creates a WebXRControllerTeleportation
  104916. * @param input input manager to add teleportation to
  104917. * @param floorMeshes floormeshes which can be teleported to
  104918. */
  104919. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  104920. }
  104921. }
  104922. declare module BABYLON {
  104923. /**
  104924. * Handles pointer input automatically for the pointer of XR controllers
  104925. */
  104926. export class WebXRControllerPointerSelection {
  104927. private static _idCounter;
  104928. private _tmpRay;
  104929. /**
  104930. * Creates a WebXRControllerPointerSelection
  104931. * @param input input manager to setup pointer selection
  104932. */
  104933. constructor(input: WebXRInput);
  104934. private _convertNormalToDirectionOfRay;
  104935. private _updatePointerDistance;
  104936. }
  104937. }
  104938. declare module BABYLON {
  104939. /**
  104940. * Class used to represent data loading progression
  104941. */
  104942. export class SceneLoaderProgressEvent {
  104943. /** defines if data length to load can be evaluated */
  104944. readonly lengthComputable: boolean;
  104945. /** defines the loaded data length */
  104946. readonly loaded: number;
  104947. /** defines the data length to load */
  104948. readonly total: number;
  104949. /**
  104950. * Create a new progress event
  104951. * @param lengthComputable defines if data length to load can be evaluated
  104952. * @param loaded defines the loaded data length
  104953. * @param total defines the data length to load
  104954. */
  104955. constructor(
  104956. /** defines if data length to load can be evaluated */
  104957. lengthComputable: boolean,
  104958. /** defines the loaded data length */
  104959. loaded: number,
  104960. /** defines the data length to load */
  104961. total: number);
  104962. /**
  104963. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104964. * @param event defines the source event
  104965. * @returns a new SceneLoaderProgressEvent
  104966. */
  104967. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104968. }
  104969. /**
  104970. * Interface used by SceneLoader plugins to define supported file extensions
  104971. */
  104972. export interface ISceneLoaderPluginExtensions {
  104973. /**
  104974. * Defines the list of supported extensions
  104975. */
  104976. [extension: string]: {
  104977. isBinary: boolean;
  104978. };
  104979. }
  104980. /**
  104981. * Interface used by SceneLoader plugin factory
  104982. */
  104983. export interface ISceneLoaderPluginFactory {
  104984. /**
  104985. * Defines the name of the factory
  104986. */
  104987. name: string;
  104988. /**
  104989. * Function called to create a new plugin
  104990. * @return the new plugin
  104991. */
  104992. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104993. /**
  104994. * Boolean indicating if the plugin can direct load specific data
  104995. */
  104996. canDirectLoad?: (data: string) => boolean;
  104997. }
  104998. /**
  104999. * Interface used to define a SceneLoader plugin
  105000. */
  105001. export interface ISceneLoaderPlugin {
  105002. /**
  105003. * The friendly name of this plugin.
  105004. */
  105005. name: string;
  105006. /**
  105007. * The file extensions supported by this plugin.
  105008. */
  105009. extensions: string | ISceneLoaderPluginExtensions;
  105010. /**
  105011. * Import meshes into a scene.
  105012. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105013. * @param scene The scene to import into
  105014. * @param data The data to import
  105015. * @param rootUrl The root url for scene and resources
  105016. * @param meshes The meshes array to import into
  105017. * @param particleSystems The particle systems array to import into
  105018. * @param skeletons The skeletons array to import into
  105019. * @param onError The callback when import fails
  105020. * @returns True if successful or false otherwise
  105021. */
  105022. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105023. /**
  105024. * Load into a scene.
  105025. * @param scene The scene to load into
  105026. * @param data The data to import
  105027. * @param rootUrl The root url for scene and resources
  105028. * @param onError The callback when import fails
  105029. * @returns true if successful or false otherwise
  105030. */
  105031. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105032. /**
  105033. * The callback that returns true if the data can be directly loaded.
  105034. */
  105035. canDirectLoad?: (data: string) => boolean;
  105036. /**
  105037. * The callback that allows custom handling of the root url based on the response url.
  105038. */
  105039. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105040. /**
  105041. * Load into an asset container.
  105042. * @param scene The scene to load into
  105043. * @param data The data to import
  105044. * @param rootUrl The root url for scene and resources
  105045. * @param onError The callback when import fails
  105046. * @returns The loaded asset container
  105047. */
  105048. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105049. }
  105050. /**
  105051. * Interface used to define an async SceneLoader plugin
  105052. */
  105053. export interface ISceneLoaderPluginAsync {
  105054. /**
  105055. * The friendly name of this plugin.
  105056. */
  105057. name: string;
  105058. /**
  105059. * The file extensions supported by this plugin.
  105060. */
  105061. extensions: string | ISceneLoaderPluginExtensions;
  105062. /**
  105063. * Import meshes into a scene.
  105064. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105065. * @param scene The scene to import into
  105066. * @param data The data to import
  105067. * @param rootUrl The root url for scene and resources
  105068. * @param onProgress The callback when the load progresses
  105069. * @param fileName Defines the name of the file to load
  105070. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105071. */
  105072. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105073. meshes: AbstractMesh[];
  105074. particleSystems: IParticleSystem[];
  105075. skeletons: Skeleton[];
  105076. animationGroups: AnimationGroup[];
  105077. }>;
  105078. /**
  105079. * Load into a scene.
  105080. * @param scene The scene to load into
  105081. * @param data The data to import
  105082. * @param rootUrl The root url for scene and resources
  105083. * @param onProgress The callback when the load progresses
  105084. * @param fileName Defines the name of the file to load
  105085. * @returns Nothing
  105086. */
  105087. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105088. /**
  105089. * The callback that returns true if the data can be directly loaded.
  105090. */
  105091. canDirectLoad?: (data: string) => boolean;
  105092. /**
  105093. * The callback that allows custom handling of the root url based on the response url.
  105094. */
  105095. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105096. /**
  105097. * Load into an asset container.
  105098. * @param scene The scene to load into
  105099. * @param data The data to import
  105100. * @param rootUrl The root url for scene and resources
  105101. * @param onProgress The callback when the load progresses
  105102. * @param fileName Defines the name of the file to load
  105103. * @returns The loaded asset container
  105104. */
  105105. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105106. }
  105107. /**
  105108. * Class used to load scene from various file formats using registered plugins
  105109. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105110. */
  105111. export class SceneLoader {
  105112. /**
  105113. * No logging while loading
  105114. */
  105115. static readonly NO_LOGGING: number;
  105116. /**
  105117. * Minimal logging while loading
  105118. */
  105119. static readonly MINIMAL_LOGGING: number;
  105120. /**
  105121. * Summary logging while loading
  105122. */
  105123. static readonly SUMMARY_LOGGING: number;
  105124. /**
  105125. * Detailled logging while loading
  105126. */
  105127. static readonly DETAILED_LOGGING: number;
  105128. /**
  105129. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105130. */
  105131. static ForceFullSceneLoadingForIncremental: boolean;
  105132. /**
  105133. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105134. */
  105135. static ShowLoadingScreen: boolean;
  105136. /**
  105137. * Defines the current logging level (while loading the scene)
  105138. * @ignorenaming
  105139. */
  105140. static loggingLevel: number;
  105141. /**
  105142. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105143. */
  105144. static CleanBoneMatrixWeights: boolean;
  105145. /**
  105146. * Event raised when a plugin is used to load a scene
  105147. */
  105148. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105149. private static _registeredPlugins;
  105150. private static _getDefaultPlugin;
  105151. private static _getPluginForExtension;
  105152. private static _getPluginForDirectLoad;
  105153. private static _getPluginForFilename;
  105154. private static _getDirectLoad;
  105155. private static _loadData;
  105156. private static _getFileInfo;
  105157. /**
  105158. * Gets a plugin that can load the given extension
  105159. * @param extension defines the extension to load
  105160. * @returns a plugin or null if none works
  105161. */
  105162. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105163. /**
  105164. * Gets a boolean indicating that the given extension can be loaded
  105165. * @param extension defines the extension to load
  105166. * @returns true if the extension is supported
  105167. */
  105168. static IsPluginForExtensionAvailable(extension: string): boolean;
  105169. /**
  105170. * Adds a new plugin to the list of registered plugins
  105171. * @param plugin defines the plugin to add
  105172. */
  105173. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105174. /**
  105175. * Import meshes into a scene
  105176. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105177. * @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)
  105178. * @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)
  105179. * @param scene the instance of BABYLON.Scene to append to
  105180. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105181. * @param onProgress a callback with a progress event for each file being loaded
  105182. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105183. * @param pluginExtension the extension used to determine the plugin
  105184. * @returns The loaded plugin
  105185. */
  105186. 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>;
  105187. /**
  105188. * Import meshes into a scene
  105189. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105190. * @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)
  105191. * @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)
  105192. * @param scene the instance of BABYLON.Scene to append to
  105193. * @param onProgress a callback with a progress event for each file being loaded
  105194. * @param pluginExtension the extension used to determine the plugin
  105195. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105196. */
  105197. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105198. meshes: AbstractMesh[];
  105199. particleSystems: IParticleSystem[];
  105200. skeletons: Skeleton[];
  105201. animationGroups: AnimationGroup[];
  105202. }>;
  105203. /**
  105204. * Load a scene
  105205. * @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)
  105206. * @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)
  105207. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105208. * @param onSuccess a callback with the scene when import succeeds
  105209. * @param onProgress a callback with a progress event for each file being loaded
  105210. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105211. * @param pluginExtension the extension used to determine the plugin
  105212. * @returns The loaded plugin
  105213. */
  105214. 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>;
  105215. /**
  105216. * Load a scene
  105217. * @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)
  105218. * @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)
  105219. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105220. * @param onProgress a callback with a progress event for each file being loaded
  105221. * @param pluginExtension the extension used to determine the plugin
  105222. * @returns The loaded scene
  105223. */
  105224. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105225. /**
  105226. * Append a scene
  105227. * @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)
  105228. * @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)
  105229. * @param scene is the instance of BABYLON.Scene to append to
  105230. * @param onSuccess a callback with the scene when import succeeds
  105231. * @param onProgress a callback with a progress event for each file being loaded
  105232. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105233. * @param pluginExtension the extension used to determine the plugin
  105234. * @returns The loaded plugin
  105235. */
  105236. 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>;
  105237. /**
  105238. * Append a scene
  105239. * @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)
  105240. * @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)
  105241. * @param scene is the instance of BABYLON.Scene to append to
  105242. * @param onProgress a callback with a progress event for each file being loaded
  105243. * @param pluginExtension the extension used to determine the plugin
  105244. * @returns The given scene
  105245. */
  105246. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105247. /**
  105248. * Load a scene into an asset container
  105249. * @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)
  105250. * @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)
  105251. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105252. * @param onSuccess a callback with the scene when import succeeds
  105253. * @param onProgress a callback with a progress event for each file being loaded
  105254. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105255. * @param pluginExtension the extension used to determine the plugin
  105256. * @returns The loaded plugin
  105257. */
  105258. 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>;
  105259. /**
  105260. * Load a scene into an asset container
  105261. * @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)
  105262. * @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)
  105263. * @param scene is the instance of Scene to append to
  105264. * @param onProgress a callback with a progress event for each file being loaded
  105265. * @param pluginExtension the extension used to determine the plugin
  105266. * @returns The loaded asset container
  105267. */
  105268. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105269. }
  105270. }
  105271. declare module BABYLON {
  105272. /**
  105273. * Generic Controller
  105274. */
  105275. export class GenericController extends WebVRController {
  105276. /**
  105277. * Base Url for the controller model.
  105278. */
  105279. static readonly MODEL_BASE_URL: string;
  105280. /**
  105281. * File name for the controller model.
  105282. */
  105283. static readonly MODEL_FILENAME: string;
  105284. /**
  105285. * Creates a new GenericController from a gamepad
  105286. * @param vrGamepad the gamepad that the controller should be created from
  105287. */
  105288. constructor(vrGamepad: any);
  105289. /**
  105290. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105291. * @param scene scene in which to add meshes
  105292. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105293. */
  105294. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105295. /**
  105296. * Called once for each button that changed state since the last frame
  105297. * @param buttonIdx Which button index changed
  105298. * @param state New state of the button
  105299. * @param changes Which properties on the state changed since last frame
  105300. */
  105301. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105302. }
  105303. }
  105304. declare module BABYLON {
  105305. /**
  105306. * Defines the WindowsMotionController object that the state of the windows motion controller
  105307. */
  105308. export class WindowsMotionController extends WebVRController {
  105309. /**
  105310. * The base url used to load the left and right controller models
  105311. */
  105312. static MODEL_BASE_URL: string;
  105313. /**
  105314. * The name of the left controller model file
  105315. */
  105316. static MODEL_LEFT_FILENAME: string;
  105317. /**
  105318. * The name of the right controller model file
  105319. */
  105320. static MODEL_RIGHT_FILENAME: string;
  105321. /**
  105322. * The controller name prefix for this controller type
  105323. */
  105324. static readonly GAMEPAD_ID_PREFIX: string;
  105325. /**
  105326. * The controller id pattern for this controller type
  105327. */
  105328. private static readonly GAMEPAD_ID_PATTERN;
  105329. private _loadedMeshInfo;
  105330. private readonly _mapping;
  105331. /**
  105332. * Fired when the trackpad on this controller is clicked
  105333. */
  105334. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105335. /**
  105336. * Fired when the trackpad on this controller is modified
  105337. */
  105338. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105339. /**
  105340. * The current x and y values of this controller's trackpad
  105341. */
  105342. trackpad: StickValues;
  105343. /**
  105344. * Creates a new WindowsMotionController from a gamepad
  105345. * @param vrGamepad the gamepad that the controller should be created from
  105346. */
  105347. constructor(vrGamepad: any);
  105348. /**
  105349. * Fired when the trigger on this controller is modified
  105350. */
  105351. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105352. /**
  105353. * Fired when the menu button on this controller is modified
  105354. */
  105355. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105356. /**
  105357. * Fired when the grip button on this controller is modified
  105358. */
  105359. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105360. /**
  105361. * Fired when the thumbstick button on this controller is modified
  105362. */
  105363. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105364. /**
  105365. * Fired when the touchpad button on this controller is modified
  105366. */
  105367. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105368. /**
  105369. * Fired when the touchpad values on this controller are modified
  105370. */
  105371. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105372. private _updateTrackpad;
  105373. /**
  105374. * Called once per frame by the engine.
  105375. */
  105376. update(): void;
  105377. /**
  105378. * Called once for each button that changed state since the last frame
  105379. * @param buttonIdx Which button index changed
  105380. * @param state New state of the button
  105381. * @param changes Which properties on the state changed since last frame
  105382. */
  105383. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105384. /**
  105385. * Moves the buttons on the controller mesh based on their current state
  105386. * @param buttonName the name of the button to move
  105387. * @param buttonValue the value of the button which determines the buttons new position
  105388. */
  105389. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105390. /**
  105391. * Moves the axis on the controller mesh based on its current state
  105392. * @param axis the index of the axis
  105393. * @param axisValue the value of the axis which determines the meshes new position
  105394. * @hidden
  105395. */
  105396. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105397. /**
  105398. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105399. * @param scene scene in which to add meshes
  105400. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105401. */
  105402. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105403. /**
  105404. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105405. * can be transformed by button presses and axes values, based on this._mapping.
  105406. *
  105407. * @param scene scene in which the meshes exist
  105408. * @param meshes list of meshes that make up the controller model to process
  105409. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105410. */
  105411. private processModel;
  105412. private createMeshInfo;
  105413. /**
  105414. * Gets the ray of the controller in the direction the controller is pointing
  105415. * @param length the length the resulting ray should be
  105416. * @returns a ray in the direction the controller is pointing
  105417. */
  105418. getForwardRay(length?: number): Ray;
  105419. /**
  105420. * Disposes of the controller
  105421. */
  105422. dispose(): void;
  105423. }
  105424. }
  105425. declare module BABYLON {
  105426. /**
  105427. * Oculus Touch Controller
  105428. */
  105429. export class OculusTouchController extends WebVRController {
  105430. /**
  105431. * Base Url for the controller model.
  105432. */
  105433. static MODEL_BASE_URL: string;
  105434. /**
  105435. * File name for the left controller model.
  105436. */
  105437. static MODEL_LEFT_FILENAME: string;
  105438. /**
  105439. * File name for the right controller model.
  105440. */
  105441. static MODEL_RIGHT_FILENAME: string;
  105442. /**
  105443. * Base Url for the Quest controller model.
  105444. */
  105445. static QUEST_MODEL_BASE_URL: string;
  105446. /**
  105447. * @hidden
  105448. * If the controllers are running on a device that needs the updated Quest controller models
  105449. */
  105450. static _IsQuest: boolean;
  105451. /**
  105452. * Fired when the secondary trigger on this controller is modified
  105453. */
  105454. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105455. /**
  105456. * Fired when the thumb rest on this controller is modified
  105457. */
  105458. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105459. /**
  105460. * Creates a new OculusTouchController from a gamepad
  105461. * @param vrGamepad the gamepad that the controller should be created from
  105462. */
  105463. constructor(vrGamepad: any);
  105464. /**
  105465. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105466. * @param scene scene in which to add meshes
  105467. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105468. */
  105469. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105470. /**
  105471. * Fired when the A button on this controller is modified
  105472. */
  105473. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105474. /**
  105475. * Fired when the B button on this controller is modified
  105476. */
  105477. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105478. /**
  105479. * Fired when the X button on this controller is modified
  105480. */
  105481. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105482. /**
  105483. * Fired when the Y button on this controller is modified
  105484. */
  105485. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105486. /**
  105487. * Called once for each button that changed state since the last frame
  105488. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105489. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105490. * 2) secondary trigger (same)
  105491. * 3) A (right) X (left), touch, pressed = value
  105492. * 4) B / Y
  105493. * 5) thumb rest
  105494. * @param buttonIdx Which button index changed
  105495. * @param state New state of the button
  105496. * @param changes Which properties on the state changed since last frame
  105497. */
  105498. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105499. }
  105500. }
  105501. declare module BABYLON {
  105502. /**
  105503. * Vive Controller
  105504. */
  105505. export class ViveController extends WebVRController {
  105506. /**
  105507. * Base Url for the controller model.
  105508. */
  105509. static MODEL_BASE_URL: string;
  105510. /**
  105511. * File name for the controller model.
  105512. */
  105513. static MODEL_FILENAME: string;
  105514. /**
  105515. * Creates a new ViveController from a gamepad
  105516. * @param vrGamepad the gamepad that the controller should be created from
  105517. */
  105518. constructor(vrGamepad: any);
  105519. /**
  105520. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105521. * @param scene scene in which to add meshes
  105522. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105523. */
  105524. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105525. /**
  105526. * Fired when the left button on this controller is modified
  105527. */
  105528. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105529. /**
  105530. * Fired when the right button on this controller is modified
  105531. */
  105532. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105533. /**
  105534. * Fired when the menu button on this controller is modified
  105535. */
  105536. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105537. /**
  105538. * Called once for each button that changed state since the last frame
  105539. * Vive mapping:
  105540. * 0: touchpad
  105541. * 1: trigger
  105542. * 2: left AND right buttons
  105543. * 3: menu button
  105544. * @param buttonIdx Which button index changed
  105545. * @param state New state of the button
  105546. * @param changes Which properties on the state changed since last frame
  105547. */
  105548. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105549. }
  105550. }
  105551. declare module BABYLON {
  105552. /**
  105553. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  105554. */
  105555. export class WebXRControllerModelLoader {
  105556. /**
  105557. * Creates the WebXRControllerModelLoader
  105558. * @param input xr input that creates the controllers
  105559. */
  105560. constructor(input: WebXRInput);
  105561. }
  105562. }
  105563. declare module BABYLON {
  105564. /**
  105565. * Contains an array of blocks representing the octree
  105566. */
  105567. export interface IOctreeContainer<T> {
  105568. /**
  105569. * Blocks within the octree
  105570. */
  105571. blocks: Array<OctreeBlock<T>>;
  105572. }
  105573. /**
  105574. * Class used to store a cell in an octree
  105575. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105576. */
  105577. export class OctreeBlock<T> {
  105578. /**
  105579. * Gets the content of the current block
  105580. */
  105581. entries: T[];
  105582. /**
  105583. * Gets the list of block children
  105584. */
  105585. blocks: Array<OctreeBlock<T>>;
  105586. private _depth;
  105587. private _maxDepth;
  105588. private _capacity;
  105589. private _minPoint;
  105590. private _maxPoint;
  105591. private _boundingVectors;
  105592. private _creationFunc;
  105593. /**
  105594. * Creates a new block
  105595. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  105596. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  105597. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105598. * @param depth defines the current depth of this block in the octree
  105599. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  105600. * @param creationFunc defines a callback to call when an element is added to the block
  105601. */
  105602. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  105603. /**
  105604. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  105605. */
  105606. readonly capacity: number;
  105607. /**
  105608. * Gets the minimum vector (in world space) of the block's bounding box
  105609. */
  105610. readonly minPoint: Vector3;
  105611. /**
  105612. * Gets the maximum vector (in world space) of the block's bounding box
  105613. */
  105614. readonly maxPoint: Vector3;
  105615. /**
  105616. * Add a new element to this block
  105617. * @param entry defines the element to add
  105618. */
  105619. addEntry(entry: T): void;
  105620. /**
  105621. * Remove an element from this block
  105622. * @param entry defines the element to remove
  105623. */
  105624. removeEntry(entry: T): void;
  105625. /**
  105626. * Add an array of elements to this block
  105627. * @param entries defines the array of elements to add
  105628. */
  105629. addEntries(entries: T[]): void;
  105630. /**
  105631. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  105632. * @param frustumPlanes defines the frustum planes to test
  105633. * @param selection defines the array to store current content if selection is positive
  105634. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105635. */
  105636. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105637. /**
  105638. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  105639. * @param sphereCenter defines the bounding sphere center
  105640. * @param sphereRadius defines the bounding sphere radius
  105641. * @param selection defines the array to store current content if selection is positive
  105642. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105643. */
  105644. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  105645. /**
  105646. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  105647. * @param ray defines the ray to test with
  105648. * @param selection defines the array to store current content if selection is positive
  105649. */
  105650. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  105651. /**
  105652. * Subdivide the content into child blocks (this block will then be empty)
  105653. */
  105654. createInnerBlocks(): void;
  105655. /**
  105656. * @hidden
  105657. */
  105658. 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;
  105659. }
  105660. }
  105661. declare module BABYLON {
  105662. /**
  105663. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  105664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105665. */
  105666. export class Octree<T> {
  105667. /** 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.) */
  105668. maxDepth: number;
  105669. /**
  105670. * Blocks within the octree containing objects
  105671. */
  105672. blocks: Array<OctreeBlock<T>>;
  105673. /**
  105674. * Content stored in the octree
  105675. */
  105676. dynamicContent: T[];
  105677. private _maxBlockCapacity;
  105678. private _selectionContent;
  105679. private _creationFunc;
  105680. /**
  105681. * Creates a octree
  105682. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105683. * @param creationFunc function to be used to instatiate the octree
  105684. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  105685. * @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.)
  105686. */
  105687. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  105688. /** 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.) */
  105689. maxDepth?: number);
  105690. /**
  105691. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  105692. * @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);
  105693. * @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);
  105694. * @param entries meshes to be added to the octree blocks
  105695. */
  105696. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  105697. /**
  105698. * Adds a mesh to the octree
  105699. * @param entry Mesh to add to the octree
  105700. */
  105701. addMesh(entry: T): void;
  105702. /**
  105703. * Remove an element from the octree
  105704. * @param entry defines the element to remove
  105705. */
  105706. removeMesh(entry: T): void;
  105707. /**
  105708. * Selects an array of meshes within the frustum
  105709. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  105710. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  105711. * @returns array of meshes within the frustum
  105712. */
  105713. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  105714. /**
  105715. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  105716. * @param sphereCenter defines the bounding sphere center
  105717. * @param sphereRadius defines the bounding sphere radius
  105718. * @param allowDuplicate defines if the selection array can contains duplicated entries
  105719. * @returns an array of objects that intersect the sphere
  105720. */
  105721. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  105722. /**
  105723. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  105724. * @param ray defines the ray to test with
  105725. * @returns array of intersected objects
  105726. */
  105727. intersectsRay(ray: Ray): SmartArray<T>;
  105728. /**
  105729. * Adds a mesh into the octree block if it intersects the block
  105730. */
  105731. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  105732. /**
  105733. * Adds a submesh into the octree block if it intersects the block
  105734. */
  105735. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  105736. }
  105737. }
  105738. declare module BABYLON {
  105739. interface Scene {
  105740. /**
  105741. * @hidden
  105742. * Backing Filed
  105743. */
  105744. _selectionOctree: Octree<AbstractMesh>;
  105745. /**
  105746. * Gets the octree used to boost mesh selection (picking)
  105747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105748. */
  105749. selectionOctree: Octree<AbstractMesh>;
  105750. /**
  105751. * Creates or updates the octree used to boost selection (picking)
  105752. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105753. * @param maxCapacity defines the maximum capacity per leaf
  105754. * @param maxDepth defines the maximum depth of the octree
  105755. * @returns an octree of AbstractMesh
  105756. */
  105757. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  105758. }
  105759. interface AbstractMesh {
  105760. /**
  105761. * @hidden
  105762. * Backing Field
  105763. */
  105764. _submeshesOctree: Octree<SubMesh>;
  105765. /**
  105766. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  105767. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  105768. * @param maxCapacity defines the maximum size of each block (64 by default)
  105769. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  105770. * @returns the new octree
  105771. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  105772. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  105773. */
  105774. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  105775. }
  105776. /**
  105777. * Defines the octree scene component responsible to manage any octrees
  105778. * in a given scene.
  105779. */
  105780. export class OctreeSceneComponent {
  105781. /**
  105782. * The component name help to identify the component in the list of scene components.
  105783. */
  105784. readonly name: string;
  105785. /**
  105786. * The scene the component belongs to.
  105787. */
  105788. scene: Scene;
  105789. /**
  105790. * Indicates if the meshes have been checked to make sure they are isEnabled()
  105791. */
  105792. readonly checksIsEnabled: boolean;
  105793. /**
  105794. * Creates a new instance of the component for the given scene
  105795. * @param scene Defines the scene to register the component in
  105796. */
  105797. constructor(scene: Scene);
  105798. /**
  105799. * Registers the component in a given scene
  105800. */
  105801. register(): void;
  105802. /**
  105803. * Return the list of active meshes
  105804. * @returns the list of active meshes
  105805. */
  105806. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  105807. /**
  105808. * Return the list of active sub meshes
  105809. * @param mesh The mesh to get the candidates sub meshes from
  105810. * @returns the list of active sub meshes
  105811. */
  105812. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  105813. private _tempRay;
  105814. /**
  105815. * Return the list of sub meshes intersecting with a given local ray
  105816. * @param mesh defines the mesh to find the submesh for
  105817. * @param localRay defines the ray in local space
  105818. * @returns the list of intersecting sub meshes
  105819. */
  105820. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  105821. /**
  105822. * Return the list of sub meshes colliding with a collider
  105823. * @param mesh defines the mesh to find the submesh for
  105824. * @param collider defines the collider to evaluate the collision against
  105825. * @returns the list of colliding sub meshes
  105826. */
  105827. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  105828. /**
  105829. * Rebuilds the elements related to this component in case of
  105830. * context lost for instance.
  105831. */
  105832. rebuild(): void;
  105833. /**
  105834. * Disposes the component and the associated ressources.
  105835. */
  105836. dispose(): void;
  105837. }
  105838. }
  105839. declare module BABYLON {
  105840. /**
  105841. * Renders a layer on top of an existing scene
  105842. */
  105843. export class UtilityLayerRenderer implements IDisposable {
  105844. /** the original scene that will be rendered on top of */
  105845. originalScene: Scene;
  105846. private _pointerCaptures;
  105847. private _lastPointerEvents;
  105848. private static _DefaultUtilityLayer;
  105849. private static _DefaultKeepDepthUtilityLayer;
  105850. private _sharedGizmoLight;
  105851. private _renderCamera;
  105852. /**
  105853. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  105854. * @returns the camera that is used when rendering the utility layer
  105855. */
  105856. getRenderCamera(): Nullable<Camera>;
  105857. /**
  105858. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  105859. * @param cam the camera that should be used when rendering the utility layer
  105860. */
  105861. setRenderCamera(cam: Nullable<Camera>): void;
  105862. /**
  105863. * @hidden
  105864. * Light which used by gizmos to get light shading
  105865. */
  105866. _getSharedGizmoLight(): HemisphericLight;
  105867. /**
  105868. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  105869. */
  105870. pickUtilitySceneFirst: boolean;
  105871. /**
  105872. * 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)
  105873. */
  105874. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  105875. /**
  105876. * 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)
  105877. */
  105878. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  105879. /**
  105880. * The scene that is rendered on top of the original scene
  105881. */
  105882. utilityLayerScene: Scene;
  105883. /**
  105884. * If the utility layer should automatically be rendered on top of existing scene
  105885. */
  105886. shouldRender: boolean;
  105887. /**
  105888. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  105889. */
  105890. onlyCheckPointerDownEvents: boolean;
  105891. /**
  105892. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  105893. */
  105894. processAllEvents: boolean;
  105895. /**
  105896. * Observable raised when the pointer move from the utility layer scene to the main scene
  105897. */
  105898. onPointerOutObservable: Observable<number>;
  105899. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  105900. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  105901. private _afterRenderObserver;
  105902. private _sceneDisposeObserver;
  105903. private _originalPointerObserver;
  105904. /**
  105905. * Instantiates a UtilityLayerRenderer
  105906. * @param originalScene the original scene that will be rendered on top of
  105907. * @param handleEvents boolean indicating if the utility layer should handle events
  105908. */
  105909. constructor(
  105910. /** the original scene that will be rendered on top of */
  105911. originalScene: Scene, handleEvents?: boolean);
  105912. private _notifyObservers;
  105913. /**
  105914. * Renders the utility layers scene on top of the original scene
  105915. */
  105916. render(): void;
  105917. /**
  105918. * Disposes of the renderer
  105919. */
  105920. dispose(): void;
  105921. private _updateCamera;
  105922. }
  105923. }
  105924. declare module BABYLON {
  105925. /**
  105926. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  105927. */
  105928. export class Gizmo implements IDisposable {
  105929. /** The utility layer the gizmo will be added to */
  105930. gizmoLayer: UtilityLayerRenderer;
  105931. /**
  105932. * The root mesh of the gizmo
  105933. */
  105934. _rootMesh: Mesh;
  105935. private _attachedMesh;
  105936. /**
  105937. * Ratio for the scale of the gizmo (Default: 1)
  105938. */
  105939. scaleRatio: number;
  105940. /**
  105941. * If a custom mesh has been set (Default: false)
  105942. */
  105943. protected _customMeshSet: boolean;
  105944. /**
  105945. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  105946. * * When set, interactions will be enabled
  105947. */
  105948. attachedMesh: Nullable<AbstractMesh>;
  105949. /**
  105950. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105951. * @param mesh The mesh to replace the default mesh of the gizmo
  105952. */
  105953. setCustomMesh(mesh: Mesh): void;
  105954. /**
  105955. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  105956. */
  105957. updateGizmoRotationToMatchAttachedMesh: boolean;
  105958. /**
  105959. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  105960. */
  105961. updateGizmoPositionToMatchAttachedMesh: boolean;
  105962. /**
  105963. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  105964. */
  105965. updateScale: boolean;
  105966. protected _interactionsEnabled: boolean;
  105967. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105968. private _beforeRenderObserver;
  105969. private _tempVector;
  105970. /**
  105971. * Creates a gizmo
  105972. * @param gizmoLayer The utility layer the gizmo will be added to
  105973. */
  105974. constructor(
  105975. /** The utility layer the gizmo will be added to */
  105976. gizmoLayer?: UtilityLayerRenderer);
  105977. /**
  105978. * Updates the gizmo to match the attached mesh's position/rotation
  105979. */
  105980. protected _update(): void;
  105981. /**
  105982. * Disposes of the gizmo
  105983. */
  105984. dispose(): void;
  105985. }
  105986. }
  105987. declare module BABYLON {
  105988. /**
  105989. * Single plane drag gizmo
  105990. */
  105991. export class PlaneDragGizmo extends Gizmo {
  105992. /**
  105993. * Drag behavior responsible for the gizmos dragging interactions
  105994. */
  105995. dragBehavior: PointerDragBehavior;
  105996. private _pointerObserver;
  105997. /**
  105998. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105999. */
  106000. snapDistance: number;
  106001. /**
  106002. * Event that fires each time the gizmo snaps to a new location.
  106003. * * snapDistance is the the change in distance
  106004. */
  106005. onSnapObservable: Observable<{
  106006. snapDistance: number;
  106007. }>;
  106008. private _plane;
  106009. private _coloredMaterial;
  106010. private _hoverMaterial;
  106011. private _isEnabled;
  106012. private _parent;
  106013. /** @hidden */
  106014. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  106015. /** @hidden */
  106016. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106017. /**
  106018. * Creates a PlaneDragGizmo
  106019. * @param gizmoLayer The utility layer the gizmo will be added to
  106020. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  106021. * @param color The color of the gizmo
  106022. */
  106023. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106024. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106025. /**
  106026. * If the gizmo is enabled
  106027. */
  106028. isEnabled: boolean;
  106029. /**
  106030. * Disposes of the gizmo
  106031. */
  106032. dispose(): void;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /**
  106037. * Gizmo that enables dragging a mesh along 3 axis
  106038. */
  106039. export class PositionGizmo extends Gizmo {
  106040. /**
  106041. * Internal gizmo used for interactions on the x axis
  106042. */
  106043. xGizmo: AxisDragGizmo;
  106044. /**
  106045. * Internal gizmo used for interactions on the y axis
  106046. */
  106047. yGizmo: AxisDragGizmo;
  106048. /**
  106049. * Internal gizmo used for interactions on the z axis
  106050. */
  106051. zGizmo: AxisDragGizmo;
  106052. /**
  106053. * Internal gizmo used for interactions on the yz plane
  106054. */
  106055. xPlaneGizmo: PlaneDragGizmo;
  106056. /**
  106057. * Internal gizmo used for interactions on the xz plane
  106058. */
  106059. yPlaneGizmo: PlaneDragGizmo;
  106060. /**
  106061. * Internal gizmo used for interactions on the xy plane
  106062. */
  106063. zPlaneGizmo: PlaneDragGizmo;
  106064. /**
  106065. * private variables
  106066. */
  106067. private _meshAttached;
  106068. private _updateGizmoRotationToMatchAttachedMesh;
  106069. private _snapDistance;
  106070. private _scaleRatio;
  106071. /** Fires an event when any of it's sub gizmos are dragged */
  106072. onDragStartObservable: Observable<unknown>;
  106073. /** Fires an event when any of it's sub gizmos are released from dragging */
  106074. onDragEndObservable: Observable<unknown>;
  106075. /**
  106076. * If set to true, planar drag is enabled
  106077. */
  106078. private _planarGizmoEnabled;
  106079. attachedMesh: Nullable<AbstractMesh>;
  106080. /**
  106081. * Creates a PositionGizmo
  106082. * @param gizmoLayer The utility layer the gizmo will be added to
  106083. */
  106084. constructor(gizmoLayer?: UtilityLayerRenderer);
  106085. /**
  106086. * If the planar drag gizmo is enabled
  106087. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  106088. */
  106089. planarGizmoEnabled: boolean;
  106090. updateGizmoRotationToMatchAttachedMesh: boolean;
  106091. /**
  106092. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106093. */
  106094. snapDistance: number;
  106095. /**
  106096. * Ratio for the scale of the gizmo (Default: 1)
  106097. */
  106098. scaleRatio: number;
  106099. /**
  106100. * Disposes of the gizmo
  106101. */
  106102. dispose(): void;
  106103. /**
  106104. * CustomMeshes are not supported by this gizmo
  106105. * @param mesh The mesh to replace the default mesh of the gizmo
  106106. */
  106107. setCustomMesh(mesh: Mesh): void;
  106108. }
  106109. }
  106110. declare module BABYLON {
  106111. /**
  106112. * Single axis drag gizmo
  106113. */
  106114. export class AxisDragGizmo extends Gizmo {
  106115. /**
  106116. * Drag behavior responsible for the gizmos dragging interactions
  106117. */
  106118. dragBehavior: PointerDragBehavior;
  106119. private _pointerObserver;
  106120. /**
  106121. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106122. */
  106123. snapDistance: number;
  106124. /**
  106125. * Event that fires each time the gizmo snaps to a new location.
  106126. * * snapDistance is the the change in distance
  106127. */
  106128. onSnapObservable: Observable<{
  106129. snapDistance: number;
  106130. }>;
  106131. private _isEnabled;
  106132. private _parent;
  106133. private _arrow;
  106134. private _coloredMaterial;
  106135. private _hoverMaterial;
  106136. /** @hidden */
  106137. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  106138. /** @hidden */
  106139. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  106140. /**
  106141. * Creates an AxisDragGizmo
  106142. * @param gizmoLayer The utility layer the gizmo will be added to
  106143. * @param dragAxis The axis which the gizmo will be able to drag on
  106144. * @param color The color of the gizmo
  106145. */
  106146. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  106147. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  106148. /**
  106149. * If the gizmo is enabled
  106150. */
  106151. isEnabled: boolean;
  106152. /**
  106153. * Disposes of the gizmo
  106154. */
  106155. dispose(): void;
  106156. }
  106157. }
  106158. declare module BABYLON.Debug {
  106159. /**
  106160. * The Axes viewer will show 3 axes in a specific point in space
  106161. */
  106162. export class AxesViewer {
  106163. private _xAxis;
  106164. private _yAxis;
  106165. private _zAxis;
  106166. private _scaleLinesFactor;
  106167. private _instanced;
  106168. /**
  106169. * Gets the hosting scene
  106170. */
  106171. scene: Scene;
  106172. /**
  106173. * Gets or sets a number used to scale line length
  106174. */
  106175. scaleLines: number;
  106176. /** Gets the node hierarchy used to render x-axis */
  106177. readonly xAxis: TransformNode;
  106178. /** Gets the node hierarchy used to render y-axis */
  106179. readonly yAxis: TransformNode;
  106180. /** Gets the node hierarchy used to render z-axis */
  106181. readonly zAxis: TransformNode;
  106182. /**
  106183. * Creates a new AxesViewer
  106184. * @param scene defines the hosting scene
  106185. * @param scaleLines defines a number used to scale line length (1 by default)
  106186. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  106187. * @param xAxis defines the node hierarchy used to render the x-axis
  106188. * @param yAxis defines the node hierarchy used to render the y-axis
  106189. * @param zAxis defines the node hierarchy used to render the z-axis
  106190. */
  106191. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  106192. /**
  106193. * Force the viewer to update
  106194. * @param position defines the position of the viewer
  106195. * @param xaxis defines the x axis of the viewer
  106196. * @param yaxis defines the y axis of the viewer
  106197. * @param zaxis defines the z axis of the viewer
  106198. */
  106199. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  106200. /**
  106201. * Creates an instance of this axes viewer.
  106202. * @returns a new axes viewer with instanced meshes
  106203. */
  106204. createInstance(): AxesViewer;
  106205. /** Releases resources */
  106206. dispose(): void;
  106207. private static _SetRenderingGroupId;
  106208. }
  106209. }
  106210. declare module BABYLON.Debug {
  106211. /**
  106212. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  106213. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  106214. */
  106215. export class BoneAxesViewer extends AxesViewer {
  106216. /**
  106217. * Gets or sets the target mesh where to display the axes viewer
  106218. */
  106219. mesh: Nullable<Mesh>;
  106220. /**
  106221. * Gets or sets the target bone where to display the axes viewer
  106222. */
  106223. bone: Nullable<Bone>;
  106224. /** Gets current position */
  106225. pos: Vector3;
  106226. /** Gets direction of X axis */
  106227. xaxis: Vector3;
  106228. /** Gets direction of Y axis */
  106229. yaxis: Vector3;
  106230. /** Gets direction of Z axis */
  106231. zaxis: Vector3;
  106232. /**
  106233. * Creates a new BoneAxesViewer
  106234. * @param scene defines the hosting scene
  106235. * @param bone defines the target bone
  106236. * @param mesh defines the target mesh
  106237. * @param scaleLines defines a scaling factor for line length (1 by default)
  106238. */
  106239. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  106240. /**
  106241. * Force the viewer to update
  106242. */
  106243. update(): void;
  106244. /** Releases resources */
  106245. dispose(): void;
  106246. }
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * Interface used to define scene explorer extensibility option
  106251. */
  106252. export interface IExplorerExtensibilityOption {
  106253. /**
  106254. * Define the option label
  106255. */
  106256. label: string;
  106257. /**
  106258. * Defines the action to execute on click
  106259. */
  106260. action: (entity: any) => void;
  106261. }
  106262. /**
  106263. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  106264. */
  106265. export interface IExplorerExtensibilityGroup {
  106266. /**
  106267. * Defines a predicate to test if a given type mut be extended
  106268. */
  106269. predicate: (entity: any) => boolean;
  106270. /**
  106271. * Gets the list of options added to a type
  106272. */
  106273. entries: IExplorerExtensibilityOption[];
  106274. }
  106275. /**
  106276. * Interface used to define the options to use to create the Inspector
  106277. */
  106278. export interface IInspectorOptions {
  106279. /**
  106280. * Display in overlay mode (default: false)
  106281. */
  106282. overlay?: boolean;
  106283. /**
  106284. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  106285. */
  106286. globalRoot?: HTMLElement;
  106287. /**
  106288. * Display the Scene explorer
  106289. */
  106290. showExplorer?: boolean;
  106291. /**
  106292. * Display the property inspector
  106293. */
  106294. showInspector?: boolean;
  106295. /**
  106296. * Display in embed mode (both panes on the right)
  106297. */
  106298. embedMode?: boolean;
  106299. /**
  106300. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  106301. */
  106302. handleResize?: boolean;
  106303. /**
  106304. * Allow the panes to popup (default: true)
  106305. */
  106306. enablePopup?: boolean;
  106307. /**
  106308. * Allow the panes to be closed by users (default: true)
  106309. */
  106310. enableClose?: boolean;
  106311. /**
  106312. * Optional list of extensibility entries
  106313. */
  106314. explorerExtensibility?: IExplorerExtensibilityGroup[];
  106315. /**
  106316. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  106317. */
  106318. inspectorURL?: string;
  106319. }
  106320. interface Scene {
  106321. /**
  106322. * @hidden
  106323. * Backing field
  106324. */
  106325. _debugLayer: DebugLayer;
  106326. /**
  106327. * Gets the debug layer (aka Inspector) associated with the scene
  106328. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106329. */
  106330. debugLayer: DebugLayer;
  106331. }
  106332. /**
  106333. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106334. * what is happening in your scene
  106335. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106336. */
  106337. export class DebugLayer {
  106338. /**
  106339. * Define the url to get the inspector script from.
  106340. * By default it uses the babylonjs CDN.
  106341. * @ignoreNaming
  106342. */
  106343. static InspectorURL: string;
  106344. private _scene;
  106345. private BJSINSPECTOR;
  106346. private _onPropertyChangedObservable?;
  106347. /**
  106348. * Observable triggered when a property is changed through the inspector.
  106349. */
  106350. readonly onPropertyChangedObservable: any;
  106351. /**
  106352. * Instantiates a new debug layer.
  106353. * The debug layer (aka Inspector) is the go to tool in order to better understand
  106354. * what is happening in your scene
  106355. * @see http://doc.babylonjs.com/features/playground_debuglayer
  106356. * @param scene Defines the scene to inspect
  106357. */
  106358. constructor(scene: Scene);
  106359. /** Creates the inspector window. */
  106360. private _createInspector;
  106361. /**
  106362. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  106363. * @param entity defines the entity to select
  106364. * @param lineContainerTitle defines the specific block to highlight
  106365. */
  106366. select(entity: any, lineContainerTitle?: string): void;
  106367. /** Get the inspector from bundle or global */
  106368. private _getGlobalInspector;
  106369. /**
  106370. * Get if the inspector is visible or not.
  106371. * @returns true if visible otherwise, false
  106372. */
  106373. isVisible(): boolean;
  106374. /**
  106375. * Hide the inspector and close its window.
  106376. */
  106377. hide(): void;
  106378. /**
  106379. * Launch the debugLayer.
  106380. * @param config Define the configuration of the inspector
  106381. * @return a promise fulfilled when the debug layer is visible
  106382. */
  106383. show(config?: IInspectorOptions): Promise<DebugLayer>;
  106384. }
  106385. }
  106386. declare module BABYLON {
  106387. /**
  106388. * Class containing static functions to help procedurally build meshes
  106389. */
  106390. export class BoxBuilder {
  106391. /**
  106392. * Creates a box mesh
  106393. * * The parameter `size` sets the size (float) of each box side (default 1)
  106394. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  106395. * * 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)
  106396. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  106397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106398. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106400. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  106401. * @param name defines the name of the mesh
  106402. * @param options defines the options used to create the mesh
  106403. * @param scene defines the hosting scene
  106404. * @returns the box mesh
  106405. */
  106406. static CreateBox(name: string, options: {
  106407. size?: number;
  106408. width?: number;
  106409. height?: number;
  106410. depth?: number;
  106411. faceUV?: Vector4[];
  106412. faceColors?: Color4[];
  106413. sideOrientation?: number;
  106414. frontUVs?: Vector4;
  106415. backUVs?: Vector4;
  106416. wrap?: boolean;
  106417. topBaseAt?: number;
  106418. bottomBaseAt?: number;
  106419. updatable?: boolean;
  106420. }, scene?: Nullable<Scene>): Mesh;
  106421. }
  106422. }
  106423. declare module BABYLON {
  106424. /**
  106425. * Class containing static functions to help procedurally build meshes
  106426. */
  106427. export class SphereBuilder {
  106428. /**
  106429. * Creates a sphere mesh
  106430. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  106431. * * 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`)
  106432. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  106433. * * 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
  106434. * * 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)
  106435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  106436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106438. * @param name defines the name of the mesh
  106439. * @param options defines the options used to create the mesh
  106440. * @param scene defines the hosting scene
  106441. * @returns the sphere mesh
  106442. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  106443. */
  106444. static CreateSphere(name: string, options: {
  106445. segments?: number;
  106446. diameter?: number;
  106447. diameterX?: number;
  106448. diameterY?: number;
  106449. diameterZ?: number;
  106450. arc?: number;
  106451. slice?: number;
  106452. sideOrientation?: number;
  106453. frontUVs?: Vector4;
  106454. backUVs?: Vector4;
  106455. updatable?: boolean;
  106456. }, scene: any): Mesh;
  106457. }
  106458. }
  106459. declare module BABYLON.Debug {
  106460. /**
  106461. * Used to show the physics impostor around the specific mesh
  106462. */
  106463. export class PhysicsViewer {
  106464. /** @hidden */
  106465. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  106466. /** @hidden */
  106467. protected _meshes: Array<Nullable<AbstractMesh>>;
  106468. /** @hidden */
  106469. protected _scene: Nullable<Scene>;
  106470. /** @hidden */
  106471. protected _numMeshes: number;
  106472. /** @hidden */
  106473. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  106474. private _renderFunction;
  106475. private _utilityLayer;
  106476. private _debugBoxMesh;
  106477. private _debugSphereMesh;
  106478. private _debugCylinderMesh;
  106479. private _debugMaterial;
  106480. private _debugMeshMeshes;
  106481. /**
  106482. * Creates a new PhysicsViewer
  106483. * @param scene defines the hosting scene
  106484. */
  106485. constructor(scene: Scene);
  106486. /** @hidden */
  106487. protected _updateDebugMeshes(): void;
  106488. /**
  106489. * Renders a specified physic impostor
  106490. * @param impostor defines the impostor to render
  106491. * @param targetMesh defines the mesh represented by the impostor
  106492. * @returns the new debug mesh used to render the impostor
  106493. */
  106494. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  106495. /**
  106496. * Hides a specified physic impostor
  106497. * @param impostor defines the impostor to hide
  106498. */
  106499. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  106500. private _getDebugMaterial;
  106501. private _getDebugBoxMesh;
  106502. private _getDebugSphereMesh;
  106503. private _getDebugCylinderMesh;
  106504. private _getDebugMeshMesh;
  106505. private _getDebugMesh;
  106506. /** Releases all resources */
  106507. dispose(): void;
  106508. }
  106509. }
  106510. declare module BABYLON {
  106511. /**
  106512. * Class containing static functions to help procedurally build meshes
  106513. */
  106514. export class LinesBuilder {
  106515. /**
  106516. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  106517. * * 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
  106518. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  106519. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  106520. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  106521. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  106522. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  106523. * * 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
  106524. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  106525. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106526. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  106527. * @param name defines the name of the new line system
  106528. * @param options defines the options used to create the line system
  106529. * @param scene defines the hosting scene
  106530. * @returns a new line system mesh
  106531. */
  106532. static CreateLineSystem(name: string, options: {
  106533. lines: Vector3[][];
  106534. updatable?: boolean;
  106535. instance?: Nullable<LinesMesh>;
  106536. colors?: Nullable<Color4[][]>;
  106537. useVertexAlpha?: boolean;
  106538. }, scene: Nullable<Scene>): LinesMesh;
  106539. /**
  106540. * Creates a line mesh
  106541. * 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
  106542. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106543. * * The parameter `points` is an array successive Vector3
  106544. * * 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
  106545. * * The optional parameter `colors` is an array of successive Color4, one per line point
  106546. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  106547. * * When updating an instance, remember that only point positions can change, not the number of points
  106548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  106550. * @param name defines the name of the new line system
  106551. * @param options defines the options used to create the line system
  106552. * @param scene defines the hosting scene
  106553. * @returns a new line mesh
  106554. */
  106555. static CreateLines(name: string, options: {
  106556. points: Vector3[];
  106557. updatable?: boolean;
  106558. instance?: Nullable<LinesMesh>;
  106559. colors?: Color4[];
  106560. useVertexAlpha?: boolean;
  106561. }, scene?: Nullable<Scene>): LinesMesh;
  106562. /**
  106563. * Creates a dashed line mesh
  106564. * * 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
  106565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  106566. * * The parameter `points` is an array successive Vector3
  106567. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  106568. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  106569. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106570. * * 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
  106571. * * When updating an instance, remember that only point positions can change, not the number of points
  106572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106573. * @param name defines the name of the mesh
  106574. * @param options defines the options used to create the mesh
  106575. * @param scene defines the hosting scene
  106576. * @returns the dashed line mesh
  106577. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  106578. */
  106579. static CreateDashedLines(name: string, options: {
  106580. points: Vector3[];
  106581. dashSize?: number;
  106582. gapSize?: number;
  106583. dashNb?: number;
  106584. updatable?: boolean;
  106585. instance?: LinesMesh;
  106586. }, scene?: Nullable<Scene>): LinesMesh;
  106587. }
  106588. }
  106589. declare module BABYLON {
  106590. /**
  106591. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106592. * in order to better appreciate the issue one might have.
  106593. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106594. */
  106595. export class RayHelper {
  106596. /**
  106597. * Defines the ray we are currently tryin to visualize.
  106598. */
  106599. ray: Nullable<Ray>;
  106600. private _renderPoints;
  106601. private _renderLine;
  106602. private _renderFunction;
  106603. private _scene;
  106604. private _updateToMeshFunction;
  106605. private _attachedToMesh;
  106606. private _meshSpaceDirection;
  106607. private _meshSpaceOrigin;
  106608. /**
  106609. * Helper function to create a colored helper in a scene in one line.
  106610. * @param ray Defines the ray we are currently tryin to visualize
  106611. * @param scene Defines the scene the ray is used in
  106612. * @param color Defines the color we want to see the ray in
  106613. * @returns The newly created ray helper.
  106614. */
  106615. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  106616. /**
  106617. * Instantiate a new ray helper.
  106618. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  106619. * in order to better appreciate the issue one might have.
  106620. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  106621. * @param ray Defines the ray we are currently tryin to visualize
  106622. */
  106623. constructor(ray: Ray);
  106624. /**
  106625. * Shows the ray we are willing to debug.
  106626. * @param scene Defines the scene the ray needs to be rendered in
  106627. * @param color Defines the color the ray needs to be rendered in
  106628. */
  106629. show(scene: Scene, color?: Color3): void;
  106630. /**
  106631. * Hides the ray we are debugging.
  106632. */
  106633. hide(): void;
  106634. private _render;
  106635. /**
  106636. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  106637. * @param mesh Defines the mesh we want the helper attached to
  106638. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  106639. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  106640. * @param length Defines the length of the ray
  106641. */
  106642. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  106643. /**
  106644. * Detach the ray helper from the mesh it has previously been attached to.
  106645. */
  106646. detachFromMesh(): void;
  106647. private _updateToMesh;
  106648. /**
  106649. * Dispose the helper and release its associated resources.
  106650. */
  106651. dispose(): void;
  106652. }
  106653. }
  106654. declare module BABYLON.Debug {
  106655. /**
  106656. * Class used to render a debug view of a given skeleton
  106657. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  106658. */
  106659. export class SkeletonViewer {
  106660. /** defines the skeleton to render */
  106661. skeleton: Skeleton;
  106662. /** defines the mesh attached to the skeleton */
  106663. mesh: AbstractMesh;
  106664. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106665. autoUpdateBonesMatrices: boolean;
  106666. /** defines the rendering group id to use with the viewer */
  106667. renderingGroupId: number;
  106668. /** Gets or sets the color used to render the skeleton */
  106669. color: Color3;
  106670. private _scene;
  106671. private _debugLines;
  106672. private _debugMesh;
  106673. private _isEnabled;
  106674. private _renderFunction;
  106675. private _utilityLayer;
  106676. /**
  106677. * Returns the mesh used to render the bones
  106678. */
  106679. readonly debugMesh: Nullable<LinesMesh>;
  106680. /**
  106681. * Creates a new SkeletonViewer
  106682. * @param skeleton defines the skeleton to render
  106683. * @param mesh defines the mesh attached to the skeleton
  106684. * @param scene defines the hosting scene
  106685. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  106686. * @param renderingGroupId defines the rendering group id to use with the viewer
  106687. */
  106688. constructor(
  106689. /** defines the skeleton to render */
  106690. skeleton: Skeleton,
  106691. /** defines the mesh attached to the skeleton */
  106692. mesh: AbstractMesh, scene: Scene,
  106693. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  106694. autoUpdateBonesMatrices?: boolean,
  106695. /** defines the rendering group id to use with the viewer */
  106696. renderingGroupId?: number);
  106697. /** Gets or sets a boolean indicating if the viewer is enabled */
  106698. isEnabled: boolean;
  106699. private _getBonePosition;
  106700. private _getLinesForBonesWithLength;
  106701. private _getLinesForBonesNoLength;
  106702. /** Update the viewer to sync with current skeleton state */
  106703. update(): void;
  106704. /** Release associated resources */
  106705. dispose(): void;
  106706. }
  106707. }
  106708. declare module BABYLON {
  106709. /**
  106710. * Options to create the null engine
  106711. */
  106712. export class NullEngineOptions {
  106713. /**
  106714. * Render width (Default: 512)
  106715. */
  106716. renderWidth: number;
  106717. /**
  106718. * Render height (Default: 256)
  106719. */
  106720. renderHeight: number;
  106721. /**
  106722. * Texture size (Default: 512)
  106723. */
  106724. textureSize: number;
  106725. /**
  106726. * If delta time between frames should be constant
  106727. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106728. */
  106729. deterministicLockstep: boolean;
  106730. /**
  106731. * Maximum about of steps between frames (Default: 4)
  106732. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106733. */
  106734. lockstepMaxSteps: number;
  106735. }
  106736. /**
  106737. * The null engine class provides support for headless version of babylon.js.
  106738. * This can be used in server side scenario or for testing purposes
  106739. */
  106740. export class NullEngine extends Engine {
  106741. private _options;
  106742. /**
  106743. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106744. */
  106745. isDeterministicLockStep(): boolean;
  106746. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  106747. getLockstepMaxSteps(): number;
  106748. /**
  106749. * Sets hardware scaling, used to save performance if needed
  106750. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  106751. */
  106752. getHardwareScalingLevel(): number;
  106753. constructor(options?: NullEngineOptions);
  106754. createVertexBuffer(vertices: FloatArray): DataBuffer;
  106755. createIndexBuffer(indices: IndicesArray): DataBuffer;
  106756. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  106757. getRenderWidth(useScreen?: boolean): number;
  106758. getRenderHeight(useScreen?: boolean): number;
  106759. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  106760. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  106761. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106762. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106763. bindSamplers(effect: Effect): void;
  106764. enableEffect(effect: Effect): void;
  106765. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106766. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  106767. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  106768. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  106769. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  106770. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  106771. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  106772. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  106773. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  106774. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  106775. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  106776. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  106777. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  106778. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  106779. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106780. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  106781. setFloat(uniform: WebGLUniformLocation, value: number): void;
  106782. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  106783. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  106784. setBool(uniform: WebGLUniformLocation, bool: number): void;
  106785. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  106786. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106787. bindBuffers(vertexBuffers: {
  106788. [key: string]: VertexBuffer;
  106789. }, indexBuffer: DataBuffer, effect: Effect): void;
  106790. wipeCaches(bruteForce?: boolean): void;
  106791. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106792. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106793. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106794. /** @hidden */
  106795. _createTexture(): WebGLTexture;
  106796. /** @hidden */
  106797. _releaseTexture(texture: InternalTexture): void;
  106798. 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;
  106799. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  106800. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  106801. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  106802. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  106803. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  106804. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  106805. areAllEffectsReady(): boolean;
  106806. /**
  106807. * @hidden
  106808. * Get the current error code of the webGL context
  106809. * @returns the error code
  106810. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106811. */
  106812. getError(): number;
  106813. /** @hidden */
  106814. _getUnpackAlignement(): number;
  106815. /** @hidden */
  106816. _unpackFlipY(value: boolean): void;
  106817. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  106818. /**
  106819. * Updates a dynamic vertex buffer.
  106820. * @param vertexBuffer the vertex buffer to update
  106821. * @param data the data used to update the vertex buffer
  106822. * @param byteOffset the byte offset of the data (optional)
  106823. * @param byteLength the byte length of the data (optional)
  106824. */
  106825. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  106826. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  106827. /** @hidden */
  106828. _bindTexture(channel: number, texture: InternalTexture): void;
  106829. /** @hidden */
  106830. _releaseBuffer(buffer: DataBuffer): boolean;
  106831. releaseEffects(): void;
  106832. displayLoadingUI(): void;
  106833. hideLoadingUI(): void;
  106834. /** @hidden */
  106835. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106836. /** @hidden */
  106837. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106838. /** @hidden */
  106839. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106840. /** @hidden */
  106841. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  106842. }
  106843. }
  106844. declare module BABYLON {
  106845. /** @hidden */
  106846. export class _OcclusionDataStorage {
  106847. /** @hidden */
  106848. occlusionInternalRetryCounter: number;
  106849. /** @hidden */
  106850. isOcclusionQueryInProgress: boolean;
  106851. /** @hidden */
  106852. isOccluded: boolean;
  106853. /** @hidden */
  106854. occlusionRetryCount: number;
  106855. /** @hidden */
  106856. occlusionType: number;
  106857. /** @hidden */
  106858. occlusionQueryAlgorithmType: number;
  106859. }
  106860. interface Engine {
  106861. /**
  106862. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  106863. * @return the new query
  106864. */
  106865. createQuery(): WebGLQuery;
  106866. /**
  106867. * Delete and release a webGL query
  106868. * @param query defines the query to delete
  106869. * @return the current engine
  106870. */
  106871. deleteQuery(query: WebGLQuery): Engine;
  106872. /**
  106873. * Check if a given query has resolved and got its value
  106874. * @param query defines the query to check
  106875. * @returns true if the query got its value
  106876. */
  106877. isQueryResultAvailable(query: WebGLQuery): boolean;
  106878. /**
  106879. * Gets the value of a given query
  106880. * @param query defines the query to check
  106881. * @returns the value of the query
  106882. */
  106883. getQueryResult(query: WebGLQuery): number;
  106884. /**
  106885. * Initiates an occlusion query
  106886. * @param algorithmType defines the algorithm to use
  106887. * @param query defines the query to use
  106888. * @returns the current engine
  106889. * @see http://doc.babylonjs.com/features/occlusionquery
  106890. */
  106891. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  106892. /**
  106893. * Ends an occlusion query
  106894. * @see http://doc.babylonjs.com/features/occlusionquery
  106895. * @param algorithmType defines the algorithm to use
  106896. * @returns the current engine
  106897. */
  106898. endOcclusionQuery(algorithmType: number): Engine;
  106899. /**
  106900. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  106901. * Please note that only one query can be issued at a time
  106902. * @returns a time token used to track the time span
  106903. */
  106904. startTimeQuery(): Nullable<_TimeToken>;
  106905. /**
  106906. * Ends a time query
  106907. * @param token defines the token used to measure the time span
  106908. * @returns the time spent (in ns)
  106909. */
  106910. endTimeQuery(token: _TimeToken): int;
  106911. /** @hidden */
  106912. _currentNonTimestampToken: Nullable<_TimeToken>;
  106913. /** @hidden */
  106914. _createTimeQuery(): WebGLQuery;
  106915. /** @hidden */
  106916. _deleteTimeQuery(query: WebGLQuery): void;
  106917. /** @hidden */
  106918. _getGlAlgorithmType(algorithmType: number): number;
  106919. /** @hidden */
  106920. _getTimeQueryResult(query: WebGLQuery): any;
  106921. /** @hidden */
  106922. _getTimeQueryAvailability(query: WebGLQuery): any;
  106923. }
  106924. interface AbstractMesh {
  106925. /**
  106926. * Backing filed
  106927. * @hidden
  106928. */
  106929. __occlusionDataStorage: _OcclusionDataStorage;
  106930. /**
  106931. * Access property
  106932. * @hidden
  106933. */
  106934. _occlusionDataStorage: _OcclusionDataStorage;
  106935. /**
  106936. * 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.
  106937. * The default value is -1 which means don't break the query and wait till the result
  106938. * @see http://doc.babylonjs.com/features/occlusionquery
  106939. */
  106940. occlusionRetryCount: number;
  106941. /**
  106942. * 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:
  106943. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  106944. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  106945. * * 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.
  106946. * @see http://doc.babylonjs.com/features/occlusionquery
  106947. */
  106948. occlusionType: number;
  106949. /**
  106950. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  106951. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  106952. * * 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.
  106953. * @see http://doc.babylonjs.com/features/occlusionquery
  106954. */
  106955. occlusionQueryAlgorithmType: number;
  106956. /**
  106957. * 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
  106958. * @see http://doc.babylonjs.com/features/occlusionquery
  106959. */
  106960. isOccluded: boolean;
  106961. /**
  106962. * Flag to check the progress status of the query
  106963. * @see http://doc.babylonjs.com/features/occlusionquery
  106964. */
  106965. isOcclusionQueryInProgress: boolean;
  106966. }
  106967. }
  106968. declare module BABYLON {
  106969. /** @hidden */
  106970. export var _forceTransformFeedbackToBundle: boolean;
  106971. interface Engine {
  106972. /**
  106973. * Creates a webGL transform feedback object
  106974. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  106975. * @returns the webGL transform feedback object
  106976. */
  106977. createTransformFeedback(): WebGLTransformFeedback;
  106978. /**
  106979. * Delete a webGL transform feedback object
  106980. * @param value defines the webGL transform feedback object to delete
  106981. */
  106982. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  106983. /**
  106984. * Bind a webGL transform feedback object to the webgl context
  106985. * @param value defines the webGL transform feedback object to bind
  106986. */
  106987. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  106988. /**
  106989. * Begins a transform feedback operation
  106990. * @param usePoints defines if points or triangles must be used
  106991. */
  106992. beginTransformFeedback(usePoints: boolean): void;
  106993. /**
  106994. * Ends a transform feedback operation
  106995. */
  106996. endTransformFeedback(): void;
  106997. /**
  106998. * Specify the varyings to use with transform feedback
  106999. * @param program defines the associated webGL program
  107000. * @param value defines the list of strings representing the varying names
  107001. */
  107002. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  107003. /**
  107004. * Bind a webGL buffer for a transform feedback operation
  107005. * @param value defines the webGL buffer to bind
  107006. */
  107007. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  107008. }
  107009. }
  107010. declare module BABYLON {
  107011. /**
  107012. * Creation options of the multi render target texture.
  107013. */
  107014. export interface IMultiRenderTargetOptions {
  107015. /**
  107016. * Define if the texture needs to create mip maps after render.
  107017. */
  107018. generateMipMaps?: boolean;
  107019. /**
  107020. * Define the types of all the draw buffers we want to create
  107021. */
  107022. types?: number[];
  107023. /**
  107024. * Define the sampling modes of all the draw buffers we want to create
  107025. */
  107026. samplingModes?: number[];
  107027. /**
  107028. * Define if a depth buffer is required
  107029. */
  107030. generateDepthBuffer?: boolean;
  107031. /**
  107032. * Define if a stencil buffer is required
  107033. */
  107034. generateStencilBuffer?: boolean;
  107035. /**
  107036. * Define if a depth texture is required instead of a depth buffer
  107037. */
  107038. generateDepthTexture?: boolean;
  107039. /**
  107040. * Define the number of desired draw buffers
  107041. */
  107042. textureCount?: number;
  107043. /**
  107044. * Define if aspect ratio should be adapted to the texture or stay the scene one
  107045. */
  107046. doNotChangeAspectRatio?: boolean;
  107047. /**
  107048. * Define the default type of the buffers we are creating
  107049. */
  107050. defaultType?: number;
  107051. }
  107052. /**
  107053. * A multi render target, like a render target provides the ability to render to a texture.
  107054. * Unlike the render target, it can render to several draw buffers in one draw.
  107055. * This is specially interesting in deferred rendering or for any effects requiring more than
  107056. * just one color from a single pass.
  107057. */
  107058. export class MultiRenderTarget extends RenderTargetTexture {
  107059. private _internalTextures;
  107060. private _textures;
  107061. private _multiRenderTargetOptions;
  107062. /**
  107063. * Get if draw buffers are currently supported by the used hardware and browser.
  107064. */
  107065. readonly isSupported: boolean;
  107066. /**
  107067. * Get the list of textures generated by the multi render target.
  107068. */
  107069. readonly textures: Texture[];
  107070. /**
  107071. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  107072. */
  107073. readonly depthTexture: Texture;
  107074. /**
  107075. * Set the wrapping mode on U of all the textures we are rendering to.
  107076. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107077. */
  107078. wrapU: number;
  107079. /**
  107080. * Set the wrapping mode on V of all the textures we are rendering to.
  107081. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  107082. */
  107083. wrapV: number;
  107084. /**
  107085. * Instantiate a new multi render target texture.
  107086. * A multi render target, like a render target provides the ability to render to a texture.
  107087. * Unlike the render target, it can render to several draw buffers in one draw.
  107088. * This is specially interesting in deferred rendering or for any effects requiring more than
  107089. * just one color from a single pass.
  107090. * @param name Define the name of the texture
  107091. * @param size Define the size of the buffers to render to
  107092. * @param count Define the number of target we are rendering into
  107093. * @param scene Define the scene the texture belongs to
  107094. * @param options Define the options used to create the multi render target
  107095. */
  107096. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  107097. /** @hidden */
  107098. _rebuild(): void;
  107099. private _createInternalTextures;
  107100. private _createTextures;
  107101. /**
  107102. * Define the number of samples used if MSAA is enabled.
  107103. */
  107104. samples: number;
  107105. /**
  107106. * Resize all the textures in the multi render target.
  107107. * Be carrefull as it will recreate all the data in the new texture.
  107108. * @param size Define the new size
  107109. */
  107110. resize(size: any): void;
  107111. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  107112. /**
  107113. * Dispose the render targets and their associated resources
  107114. */
  107115. dispose(): void;
  107116. /**
  107117. * Release all the underlying texture used as draw buffers.
  107118. */
  107119. releaseInternalTextures(): void;
  107120. }
  107121. }
  107122. declare module BABYLON {
  107123. interface Engine {
  107124. /**
  107125. * Unbind a list of render target textures from the webGL context
  107126. * This is used only when drawBuffer extension or webGL2 are active
  107127. * @param textures defines the render target textures to unbind
  107128. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  107129. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  107130. */
  107131. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  107132. /**
  107133. * Create a multi render target texture
  107134. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  107135. * @param size defines the size of the texture
  107136. * @param options defines the creation options
  107137. * @returns the cube texture as an InternalTexture
  107138. */
  107139. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  107140. /**
  107141. * Update the sample count for a given multiple render target texture
  107142. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107143. * @param textures defines the textures to update
  107144. * @param samples defines the sample count to set
  107145. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107146. */
  107147. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  107148. }
  107149. }
  107150. declare module BABYLON {
  107151. /**
  107152. * Gather the list of clipboard event types as constants.
  107153. */
  107154. export class ClipboardEventTypes {
  107155. /**
  107156. * The clipboard event is fired when a copy command is active (pressed).
  107157. */
  107158. static readonly COPY: number;
  107159. /**
  107160. * The clipboard event is fired when a cut command is active (pressed).
  107161. */
  107162. static readonly CUT: number;
  107163. /**
  107164. * The clipboard event is fired when a paste command is active (pressed).
  107165. */
  107166. static readonly PASTE: number;
  107167. }
  107168. /**
  107169. * This class is used to store clipboard related info for the onClipboardObservable event.
  107170. */
  107171. export class ClipboardInfo {
  107172. /**
  107173. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107174. */
  107175. type: number;
  107176. /**
  107177. * Defines the related dom event
  107178. */
  107179. event: ClipboardEvent;
  107180. /**
  107181. *Creates an instance of ClipboardInfo.
  107182. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  107183. * @param event Defines the related dom event
  107184. */
  107185. constructor(
  107186. /**
  107187. * Defines the type of event (BABYLON.ClipboardEventTypes)
  107188. */
  107189. type: number,
  107190. /**
  107191. * Defines the related dom event
  107192. */
  107193. event: ClipboardEvent);
  107194. /**
  107195. * Get the clipboard event's type from the keycode.
  107196. * @param keyCode Defines the keyCode for the current keyboard event.
  107197. * @return {number}
  107198. */
  107199. static GetTypeFromCharacter(keyCode: number): number;
  107200. }
  107201. }
  107202. declare module BABYLON {
  107203. /**
  107204. * Google Daydream controller
  107205. */
  107206. export class DaydreamController extends WebVRController {
  107207. /**
  107208. * Base Url for the controller model.
  107209. */
  107210. static MODEL_BASE_URL: string;
  107211. /**
  107212. * File name for the controller model.
  107213. */
  107214. static MODEL_FILENAME: string;
  107215. /**
  107216. * Gamepad Id prefix used to identify Daydream Controller.
  107217. */
  107218. static readonly GAMEPAD_ID_PREFIX: string;
  107219. /**
  107220. * Creates a new DaydreamController from a gamepad
  107221. * @param vrGamepad the gamepad that the controller should be created from
  107222. */
  107223. constructor(vrGamepad: any);
  107224. /**
  107225. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107226. * @param scene scene in which to add meshes
  107227. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107228. */
  107229. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107230. /**
  107231. * Called once for each button that changed state since the last frame
  107232. * @param buttonIdx Which button index changed
  107233. * @param state New state of the button
  107234. * @param changes Which properties on the state changed since last frame
  107235. */
  107236. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107237. }
  107238. }
  107239. declare module BABYLON {
  107240. /**
  107241. * Gear VR Controller
  107242. */
  107243. export class GearVRController extends WebVRController {
  107244. /**
  107245. * Base Url for the controller model.
  107246. */
  107247. static MODEL_BASE_URL: string;
  107248. /**
  107249. * File name for the controller model.
  107250. */
  107251. static MODEL_FILENAME: string;
  107252. /**
  107253. * Gamepad Id prefix used to identify this controller.
  107254. */
  107255. static readonly GAMEPAD_ID_PREFIX: string;
  107256. private readonly _buttonIndexToObservableNameMap;
  107257. /**
  107258. * Creates a new GearVRController from a gamepad
  107259. * @param vrGamepad the gamepad that the controller should be created from
  107260. */
  107261. constructor(vrGamepad: any);
  107262. /**
  107263. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  107264. * @param scene scene in which to add meshes
  107265. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  107266. */
  107267. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  107268. /**
  107269. * Called once for each button that changed state since the last frame
  107270. * @param buttonIdx Which button index changed
  107271. * @param state New state of the button
  107272. * @param changes Which properties on the state changed since last frame
  107273. */
  107274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  107275. }
  107276. }
  107277. declare module BABYLON {
  107278. /**
  107279. * Class containing static functions to help procedurally build meshes
  107280. */
  107281. export class PolyhedronBuilder {
  107282. /**
  107283. * Creates a polyhedron mesh
  107284. * * 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
  107285. * * The parameter `size` (positive float, default 1) sets the polygon size
  107286. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  107287. * * 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`
  107288. * * 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
  107289. * * 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)`)
  107290. * * 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
  107291. * * 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
  107292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107293. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107295. * @param name defines the name of the mesh
  107296. * @param options defines the options used to create the mesh
  107297. * @param scene defines the hosting scene
  107298. * @returns the polyhedron mesh
  107299. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  107300. */
  107301. static CreatePolyhedron(name: string, options: {
  107302. type?: number;
  107303. size?: number;
  107304. sizeX?: number;
  107305. sizeY?: number;
  107306. sizeZ?: number;
  107307. custom?: any;
  107308. faceUV?: Vector4[];
  107309. faceColors?: Color4[];
  107310. flat?: boolean;
  107311. updatable?: boolean;
  107312. sideOrientation?: number;
  107313. frontUVs?: Vector4;
  107314. backUVs?: Vector4;
  107315. }, scene?: Nullable<Scene>): Mesh;
  107316. }
  107317. }
  107318. declare module BABYLON {
  107319. /**
  107320. * Gizmo that enables scaling a mesh along 3 axis
  107321. */
  107322. export class ScaleGizmo extends Gizmo {
  107323. /**
  107324. * Internal gizmo used for interactions on the x axis
  107325. */
  107326. xGizmo: AxisScaleGizmo;
  107327. /**
  107328. * Internal gizmo used for interactions on the y axis
  107329. */
  107330. yGizmo: AxisScaleGizmo;
  107331. /**
  107332. * Internal gizmo used for interactions on the z axis
  107333. */
  107334. zGizmo: AxisScaleGizmo;
  107335. /**
  107336. * Internal gizmo used to scale all axis equally
  107337. */
  107338. uniformScaleGizmo: AxisScaleGizmo;
  107339. private _meshAttached;
  107340. private _updateGizmoRotationToMatchAttachedMesh;
  107341. private _snapDistance;
  107342. private _scaleRatio;
  107343. private _uniformScalingMesh;
  107344. private _octahedron;
  107345. /** Fires an event when any of it's sub gizmos are dragged */
  107346. onDragStartObservable: Observable<unknown>;
  107347. /** Fires an event when any of it's sub gizmos are released from dragging */
  107348. onDragEndObservable: Observable<unknown>;
  107349. attachedMesh: Nullable<AbstractMesh>;
  107350. /**
  107351. * Creates a ScaleGizmo
  107352. * @param gizmoLayer The utility layer the gizmo will be added to
  107353. */
  107354. constructor(gizmoLayer?: UtilityLayerRenderer);
  107355. updateGizmoRotationToMatchAttachedMesh: boolean;
  107356. /**
  107357. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107358. */
  107359. snapDistance: number;
  107360. /**
  107361. * Ratio for the scale of the gizmo (Default: 1)
  107362. */
  107363. scaleRatio: number;
  107364. /**
  107365. * Disposes of the gizmo
  107366. */
  107367. dispose(): void;
  107368. }
  107369. }
  107370. declare module BABYLON {
  107371. /**
  107372. * Single axis scale gizmo
  107373. */
  107374. export class AxisScaleGizmo extends Gizmo {
  107375. /**
  107376. * Drag behavior responsible for the gizmos dragging interactions
  107377. */
  107378. dragBehavior: PointerDragBehavior;
  107379. private _pointerObserver;
  107380. /**
  107381. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107382. */
  107383. snapDistance: number;
  107384. /**
  107385. * Event that fires each time the gizmo snaps to a new location.
  107386. * * snapDistance is the the change in distance
  107387. */
  107388. onSnapObservable: Observable<{
  107389. snapDistance: number;
  107390. }>;
  107391. /**
  107392. * If the scaling operation should be done on all axis (default: false)
  107393. */
  107394. uniformScaling: boolean;
  107395. private _isEnabled;
  107396. private _parent;
  107397. private _arrow;
  107398. private _coloredMaterial;
  107399. private _hoverMaterial;
  107400. /**
  107401. * Creates an AxisScaleGizmo
  107402. * @param gizmoLayer The utility layer the gizmo will be added to
  107403. * @param dragAxis The axis which the gizmo will be able to scale on
  107404. * @param color The color of the gizmo
  107405. */
  107406. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  107407. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107408. /**
  107409. * If the gizmo is enabled
  107410. */
  107411. isEnabled: boolean;
  107412. /**
  107413. * Disposes of the gizmo
  107414. */
  107415. dispose(): void;
  107416. /**
  107417. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  107418. * @param mesh The mesh to replace the default mesh of the gizmo
  107419. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  107420. */
  107421. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  107422. }
  107423. }
  107424. declare module BABYLON {
  107425. /**
  107426. * Bounding box gizmo
  107427. */
  107428. export class BoundingBoxGizmo extends Gizmo {
  107429. private _lineBoundingBox;
  107430. private _rotateSpheresParent;
  107431. private _scaleBoxesParent;
  107432. private _boundingDimensions;
  107433. private _renderObserver;
  107434. private _pointerObserver;
  107435. private _scaleDragSpeed;
  107436. private _tmpQuaternion;
  107437. private _tmpVector;
  107438. private _tmpRotationMatrix;
  107439. /**
  107440. * 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)
  107441. */
  107442. ignoreChildren: boolean;
  107443. /**
  107444. * 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)
  107445. */
  107446. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  107447. /**
  107448. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  107449. */
  107450. rotationSphereSize: number;
  107451. /**
  107452. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  107453. */
  107454. scaleBoxSize: number;
  107455. /**
  107456. * 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)
  107457. */
  107458. fixedDragMeshScreenSize: boolean;
  107459. /**
  107460. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  107461. */
  107462. fixedDragMeshScreenSizeDistanceFactor: number;
  107463. /**
  107464. * Fired when a rotation sphere or scale box is dragged
  107465. */
  107466. onDragStartObservable: Observable<{}>;
  107467. /**
  107468. * Fired when a scale box is dragged
  107469. */
  107470. onScaleBoxDragObservable: Observable<{}>;
  107471. /**
  107472. * Fired when a scale box drag is ended
  107473. */
  107474. onScaleBoxDragEndObservable: Observable<{}>;
  107475. /**
  107476. * Fired when a rotation sphere is dragged
  107477. */
  107478. onRotationSphereDragObservable: Observable<{}>;
  107479. /**
  107480. * Fired when a rotation sphere drag is ended
  107481. */
  107482. onRotationSphereDragEndObservable: Observable<{}>;
  107483. /**
  107484. * 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)
  107485. */
  107486. scalePivot: Nullable<Vector3>;
  107487. /**
  107488. * Mesh used as a pivot to rotate the attached mesh
  107489. */
  107490. private _anchorMesh;
  107491. private _existingMeshScale;
  107492. private _dragMesh;
  107493. private pointerDragBehavior;
  107494. private coloredMaterial;
  107495. private hoverColoredMaterial;
  107496. /**
  107497. * Sets the color of the bounding box gizmo
  107498. * @param color the color to set
  107499. */
  107500. setColor(color: Color3): void;
  107501. /**
  107502. * Creates an BoundingBoxGizmo
  107503. * @param gizmoLayer The utility layer the gizmo will be added to
  107504. * @param color The color of the gizmo
  107505. */
  107506. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  107507. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107508. private _selectNode;
  107509. /**
  107510. * Updates the bounding box information for the Gizmo
  107511. */
  107512. updateBoundingBox(): void;
  107513. private _updateRotationSpheres;
  107514. private _updateScaleBoxes;
  107515. /**
  107516. * Enables rotation on the specified axis and disables rotation on the others
  107517. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  107518. */
  107519. setEnabledRotationAxis(axis: string): void;
  107520. /**
  107521. * Enables/disables scaling
  107522. * @param enable if scaling should be enabled
  107523. */
  107524. setEnabledScaling(enable: boolean): void;
  107525. private _updateDummy;
  107526. /**
  107527. * Enables a pointer drag behavior on the bounding box of the gizmo
  107528. */
  107529. enableDragBehavior(): void;
  107530. /**
  107531. * Disposes of the gizmo
  107532. */
  107533. dispose(): void;
  107534. /**
  107535. * 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)
  107536. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  107537. * @returns the bounding box mesh with the passed in mesh as a child
  107538. */
  107539. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  107540. /**
  107541. * CustomMeshes are not supported by this gizmo
  107542. * @param mesh The mesh to replace the default mesh of the gizmo
  107543. */
  107544. setCustomMesh(mesh: Mesh): void;
  107545. }
  107546. }
  107547. declare module BABYLON {
  107548. /**
  107549. * Single plane rotation gizmo
  107550. */
  107551. export class PlaneRotationGizmo extends Gizmo {
  107552. /**
  107553. * Drag behavior responsible for the gizmos dragging interactions
  107554. */
  107555. dragBehavior: PointerDragBehavior;
  107556. private _pointerObserver;
  107557. /**
  107558. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  107559. */
  107560. snapDistance: number;
  107561. /**
  107562. * Event that fires each time the gizmo snaps to a new location.
  107563. * * snapDistance is the the change in distance
  107564. */
  107565. onSnapObservable: Observable<{
  107566. snapDistance: number;
  107567. }>;
  107568. private _isEnabled;
  107569. private _parent;
  107570. /**
  107571. * Creates a PlaneRotationGizmo
  107572. * @param gizmoLayer The utility layer the gizmo will be added to
  107573. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  107574. * @param color The color of the gizmo
  107575. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107576. */
  107577. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  107578. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  107579. /**
  107580. * If the gizmo is enabled
  107581. */
  107582. isEnabled: boolean;
  107583. /**
  107584. * Disposes of the gizmo
  107585. */
  107586. dispose(): void;
  107587. }
  107588. }
  107589. declare module BABYLON {
  107590. /**
  107591. * Gizmo that enables rotating a mesh along 3 axis
  107592. */
  107593. export class RotationGizmo extends Gizmo {
  107594. /**
  107595. * Internal gizmo used for interactions on the x axis
  107596. */
  107597. xGizmo: PlaneRotationGizmo;
  107598. /**
  107599. * Internal gizmo used for interactions on the y axis
  107600. */
  107601. yGizmo: PlaneRotationGizmo;
  107602. /**
  107603. * Internal gizmo used for interactions on the z axis
  107604. */
  107605. zGizmo: PlaneRotationGizmo;
  107606. /** Fires an event when any of it's sub gizmos are dragged */
  107607. onDragStartObservable: Observable<unknown>;
  107608. /** Fires an event when any of it's sub gizmos are released from dragging */
  107609. onDragEndObservable: Observable<unknown>;
  107610. private _meshAttached;
  107611. attachedMesh: Nullable<AbstractMesh>;
  107612. /**
  107613. * Creates a RotationGizmo
  107614. * @param gizmoLayer The utility layer the gizmo will be added to
  107615. * @param tessellation Amount of tessellation to be used when creating rotation circles
  107616. */
  107617. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  107618. updateGizmoRotationToMatchAttachedMesh: boolean;
  107619. /**
  107620. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  107621. */
  107622. snapDistance: number;
  107623. /**
  107624. * Ratio for the scale of the gizmo (Default: 1)
  107625. */
  107626. scaleRatio: number;
  107627. /**
  107628. * Disposes of the gizmo
  107629. */
  107630. dispose(): void;
  107631. /**
  107632. * CustomMeshes are not supported by this gizmo
  107633. * @param mesh The mesh to replace the default mesh of the gizmo
  107634. */
  107635. setCustomMesh(mesh: Mesh): void;
  107636. }
  107637. }
  107638. declare module BABYLON {
  107639. /**
  107640. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  107641. */
  107642. export class GizmoManager implements IDisposable {
  107643. private scene;
  107644. /**
  107645. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  107646. */
  107647. gizmos: {
  107648. positionGizmo: Nullable<PositionGizmo>;
  107649. rotationGizmo: Nullable<RotationGizmo>;
  107650. scaleGizmo: Nullable<ScaleGizmo>;
  107651. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  107652. };
  107653. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  107654. clearGizmoOnEmptyPointerEvent: boolean;
  107655. /** Fires an event when the manager is attached to a mesh */
  107656. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  107657. private _gizmosEnabled;
  107658. private _pointerObserver;
  107659. private _attachedMesh;
  107660. private _boundingBoxColor;
  107661. private _defaultUtilityLayer;
  107662. private _defaultKeepDepthUtilityLayer;
  107663. /**
  107664. * When bounding box gizmo is enabled, this can be used to track drag/end events
  107665. */
  107666. boundingBoxDragBehavior: SixDofDragBehavior;
  107667. /**
  107668. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  107669. */
  107670. attachableMeshes: Nullable<Array<AbstractMesh>>;
  107671. /**
  107672. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  107673. */
  107674. usePointerToAttachGizmos: boolean;
  107675. /**
  107676. * Utility layer that the bounding box gizmo belongs to
  107677. */
  107678. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  107679. /**
  107680. * Utility layer that all gizmos besides bounding box belong to
  107681. */
  107682. readonly utilityLayer: UtilityLayerRenderer;
  107683. /**
  107684. * Instatiates a gizmo manager
  107685. * @param scene the scene to overlay the gizmos on top of
  107686. */
  107687. constructor(scene: Scene);
  107688. /**
  107689. * Attaches a set of gizmos to the specified mesh
  107690. * @param mesh The mesh the gizmo's should be attached to
  107691. */
  107692. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  107693. /**
  107694. * If the position gizmo is enabled
  107695. */
  107696. positionGizmoEnabled: boolean;
  107697. /**
  107698. * If the rotation gizmo is enabled
  107699. */
  107700. rotationGizmoEnabled: boolean;
  107701. /**
  107702. * If the scale gizmo is enabled
  107703. */
  107704. scaleGizmoEnabled: boolean;
  107705. /**
  107706. * If the boundingBox gizmo is enabled
  107707. */
  107708. boundingBoxGizmoEnabled: boolean;
  107709. /**
  107710. * Disposes of the gizmo manager
  107711. */
  107712. dispose(): void;
  107713. }
  107714. }
  107715. declare module BABYLON {
  107716. /**
  107717. * A directional light is defined by a direction (what a surprise!).
  107718. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  107719. * 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.
  107720. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107721. */
  107722. export class DirectionalLight extends ShadowLight {
  107723. private _shadowFrustumSize;
  107724. /**
  107725. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  107726. */
  107727. /**
  107728. * Specifies a fix frustum size for the shadow generation.
  107729. */
  107730. shadowFrustumSize: number;
  107731. private _shadowOrthoScale;
  107732. /**
  107733. * Gets the shadow projection scale against the optimal computed one.
  107734. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107735. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107736. */
  107737. /**
  107738. * Sets the shadow projection scale against the optimal computed one.
  107739. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  107740. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  107741. */
  107742. shadowOrthoScale: number;
  107743. /**
  107744. * Automatically compute the projection matrix to best fit (including all the casters)
  107745. * on each frame.
  107746. */
  107747. autoUpdateExtends: boolean;
  107748. private _orthoLeft;
  107749. private _orthoRight;
  107750. private _orthoTop;
  107751. private _orthoBottom;
  107752. /**
  107753. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  107754. * The directional light is emitted from everywhere in the given direction.
  107755. * It can cast shadows.
  107756. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107757. * @param name The friendly name of the light
  107758. * @param direction The direction of the light
  107759. * @param scene The scene the light belongs to
  107760. */
  107761. constructor(name: string, direction: Vector3, scene: Scene);
  107762. /**
  107763. * Returns the string "DirectionalLight".
  107764. * @return The class name
  107765. */
  107766. getClassName(): string;
  107767. /**
  107768. * Returns the integer 1.
  107769. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107770. */
  107771. getTypeID(): number;
  107772. /**
  107773. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  107774. * Returns the DirectionalLight Shadow projection matrix.
  107775. */
  107776. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107777. /**
  107778. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  107779. * Returns the DirectionalLight Shadow projection matrix.
  107780. */
  107781. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  107782. /**
  107783. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  107784. * Returns the DirectionalLight Shadow projection matrix.
  107785. */
  107786. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107787. protected _buildUniformLayout(): void;
  107788. /**
  107789. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  107790. * @param effect The effect to update
  107791. * @param lightIndex The index of the light in the effect to update
  107792. * @returns The directional light
  107793. */
  107794. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  107795. /**
  107796. * Gets the minZ used for shadow according to both the scene and the light.
  107797. *
  107798. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107799. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107800. * @param activeCamera The camera we are returning the min for
  107801. * @returns the depth min z
  107802. */
  107803. getDepthMinZ(activeCamera: Camera): number;
  107804. /**
  107805. * Gets the maxZ used for shadow according to both the scene and the light.
  107806. *
  107807. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  107808. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  107809. * @param activeCamera The camera we are returning the max for
  107810. * @returns the depth max z
  107811. */
  107812. getDepthMaxZ(activeCamera: Camera): number;
  107813. /**
  107814. * Prepares the list of defines specific to the light type.
  107815. * @param defines the list of defines
  107816. * @param lightIndex defines the index of the light for the effect
  107817. */
  107818. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107819. }
  107820. }
  107821. declare module BABYLON {
  107822. /**
  107823. * Class containing static functions to help procedurally build meshes
  107824. */
  107825. export class HemisphereBuilder {
  107826. /**
  107827. * Creates a hemisphere mesh
  107828. * @param name defines the name of the mesh
  107829. * @param options defines the options used to create the mesh
  107830. * @param scene defines the hosting scene
  107831. * @returns the hemisphere mesh
  107832. */
  107833. static CreateHemisphere(name: string, options: {
  107834. segments?: number;
  107835. diameter?: number;
  107836. sideOrientation?: number;
  107837. }, scene: any): Mesh;
  107838. }
  107839. }
  107840. declare module BABYLON {
  107841. /**
  107842. * A spot light is defined by a position, a direction, an angle, and an exponent.
  107843. * These values define a cone of light starting from the position, emitting toward the direction.
  107844. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  107845. * and the exponent defines the speed of the decay of the light with distance (reach).
  107846. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107847. */
  107848. export class SpotLight extends ShadowLight {
  107849. private _angle;
  107850. private _innerAngle;
  107851. private _cosHalfAngle;
  107852. private _lightAngleScale;
  107853. private _lightAngleOffset;
  107854. /**
  107855. * Gets the cone angle of the spot light in Radians.
  107856. */
  107857. /**
  107858. * Sets the cone angle of the spot light in Radians.
  107859. */
  107860. angle: number;
  107861. /**
  107862. * Only used in gltf falloff mode, this defines the angle where
  107863. * the directional falloff will start before cutting at angle which could be seen
  107864. * as outer angle.
  107865. */
  107866. /**
  107867. * Only used in gltf falloff mode, this defines the angle where
  107868. * the directional falloff will start before cutting at angle which could be seen
  107869. * as outer angle.
  107870. */
  107871. innerAngle: number;
  107872. private _shadowAngleScale;
  107873. /**
  107874. * Allows scaling the angle of the light for shadow generation only.
  107875. */
  107876. /**
  107877. * Allows scaling the angle of the light for shadow generation only.
  107878. */
  107879. shadowAngleScale: number;
  107880. /**
  107881. * The light decay speed with the distance from the emission spot.
  107882. */
  107883. exponent: number;
  107884. private _projectionTextureMatrix;
  107885. /**
  107886. * Allows reading the projecton texture
  107887. */
  107888. readonly projectionTextureMatrix: Matrix;
  107889. protected _projectionTextureLightNear: number;
  107890. /**
  107891. * Gets the near clip of the Spotlight for texture projection.
  107892. */
  107893. /**
  107894. * Sets the near clip of the Spotlight for texture projection.
  107895. */
  107896. projectionTextureLightNear: number;
  107897. protected _projectionTextureLightFar: number;
  107898. /**
  107899. * Gets the far clip of the Spotlight for texture projection.
  107900. */
  107901. /**
  107902. * Sets the far clip of the Spotlight for texture projection.
  107903. */
  107904. projectionTextureLightFar: number;
  107905. protected _projectionTextureUpDirection: Vector3;
  107906. /**
  107907. * Gets the Up vector of the Spotlight for texture projection.
  107908. */
  107909. /**
  107910. * Sets the Up vector of the Spotlight for texture projection.
  107911. */
  107912. projectionTextureUpDirection: Vector3;
  107913. private _projectionTexture;
  107914. /**
  107915. * Gets the projection texture of the light.
  107916. */
  107917. /**
  107918. * Sets the projection texture of the light.
  107919. */
  107920. projectionTexture: Nullable<BaseTexture>;
  107921. private _projectionTextureViewLightDirty;
  107922. private _projectionTextureProjectionLightDirty;
  107923. private _projectionTextureDirty;
  107924. private _projectionTextureViewTargetVector;
  107925. private _projectionTextureViewLightMatrix;
  107926. private _projectionTextureProjectionLightMatrix;
  107927. private _projectionTextureScalingMatrix;
  107928. /**
  107929. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  107930. * It can cast shadows.
  107931. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107932. * @param name The light friendly name
  107933. * @param position The position of the spot light in the scene
  107934. * @param direction The direction of the light in the scene
  107935. * @param angle The cone angle of the light in Radians
  107936. * @param exponent The light decay speed with the distance from the emission spot
  107937. * @param scene The scene the lights belongs to
  107938. */
  107939. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  107940. /**
  107941. * Returns the string "SpotLight".
  107942. * @returns the class name
  107943. */
  107944. getClassName(): string;
  107945. /**
  107946. * Returns the integer 2.
  107947. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107948. */
  107949. getTypeID(): number;
  107950. /**
  107951. * Overrides the direction setter to recompute the projection texture view light Matrix.
  107952. */
  107953. protected _setDirection(value: Vector3): void;
  107954. /**
  107955. * Overrides the position setter to recompute the projection texture view light Matrix.
  107956. */
  107957. protected _setPosition(value: Vector3): void;
  107958. /**
  107959. * 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.
  107960. * Returns the SpotLight.
  107961. */
  107962. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107963. protected _computeProjectionTextureViewLightMatrix(): void;
  107964. protected _computeProjectionTextureProjectionLightMatrix(): void;
  107965. /**
  107966. * Main function for light texture projection matrix computing.
  107967. */
  107968. protected _computeProjectionTextureMatrix(): void;
  107969. protected _buildUniformLayout(): void;
  107970. private _computeAngleValues;
  107971. /**
  107972. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  107973. * @param effect The effect to update
  107974. * @param lightIndex The index of the light in the effect to update
  107975. * @returns The spot light
  107976. */
  107977. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  107978. /**
  107979. * Disposes the light and the associated resources.
  107980. */
  107981. dispose(): void;
  107982. /**
  107983. * Prepares the list of defines specific to the light type.
  107984. * @param defines the list of defines
  107985. * @param lightIndex defines the index of the light for the effect
  107986. */
  107987. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107988. }
  107989. }
  107990. declare module BABYLON {
  107991. /**
  107992. * Gizmo that enables viewing a light
  107993. */
  107994. export class LightGizmo extends Gizmo {
  107995. private _lightMesh;
  107996. private _material;
  107997. private cachedPosition;
  107998. private cachedForward;
  107999. /**
  108000. * Creates a LightGizmo
  108001. * @param gizmoLayer The utility layer the gizmo will be added to
  108002. */
  108003. constructor(gizmoLayer?: UtilityLayerRenderer);
  108004. private _light;
  108005. /**
  108006. * The light that the gizmo is attached to
  108007. */
  108008. light: Nullable<Light>;
  108009. /**
  108010. * @hidden
  108011. * Updates the gizmo to match the attached mesh's position/rotation
  108012. */
  108013. protected _update(): void;
  108014. private static _Scale;
  108015. /**
  108016. * Creates the lines for a light mesh
  108017. */
  108018. private static _createLightLines;
  108019. /**
  108020. * Disposes of the light gizmo
  108021. */
  108022. dispose(): void;
  108023. private static _CreateHemisphericLightMesh;
  108024. private static _CreatePointLightMesh;
  108025. private static _CreateSpotLightMesh;
  108026. private static _CreateDirectionalLightMesh;
  108027. }
  108028. }
  108029. declare module BABYLON {
  108030. /** @hidden */
  108031. export var backgroundFragmentDeclaration: {
  108032. name: string;
  108033. shader: string;
  108034. };
  108035. }
  108036. declare module BABYLON {
  108037. /** @hidden */
  108038. export var backgroundUboDeclaration: {
  108039. name: string;
  108040. shader: string;
  108041. };
  108042. }
  108043. declare module BABYLON {
  108044. /** @hidden */
  108045. export var backgroundPixelShader: {
  108046. name: string;
  108047. shader: string;
  108048. };
  108049. }
  108050. declare module BABYLON {
  108051. /** @hidden */
  108052. export var backgroundVertexDeclaration: {
  108053. name: string;
  108054. shader: string;
  108055. };
  108056. }
  108057. declare module BABYLON {
  108058. /** @hidden */
  108059. export var backgroundVertexShader: {
  108060. name: string;
  108061. shader: string;
  108062. };
  108063. }
  108064. declare module BABYLON {
  108065. /**
  108066. * Background material used to create an efficient environement around your scene.
  108067. */
  108068. export class BackgroundMaterial extends PushMaterial {
  108069. /**
  108070. * Standard reflectance value at parallel view angle.
  108071. */
  108072. static StandardReflectance0: number;
  108073. /**
  108074. * Standard reflectance value at grazing angle.
  108075. */
  108076. static StandardReflectance90: number;
  108077. protected _primaryColor: Color3;
  108078. /**
  108079. * Key light Color (multiply against the environement texture)
  108080. */
  108081. primaryColor: Color3;
  108082. protected __perceptualColor: Nullable<Color3>;
  108083. /**
  108084. * Experimental Internal Use Only.
  108085. *
  108086. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  108087. * This acts as a helper to set the primary color to a more "human friendly" value.
  108088. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  108089. * output color as close as possible from the chosen value.
  108090. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  108091. * part of lighting setup.)
  108092. */
  108093. _perceptualColor: Nullable<Color3>;
  108094. protected _primaryColorShadowLevel: float;
  108095. /**
  108096. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  108097. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  108098. */
  108099. primaryColorShadowLevel: float;
  108100. protected _primaryColorHighlightLevel: float;
  108101. /**
  108102. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  108103. * The primary color is used at the level chosen to define what the white area would look.
  108104. */
  108105. primaryColorHighlightLevel: float;
  108106. protected _reflectionTexture: Nullable<BaseTexture>;
  108107. /**
  108108. * Reflection Texture used in the material.
  108109. * Should be author in a specific way for the best result (refer to the documentation).
  108110. */
  108111. reflectionTexture: Nullable<BaseTexture>;
  108112. protected _reflectionBlur: float;
  108113. /**
  108114. * Reflection Texture level of blur.
  108115. *
  108116. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  108117. * texture twice.
  108118. */
  108119. reflectionBlur: float;
  108120. protected _diffuseTexture: Nullable<BaseTexture>;
  108121. /**
  108122. * Diffuse Texture used in the material.
  108123. * Should be author in a specific way for the best result (refer to the documentation).
  108124. */
  108125. diffuseTexture: Nullable<BaseTexture>;
  108126. protected _shadowLights: Nullable<IShadowLight[]>;
  108127. /**
  108128. * Specify the list of lights casting shadow on the material.
  108129. * All scene shadow lights will be included if null.
  108130. */
  108131. shadowLights: Nullable<IShadowLight[]>;
  108132. protected _shadowLevel: float;
  108133. /**
  108134. * Helps adjusting the shadow to a softer level if required.
  108135. * 0 means black shadows and 1 means no shadows.
  108136. */
  108137. shadowLevel: float;
  108138. protected _sceneCenter: Vector3;
  108139. /**
  108140. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  108141. * It is usually zero but might be interesting to modify according to your setup.
  108142. */
  108143. sceneCenter: Vector3;
  108144. protected _opacityFresnel: boolean;
  108145. /**
  108146. * This helps specifying that the material is falling off to the sky box at grazing angle.
  108147. * This helps ensuring a nice transition when the camera goes under the ground.
  108148. */
  108149. opacityFresnel: boolean;
  108150. protected _reflectionFresnel: boolean;
  108151. /**
  108152. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  108153. * This helps adding a mirror texture on the ground.
  108154. */
  108155. reflectionFresnel: boolean;
  108156. protected _reflectionFalloffDistance: number;
  108157. /**
  108158. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  108159. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  108160. */
  108161. reflectionFalloffDistance: number;
  108162. protected _reflectionAmount: number;
  108163. /**
  108164. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  108165. */
  108166. reflectionAmount: number;
  108167. protected _reflectionReflectance0: number;
  108168. /**
  108169. * This specifies the weight of the reflection at grazing angle.
  108170. */
  108171. reflectionReflectance0: number;
  108172. protected _reflectionReflectance90: number;
  108173. /**
  108174. * This specifies the weight of the reflection at a perpendicular point of view.
  108175. */
  108176. reflectionReflectance90: number;
  108177. /**
  108178. * Sets the reflection reflectance fresnel values according to the default standard
  108179. * empirically know to work well :-)
  108180. */
  108181. reflectionStandardFresnelWeight: number;
  108182. protected _useRGBColor: boolean;
  108183. /**
  108184. * Helps to directly use the maps channels instead of their level.
  108185. */
  108186. useRGBColor: boolean;
  108187. protected _enableNoise: boolean;
  108188. /**
  108189. * This helps reducing the banding effect that could occur on the background.
  108190. */
  108191. enableNoise: boolean;
  108192. /**
  108193. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108194. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  108195. * Recommended to be keep at 1.0 except for special cases.
  108196. */
  108197. fovMultiplier: number;
  108198. private _fovMultiplier;
  108199. /**
  108200. * Enable the FOV adjustment feature controlled by fovMultiplier.
  108201. */
  108202. useEquirectangularFOV: boolean;
  108203. private _maxSimultaneousLights;
  108204. /**
  108205. * Number of Simultaneous lights allowed on the material.
  108206. */
  108207. maxSimultaneousLights: int;
  108208. /**
  108209. * Default configuration related to image processing available in the Background Material.
  108210. */
  108211. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108212. /**
  108213. * Keep track of the image processing observer to allow dispose and replace.
  108214. */
  108215. private _imageProcessingObserver;
  108216. /**
  108217. * Attaches a new image processing configuration to the PBR Material.
  108218. * @param configuration (if null the scene configuration will be use)
  108219. */
  108220. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108221. /**
  108222. * Gets the image processing configuration used either in this material.
  108223. */
  108224. /**
  108225. * Sets the Default image processing configuration used either in the this material.
  108226. *
  108227. * If sets to null, the scene one is in use.
  108228. */
  108229. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  108230. /**
  108231. * Gets wether the color curves effect is enabled.
  108232. */
  108233. /**
  108234. * Sets wether the color curves effect is enabled.
  108235. */
  108236. cameraColorCurvesEnabled: boolean;
  108237. /**
  108238. * Gets wether the color grading effect is enabled.
  108239. */
  108240. /**
  108241. * Gets wether the color grading effect is enabled.
  108242. */
  108243. cameraColorGradingEnabled: boolean;
  108244. /**
  108245. * Gets wether tonemapping is enabled or not.
  108246. */
  108247. /**
  108248. * Sets wether tonemapping is enabled or not
  108249. */
  108250. cameraToneMappingEnabled: boolean;
  108251. /**
  108252. * The camera exposure used on this material.
  108253. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108254. * This corresponds to a photographic exposure.
  108255. */
  108256. /**
  108257. * The camera exposure used on this material.
  108258. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108259. * This corresponds to a photographic exposure.
  108260. */
  108261. cameraExposure: float;
  108262. /**
  108263. * Gets The camera contrast used on this material.
  108264. */
  108265. /**
  108266. * Sets The camera contrast used on this material.
  108267. */
  108268. cameraContrast: float;
  108269. /**
  108270. * Gets the Color Grading 2D Lookup Texture.
  108271. */
  108272. /**
  108273. * Sets the Color Grading 2D Lookup Texture.
  108274. */
  108275. cameraColorGradingTexture: Nullable<BaseTexture>;
  108276. /**
  108277. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108278. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108279. * 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;
  108280. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108281. */
  108282. /**
  108283. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108284. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108285. * 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;
  108286. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108287. */
  108288. cameraColorCurves: Nullable<ColorCurves>;
  108289. /**
  108290. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  108291. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  108292. */
  108293. switchToBGR: boolean;
  108294. private _renderTargets;
  108295. private _reflectionControls;
  108296. private _white;
  108297. private _primaryShadowColor;
  108298. private _primaryHighlightColor;
  108299. /**
  108300. * Instantiates a Background Material in the given scene
  108301. * @param name The friendly name of the material
  108302. * @param scene The scene to add the material to
  108303. */
  108304. constructor(name: string, scene: Scene);
  108305. /**
  108306. * Gets a boolean indicating that current material needs to register RTT
  108307. */
  108308. readonly hasRenderTargetTextures: boolean;
  108309. /**
  108310. * The entire material has been created in order to prevent overdraw.
  108311. * @returns false
  108312. */
  108313. needAlphaTesting(): boolean;
  108314. /**
  108315. * The entire material has been created in order to prevent overdraw.
  108316. * @returns true if blending is enable
  108317. */
  108318. needAlphaBlending(): boolean;
  108319. /**
  108320. * Checks wether the material is ready to be rendered for a given mesh.
  108321. * @param mesh The mesh to render
  108322. * @param subMesh The submesh to check against
  108323. * @param useInstances Specify wether or not the material is used with instances
  108324. * @returns true if all the dependencies are ready (Textures, Effects...)
  108325. */
  108326. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108327. /**
  108328. * Compute the primary color according to the chosen perceptual color.
  108329. */
  108330. private _computePrimaryColorFromPerceptualColor;
  108331. /**
  108332. * Compute the highlights and shadow colors according to their chosen levels.
  108333. */
  108334. private _computePrimaryColors;
  108335. /**
  108336. * Build the uniform buffer used in the material.
  108337. */
  108338. buildUniformLayout(): void;
  108339. /**
  108340. * Unbind the material.
  108341. */
  108342. unbind(): void;
  108343. /**
  108344. * Bind only the world matrix to the material.
  108345. * @param world The world matrix to bind.
  108346. */
  108347. bindOnlyWorldMatrix(world: Matrix): void;
  108348. /**
  108349. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  108350. * @param world The world matrix to bind.
  108351. * @param subMesh The submesh to bind for.
  108352. */
  108353. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108354. /**
  108355. * Dispose the material.
  108356. * @param forceDisposeEffect Force disposal of the associated effect.
  108357. * @param forceDisposeTextures Force disposal of the associated textures.
  108358. */
  108359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108360. /**
  108361. * Clones the material.
  108362. * @param name The cloned name.
  108363. * @returns The cloned material.
  108364. */
  108365. clone(name: string): BackgroundMaterial;
  108366. /**
  108367. * Serializes the current material to its JSON representation.
  108368. * @returns The JSON representation.
  108369. */
  108370. serialize(): any;
  108371. /**
  108372. * Gets the class name of the material
  108373. * @returns "BackgroundMaterial"
  108374. */
  108375. getClassName(): string;
  108376. /**
  108377. * Parse a JSON input to create back a background material.
  108378. * @param source The JSON data to parse
  108379. * @param scene The scene to create the parsed material in
  108380. * @param rootUrl The root url of the assets the material depends upon
  108381. * @returns the instantiated BackgroundMaterial.
  108382. */
  108383. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * Represents the different options available during the creation of
  108389. * a Environment helper.
  108390. *
  108391. * This can control the default ground, skybox and image processing setup of your scene.
  108392. */
  108393. export interface IEnvironmentHelperOptions {
  108394. /**
  108395. * Specifies wether or not to create a ground.
  108396. * True by default.
  108397. */
  108398. createGround: boolean;
  108399. /**
  108400. * Specifies the ground size.
  108401. * 15 by default.
  108402. */
  108403. groundSize: number;
  108404. /**
  108405. * The texture used on the ground for the main color.
  108406. * Comes from the BabylonJS CDN by default.
  108407. *
  108408. * Remarks: Can be either a texture or a url.
  108409. */
  108410. groundTexture: string | BaseTexture;
  108411. /**
  108412. * The color mixed in the ground texture by default.
  108413. * BabylonJS clearColor by default.
  108414. */
  108415. groundColor: Color3;
  108416. /**
  108417. * Specifies the ground opacity.
  108418. * 1 by default.
  108419. */
  108420. groundOpacity: number;
  108421. /**
  108422. * Enables the ground to receive shadows.
  108423. * True by default.
  108424. */
  108425. enableGroundShadow: boolean;
  108426. /**
  108427. * Helps preventing the shadow to be fully black on the ground.
  108428. * 0.5 by default.
  108429. */
  108430. groundShadowLevel: number;
  108431. /**
  108432. * Creates a mirror texture attach to the ground.
  108433. * false by default.
  108434. */
  108435. enableGroundMirror: boolean;
  108436. /**
  108437. * Specifies the ground mirror size ratio.
  108438. * 0.3 by default as the default kernel is 64.
  108439. */
  108440. groundMirrorSizeRatio: number;
  108441. /**
  108442. * Specifies the ground mirror blur kernel size.
  108443. * 64 by default.
  108444. */
  108445. groundMirrorBlurKernel: number;
  108446. /**
  108447. * Specifies the ground mirror visibility amount.
  108448. * 1 by default
  108449. */
  108450. groundMirrorAmount: number;
  108451. /**
  108452. * Specifies the ground mirror reflectance weight.
  108453. * This uses the standard weight of the background material to setup the fresnel effect
  108454. * of the mirror.
  108455. * 1 by default.
  108456. */
  108457. groundMirrorFresnelWeight: number;
  108458. /**
  108459. * Specifies the ground mirror Falloff distance.
  108460. * This can helps reducing the size of the reflection.
  108461. * 0 by Default.
  108462. */
  108463. groundMirrorFallOffDistance: number;
  108464. /**
  108465. * Specifies the ground mirror texture type.
  108466. * Unsigned Int by Default.
  108467. */
  108468. groundMirrorTextureType: number;
  108469. /**
  108470. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  108471. * the shown objects.
  108472. */
  108473. groundYBias: number;
  108474. /**
  108475. * Specifies wether or not to create a skybox.
  108476. * True by default.
  108477. */
  108478. createSkybox: boolean;
  108479. /**
  108480. * Specifies the skybox size.
  108481. * 20 by default.
  108482. */
  108483. skyboxSize: number;
  108484. /**
  108485. * The texture used on the skybox for the main color.
  108486. * Comes from the BabylonJS CDN by default.
  108487. *
  108488. * Remarks: Can be either a texture or a url.
  108489. */
  108490. skyboxTexture: string | BaseTexture;
  108491. /**
  108492. * The color mixed in the skybox texture by default.
  108493. * BabylonJS clearColor by default.
  108494. */
  108495. skyboxColor: Color3;
  108496. /**
  108497. * The background rotation around the Y axis of the scene.
  108498. * This helps aligning the key lights of your scene with the background.
  108499. * 0 by default.
  108500. */
  108501. backgroundYRotation: number;
  108502. /**
  108503. * Compute automatically the size of the elements to best fit with the scene.
  108504. */
  108505. sizeAuto: boolean;
  108506. /**
  108507. * Default position of the rootMesh if autoSize is not true.
  108508. */
  108509. rootPosition: Vector3;
  108510. /**
  108511. * Sets up the image processing in the scene.
  108512. * true by default.
  108513. */
  108514. setupImageProcessing: boolean;
  108515. /**
  108516. * The texture used as your environment texture in the scene.
  108517. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  108518. *
  108519. * Remarks: Can be either a texture or a url.
  108520. */
  108521. environmentTexture: string | BaseTexture;
  108522. /**
  108523. * The value of the exposure to apply to the scene.
  108524. * 0.6 by default if setupImageProcessing is true.
  108525. */
  108526. cameraExposure: number;
  108527. /**
  108528. * The value of the contrast to apply to the scene.
  108529. * 1.6 by default if setupImageProcessing is true.
  108530. */
  108531. cameraContrast: number;
  108532. /**
  108533. * Specifies wether or not tonemapping should be enabled in the scene.
  108534. * true by default if setupImageProcessing is true.
  108535. */
  108536. toneMappingEnabled: boolean;
  108537. }
  108538. /**
  108539. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  108540. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  108541. * It also helps with the default setup of your imageProcessing configuration.
  108542. */
  108543. export class EnvironmentHelper {
  108544. /**
  108545. * Default ground texture URL.
  108546. */
  108547. private static _groundTextureCDNUrl;
  108548. /**
  108549. * Default skybox texture URL.
  108550. */
  108551. private static _skyboxTextureCDNUrl;
  108552. /**
  108553. * Default environment texture URL.
  108554. */
  108555. private static _environmentTextureCDNUrl;
  108556. /**
  108557. * Creates the default options for the helper.
  108558. */
  108559. private static _getDefaultOptions;
  108560. private _rootMesh;
  108561. /**
  108562. * Gets the root mesh created by the helper.
  108563. */
  108564. readonly rootMesh: Mesh;
  108565. private _skybox;
  108566. /**
  108567. * Gets the skybox created by the helper.
  108568. */
  108569. readonly skybox: Nullable<Mesh>;
  108570. private _skyboxTexture;
  108571. /**
  108572. * Gets the skybox texture created by the helper.
  108573. */
  108574. readonly skyboxTexture: Nullable<BaseTexture>;
  108575. private _skyboxMaterial;
  108576. /**
  108577. * Gets the skybox material created by the helper.
  108578. */
  108579. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  108580. private _ground;
  108581. /**
  108582. * Gets the ground mesh created by the helper.
  108583. */
  108584. readonly ground: Nullable<Mesh>;
  108585. private _groundTexture;
  108586. /**
  108587. * Gets the ground texture created by the helper.
  108588. */
  108589. readonly groundTexture: Nullable<BaseTexture>;
  108590. private _groundMirror;
  108591. /**
  108592. * Gets the ground mirror created by the helper.
  108593. */
  108594. readonly groundMirror: Nullable<MirrorTexture>;
  108595. /**
  108596. * Gets the ground mirror render list to helps pushing the meshes
  108597. * you wish in the ground reflection.
  108598. */
  108599. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  108600. private _groundMaterial;
  108601. /**
  108602. * Gets the ground material created by the helper.
  108603. */
  108604. readonly groundMaterial: Nullable<BackgroundMaterial>;
  108605. /**
  108606. * Stores the creation options.
  108607. */
  108608. private readonly _scene;
  108609. private _options;
  108610. /**
  108611. * This observable will be notified with any error during the creation of the environment,
  108612. * mainly texture creation errors.
  108613. */
  108614. onErrorObservable: Observable<{
  108615. message?: string;
  108616. exception?: any;
  108617. }>;
  108618. /**
  108619. * constructor
  108620. * @param options Defines the options we want to customize the helper
  108621. * @param scene The scene to add the material to
  108622. */
  108623. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  108624. /**
  108625. * Updates the background according to the new options
  108626. * @param options
  108627. */
  108628. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  108629. /**
  108630. * Sets the primary color of all the available elements.
  108631. * @param color the main color to affect to the ground and the background
  108632. */
  108633. setMainColor(color: Color3): void;
  108634. /**
  108635. * Setup the image processing according to the specified options.
  108636. */
  108637. private _setupImageProcessing;
  108638. /**
  108639. * Setup the environment texture according to the specified options.
  108640. */
  108641. private _setupEnvironmentTexture;
  108642. /**
  108643. * Setup the background according to the specified options.
  108644. */
  108645. private _setupBackground;
  108646. /**
  108647. * Get the scene sizes according to the setup.
  108648. */
  108649. private _getSceneSize;
  108650. /**
  108651. * Setup the ground according to the specified options.
  108652. */
  108653. private _setupGround;
  108654. /**
  108655. * Setup the ground material according to the specified options.
  108656. */
  108657. private _setupGroundMaterial;
  108658. /**
  108659. * Setup the ground diffuse texture according to the specified options.
  108660. */
  108661. private _setupGroundDiffuseTexture;
  108662. /**
  108663. * Setup the ground mirror texture according to the specified options.
  108664. */
  108665. private _setupGroundMirrorTexture;
  108666. /**
  108667. * Setup the ground to receive the mirror texture.
  108668. */
  108669. private _setupMirrorInGroundMaterial;
  108670. /**
  108671. * Setup the skybox according to the specified options.
  108672. */
  108673. private _setupSkybox;
  108674. /**
  108675. * Setup the skybox material according to the specified options.
  108676. */
  108677. private _setupSkyboxMaterial;
  108678. /**
  108679. * Setup the skybox reflection texture according to the specified options.
  108680. */
  108681. private _setupSkyboxReflectionTexture;
  108682. private _errorHandler;
  108683. /**
  108684. * Dispose all the elements created by the Helper.
  108685. */
  108686. dispose(): void;
  108687. }
  108688. }
  108689. declare module BABYLON {
  108690. /**
  108691. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  108692. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  108693. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  108694. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108695. */
  108696. export class PhotoDome extends TransformNode {
  108697. /**
  108698. * Define the image as a Monoscopic panoramic 360 image.
  108699. */
  108700. static readonly MODE_MONOSCOPIC: number;
  108701. /**
  108702. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108703. */
  108704. static readonly MODE_TOPBOTTOM: number;
  108705. /**
  108706. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108707. */
  108708. static readonly MODE_SIDEBYSIDE: number;
  108709. private _useDirectMapping;
  108710. /**
  108711. * The texture being displayed on the sphere
  108712. */
  108713. protected _photoTexture: Texture;
  108714. /**
  108715. * Gets or sets the texture being displayed on the sphere
  108716. */
  108717. photoTexture: Texture;
  108718. /**
  108719. * Observable raised when an error occured while loading the 360 image
  108720. */
  108721. onLoadErrorObservable: Observable<string>;
  108722. /**
  108723. * The skybox material
  108724. */
  108725. protected _material: BackgroundMaterial;
  108726. /**
  108727. * The surface used for the skybox
  108728. */
  108729. protected _mesh: Mesh;
  108730. /**
  108731. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108732. * Also see the options.resolution property.
  108733. */
  108734. fovMultiplier: number;
  108735. private _imageMode;
  108736. /**
  108737. * Gets or set the current video mode for the video. It can be:
  108738. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  108739. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  108740. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  108741. */
  108742. imageMode: number;
  108743. /**
  108744. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  108745. * @param name Element's name, child elements will append suffixes for their own names.
  108746. * @param urlsOfPhoto defines the url of the photo to display
  108747. * @param options defines an object containing optional or exposed sub element properties
  108748. * @param onError defines a callback called when an error occured while loading the texture
  108749. */
  108750. constructor(name: string, urlOfPhoto: string, options: {
  108751. resolution?: number;
  108752. size?: number;
  108753. useDirectMapping?: boolean;
  108754. faceForward?: boolean;
  108755. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  108756. private _onBeforeCameraRenderObserver;
  108757. private _changeImageMode;
  108758. /**
  108759. * Releases resources associated with this node.
  108760. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108761. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108762. */
  108763. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108764. }
  108765. }
  108766. declare module BABYLON {
  108767. /** @hidden */
  108768. export var rgbdDecodePixelShader: {
  108769. name: string;
  108770. shader: string;
  108771. };
  108772. }
  108773. declare module BABYLON {
  108774. /**
  108775. * Class used to host texture specific utilities
  108776. */
  108777. export class BRDFTextureTools {
  108778. /**
  108779. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  108780. * @param texture the texture to expand.
  108781. */
  108782. private static _ExpandDefaultBRDFTexture;
  108783. /**
  108784. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  108785. * @param scene defines the hosting scene
  108786. * @returns the environment BRDF texture
  108787. */
  108788. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  108789. private static _environmentBRDFBase64Texture;
  108790. }
  108791. }
  108792. declare module BABYLON {
  108793. /**
  108794. * @hidden
  108795. */
  108796. export interface IMaterialClearCoatDefines {
  108797. CLEARCOAT: boolean;
  108798. CLEARCOAT_DEFAULTIOR: boolean;
  108799. CLEARCOAT_TEXTURE: boolean;
  108800. CLEARCOAT_TEXTUREDIRECTUV: number;
  108801. CLEARCOAT_BUMP: boolean;
  108802. CLEARCOAT_BUMPDIRECTUV: number;
  108803. CLEARCOAT_TINT: boolean;
  108804. CLEARCOAT_TINT_TEXTURE: boolean;
  108805. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108806. /** @hidden */
  108807. _areTexturesDirty: boolean;
  108808. }
  108809. /**
  108810. * Define the code related to the clear coat parameters of the pbr material.
  108811. */
  108812. export class PBRClearCoatConfiguration {
  108813. /**
  108814. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108815. * The default fits with a polyurethane material.
  108816. */
  108817. private static readonly _DefaultIndexOfRefraction;
  108818. private _isEnabled;
  108819. /**
  108820. * Defines if the clear coat is enabled in the material.
  108821. */
  108822. isEnabled: boolean;
  108823. /**
  108824. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  108825. */
  108826. intensity: number;
  108827. /**
  108828. * Defines the clear coat layer roughness.
  108829. */
  108830. roughness: number;
  108831. private _indexOfRefraction;
  108832. /**
  108833. * Defines the index of refraction of the clear coat.
  108834. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  108835. * The default fits with a polyurethane material.
  108836. * Changing the default value is more performance intensive.
  108837. */
  108838. indexOfRefraction: number;
  108839. private _texture;
  108840. /**
  108841. * Stores the clear coat values in a texture.
  108842. */
  108843. texture: Nullable<BaseTexture>;
  108844. private _bumpTexture;
  108845. /**
  108846. * Define the clear coat specific bump texture.
  108847. */
  108848. bumpTexture: Nullable<BaseTexture>;
  108849. private _isTintEnabled;
  108850. /**
  108851. * Defines if the clear coat tint is enabled in the material.
  108852. */
  108853. isTintEnabled: boolean;
  108854. /**
  108855. * Defines the clear coat tint of the material.
  108856. * This is only use if tint is enabled
  108857. */
  108858. tintColor: Color3;
  108859. /**
  108860. * Defines the distance at which the tint color should be found in the
  108861. * clear coat media.
  108862. * This is only use if tint is enabled
  108863. */
  108864. tintColorAtDistance: number;
  108865. /**
  108866. * Defines the clear coat layer thickness.
  108867. * This is only use if tint is enabled
  108868. */
  108869. tintThickness: number;
  108870. private _tintTexture;
  108871. /**
  108872. * Stores the clear tint values in a texture.
  108873. * rgb is tint
  108874. * a is a thickness factor
  108875. */
  108876. tintTexture: Nullable<BaseTexture>;
  108877. /** @hidden */
  108878. private _internalMarkAllSubMeshesAsTexturesDirty;
  108879. /** @hidden */
  108880. _markAllSubMeshesAsTexturesDirty(): void;
  108881. /**
  108882. * Instantiate a new istance of clear coat configuration.
  108883. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  108884. */
  108885. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  108886. /**
  108887. * Gets wehter the submesh is ready to be used or not.
  108888. * @param defines the list of "defines" to update.
  108889. * @param scene defines the scene the material belongs to.
  108890. * @param engine defines the engine the material belongs to.
  108891. * @param disableBumpMap defines wether the material disables bump or not.
  108892. * @returns - boolean indicating that the submesh is ready or not.
  108893. */
  108894. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  108895. /**
  108896. * Checks to see if a texture is used in the material.
  108897. * @param defines the list of "defines" to update.
  108898. * @param scene defines the scene to the material belongs to.
  108899. */
  108900. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  108901. /**
  108902. * Binds the material data.
  108903. * @param uniformBuffer defines the Uniform buffer to fill in.
  108904. * @param scene defines the scene the material belongs to.
  108905. * @param engine defines the engine the material belongs to.
  108906. * @param disableBumpMap defines wether the material disables bump or not.
  108907. * @param isFrozen defines wether the material is frozen or not.
  108908. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108909. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108910. */
  108911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  108912. /**
  108913. * Checks to see if a texture is used in the material.
  108914. * @param texture - Base texture to use.
  108915. * @returns - Boolean specifying if a texture is used in the material.
  108916. */
  108917. hasTexture(texture: BaseTexture): boolean;
  108918. /**
  108919. * Returns an array of the actively used textures.
  108920. * @param activeTextures Array of BaseTextures
  108921. */
  108922. getActiveTextures(activeTextures: BaseTexture[]): void;
  108923. /**
  108924. * Returns the animatable textures.
  108925. * @param animatables Array of animatable textures.
  108926. */
  108927. getAnimatables(animatables: IAnimatable[]): void;
  108928. /**
  108929. * Disposes the resources of the material.
  108930. * @param forceDisposeTextures - Forces the disposal of all textures.
  108931. */
  108932. dispose(forceDisposeTextures?: boolean): void;
  108933. /**
  108934. * Get the current class name of the texture useful for serialization or dynamic coding.
  108935. * @returns "PBRClearCoatConfiguration"
  108936. */
  108937. getClassName(): string;
  108938. /**
  108939. * Add fallbacks to the effect fallbacks list.
  108940. * @param defines defines the Base texture to use.
  108941. * @param fallbacks defines the current fallback list.
  108942. * @param currentRank defines the current fallback rank.
  108943. * @returns the new fallback rank.
  108944. */
  108945. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  108946. /**
  108947. * Add the required uniforms to the current list.
  108948. * @param uniforms defines the current uniform list.
  108949. */
  108950. static AddUniforms(uniforms: string[]): void;
  108951. /**
  108952. * Add the required samplers to the current list.
  108953. * @param samplers defines the current sampler list.
  108954. */
  108955. static AddSamplers(samplers: string[]): void;
  108956. /**
  108957. * Add the required uniforms to the current buffer.
  108958. * @param uniformBuffer defines the current uniform buffer.
  108959. */
  108960. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  108961. /**
  108962. * Makes a duplicate of the current configuration into another one.
  108963. * @param clearCoatConfiguration define the config where to copy the info
  108964. */
  108965. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  108966. /**
  108967. * Serializes this clear coat configuration.
  108968. * @returns - An object with the serialized config.
  108969. */
  108970. serialize(): any;
  108971. /**
  108972. * Parses a anisotropy Configuration from a serialized object.
  108973. * @param source - Serialized object.
  108974. * @param scene Defines the scene we are parsing for
  108975. * @param rootUrl Defines the rootUrl to load from
  108976. */
  108977. parse(source: any, scene: Scene, rootUrl: string): void;
  108978. }
  108979. }
  108980. declare module BABYLON {
  108981. /**
  108982. * @hidden
  108983. */
  108984. export interface IMaterialAnisotropicDefines {
  108985. ANISOTROPIC: boolean;
  108986. ANISOTROPIC_TEXTURE: boolean;
  108987. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108988. MAINUV1: boolean;
  108989. _areTexturesDirty: boolean;
  108990. _needUVs: boolean;
  108991. }
  108992. /**
  108993. * Define the code related to the anisotropic parameters of the pbr material.
  108994. */
  108995. export class PBRAnisotropicConfiguration {
  108996. private _isEnabled;
  108997. /**
  108998. * Defines if the anisotropy is enabled in the material.
  108999. */
  109000. isEnabled: boolean;
  109001. /**
  109002. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  109003. */
  109004. intensity: number;
  109005. /**
  109006. * Defines if the effect is along the tangents, bitangents or in between.
  109007. * By default, the effect is "strectching" the highlights along the tangents.
  109008. */
  109009. direction: Vector2;
  109010. private _texture;
  109011. /**
  109012. * Stores the anisotropy values in a texture.
  109013. * rg is direction (like normal from -1 to 1)
  109014. * b is a intensity
  109015. */
  109016. texture: Nullable<BaseTexture>;
  109017. /** @hidden */
  109018. private _internalMarkAllSubMeshesAsTexturesDirty;
  109019. /** @hidden */
  109020. _markAllSubMeshesAsTexturesDirty(): void;
  109021. /**
  109022. * Instantiate a new istance of anisotropy configuration.
  109023. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109024. */
  109025. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109026. /**
  109027. * Specifies that the submesh is ready to be used.
  109028. * @param defines the list of "defines" to update.
  109029. * @param scene defines the scene the material belongs to.
  109030. * @returns - boolean indicating that the submesh is ready or not.
  109031. */
  109032. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  109033. /**
  109034. * Checks to see if a texture is used in the material.
  109035. * @param defines the list of "defines" to update.
  109036. * @param mesh the mesh we are preparing the defines for.
  109037. * @param scene defines the scene the material belongs to.
  109038. */
  109039. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  109040. /**
  109041. * Binds the material data.
  109042. * @param uniformBuffer defines the Uniform buffer to fill in.
  109043. * @param scene defines the scene the material belongs to.
  109044. * @param isFrozen defines wether the material is frozen or not.
  109045. */
  109046. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109047. /**
  109048. * Checks to see if a texture is used in the material.
  109049. * @param texture - Base texture to use.
  109050. * @returns - Boolean specifying if a texture is used in the material.
  109051. */
  109052. hasTexture(texture: BaseTexture): boolean;
  109053. /**
  109054. * Returns an array of the actively used textures.
  109055. * @param activeTextures Array of BaseTextures
  109056. */
  109057. getActiveTextures(activeTextures: BaseTexture[]): void;
  109058. /**
  109059. * Returns the animatable textures.
  109060. * @param animatables Array of animatable textures.
  109061. */
  109062. getAnimatables(animatables: IAnimatable[]): void;
  109063. /**
  109064. * Disposes the resources of the material.
  109065. * @param forceDisposeTextures - Forces the disposal of all textures.
  109066. */
  109067. dispose(forceDisposeTextures?: boolean): void;
  109068. /**
  109069. * Get the current class name of the texture useful for serialization or dynamic coding.
  109070. * @returns "PBRAnisotropicConfiguration"
  109071. */
  109072. getClassName(): string;
  109073. /**
  109074. * Add fallbacks to the effect fallbacks list.
  109075. * @param defines defines the Base texture to use.
  109076. * @param fallbacks defines the current fallback list.
  109077. * @param currentRank defines the current fallback rank.
  109078. * @returns the new fallback rank.
  109079. */
  109080. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109081. /**
  109082. * Add the required uniforms to the current list.
  109083. * @param uniforms defines the current uniform list.
  109084. */
  109085. static AddUniforms(uniforms: string[]): void;
  109086. /**
  109087. * Add the required uniforms to the current buffer.
  109088. * @param uniformBuffer defines the current uniform buffer.
  109089. */
  109090. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109091. /**
  109092. * Add the required samplers to the current list.
  109093. * @param samplers defines the current sampler list.
  109094. */
  109095. static AddSamplers(samplers: string[]): void;
  109096. /**
  109097. * Makes a duplicate of the current configuration into another one.
  109098. * @param anisotropicConfiguration define the config where to copy the info
  109099. */
  109100. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  109101. /**
  109102. * Serializes this anisotropy configuration.
  109103. * @returns - An object with the serialized config.
  109104. */
  109105. serialize(): any;
  109106. /**
  109107. * Parses a anisotropy Configuration from a serialized object.
  109108. * @param source - Serialized object.
  109109. * @param scene Defines the scene we are parsing for
  109110. * @param rootUrl Defines the rootUrl to load from
  109111. */
  109112. parse(source: any, scene: Scene, rootUrl: string): void;
  109113. }
  109114. }
  109115. declare module BABYLON {
  109116. /**
  109117. * @hidden
  109118. */
  109119. export interface IMaterialBRDFDefines {
  109120. BRDF_V_HEIGHT_CORRELATED: boolean;
  109121. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109122. SPHERICAL_HARMONICS: boolean;
  109123. /** @hidden */
  109124. _areMiscDirty: boolean;
  109125. }
  109126. /**
  109127. * Define the code related to the BRDF parameters of the pbr material.
  109128. */
  109129. export class PBRBRDFConfiguration {
  109130. /**
  109131. * Default value used for the energy conservation.
  109132. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109133. */
  109134. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  109135. /**
  109136. * Default value used for the Smith Visibility Height Correlated mode.
  109137. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  109138. */
  109139. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  109140. /**
  109141. * Default value used for the IBL diffuse part.
  109142. * This can help switching back to the polynomials mode globally which is a tiny bit
  109143. * less GPU intensive at the drawback of a lower quality.
  109144. */
  109145. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  109146. private _useEnergyConservation;
  109147. /**
  109148. * Defines if the material uses energy conservation.
  109149. */
  109150. useEnergyConservation: boolean;
  109151. private _useSmithVisibilityHeightCorrelated;
  109152. /**
  109153. * LEGACY Mode set to false
  109154. * Defines if the material uses height smith correlated visibility term.
  109155. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  109156. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  109157. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  109158. * Not relying on height correlated will also disable energy conservation.
  109159. */
  109160. useSmithVisibilityHeightCorrelated: boolean;
  109161. private _useSphericalHarmonics;
  109162. /**
  109163. * LEGACY Mode set to false
  109164. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  109165. * diffuse part of the IBL.
  109166. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  109167. * to the ground truth.
  109168. */
  109169. useSphericalHarmonics: boolean;
  109170. /** @hidden */
  109171. private _internalMarkAllSubMeshesAsMiscDirty;
  109172. /** @hidden */
  109173. _markAllSubMeshesAsMiscDirty(): void;
  109174. /**
  109175. * Instantiate a new istance of clear coat configuration.
  109176. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  109177. */
  109178. constructor(markAllSubMeshesAsMiscDirty: () => void);
  109179. /**
  109180. * Checks to see if a texture is used in the material.
  109181. * @param defines the list of "defines" to update.
  109182. */
  109183. prepareDefines(defines: IMaterialBRDFDefines): void;
  109184. /**
  109185. * Get the current class name of the texture useful for serialization or dynamic coding.
  109186. * @returns "PBRClearCoatConfiguration"
  109187. */
  109188. getClassName(): string;
  109189. /**
  109190. * Makes a duplicate of the current configuration into another one.
  109191. * @param brdfConfiguration define the config where to copy the info
  109192. */
  109193. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  109194. /**
  109195. * Serializes this BRDF configuration.
  109196. * @returns - An object with the serialized config.
  109197. */
  109198. serialize(): any;
  109199. /**
  109200. * Parses a anisotropy Configuration from a serialized object.
  109201. * @param source - Serialized object.
  109202. * @param scene Defines the scene we are parsing for
  109203. * @param rootUrl Defines the rootUrl to load from
  109204. */
  109205. parse(source: any, scene: Scene, rootUrl: string): void;
  109206. }
  109207. }
  109208. declare module BABYLON {
  109209. /**
  109210. * @hidden
  109211. */
  109212. export interface IMaterialSheenDefines {
  109213. SHEEN: boolean;
  109214. SHEEN_TEXTURE: boolean;
  109215. SHEEN_TEXTUREDIRECTUV: number;
  109216. SHEEN_LINKWITHALBEDO: boolean;
  109217. /** @hidden */
  109218. _areTexturesDirty: boolean;
  109219. }
  109220. /**
  109221. * Define the code related to the Sheen parameters of the pbr material.
  109222. */
  109223. export class PBRSheenConfiguration {
  109224. private _isEnabled;
  109225. /**
  109226. * Defines if the material uses sheen.
  109227. */
  109228. isEnabled: boolean;
  109229. private _linkSheenWithAlbedo;
  109230. /**
  109231. * Defines if the sheen is linked to the sheen color.
  109232. */
  109233. linkSheenWithAlbedo: boolean;
  109234. /**
  109235. * Defines the sheen intensity.
  109236. */
  109237. intensity: number;
  109238. /**
  109239. * Defines the sheen color.
  109240. */
  109241. color: Color3;
  109242. private _texture;
  109243. /**
  109244. * Stores the sheen tint values in a texture.
  109245. * rgb is tint
  109246. * a is a intensity
  109247. */
  109248. texture: Nullable<BaseTexture>;
  109249. /** @hidden */
  109250. private _internalMarkAllSubMeshesAsTexturesDirty;
  109251. /** @hidden */
  109252. _markAllSubMeshesAsTexturesDirty(): void;
  109253. /**
  109254. * Instantiate a new istance of clear coat configuration.
  109255. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109256. */
  109257. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109258. /**
  109259. * Specifies that the submesh is ready to be used.
  109260. * @param defines the list of "defines" to update.
  109261. * @param scene defines the scene the material belongs to.
  109262. * @returns - boolean indicating that the submesh is ready or not.
  109263. */
  109264. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  109265. /**
  109266. * Checks to see if a texture is used in the material.
  109267. * @param defines the list of "defines" to update.
  109268. * @param scene defines the scene the material belongs to.
  109269. */
  109270. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  109271. /**
  109272. * Binds the material data.
  109273. * @param uniformBuffer defines the Uniform buffer to fill in.
  109274. * @param scene defines the scene the material belongs to.
  109275. * @param isFrozen defines wether the material is frozen or not.
  109276. */
  109277. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  109278. /**
  109279. * Checks to see if a texture is used in the material.
  109280. * @param texture - Base texture to use.
  109281. * @returns - Boolean specifying if a texture is used in the material.
  109282. */
  109283. hasTexture(texture: BaseTexture): boolean;
  109284. /**
  109285. * Returns an array of the actively used textures.
  109286. * @param activeTextures Array of BaseTextures
  109287. */
  109288. getActiveTextures(activeTextures: BaseTexture[]): void;
  109289. /**
  109290. * Returns the animatable textures.
  109291. * @param animatables Array of animatable textures.
  109292. */
  109293. getAnimatables(animatables: IAnimatable[]): void;
  109294. /**
  109295. * Disposes the resources of the material.
  109296. * @param forceDisposeTextures - Forces the disposal of all textures.
  109297. */
  109298. dispose(forceDisposeTextures?: boolean): void;
  109299. /**
  109300. * Get the current class name of the texture useful for serialization or dynamic coding.
  109301. * @returns "PBRSheenConfiguration"
  109302. */
  109303. getClassName(): string;
  109304. /**
  109305. * Add fallbacks to the effect fallbacks list.
  109306. * @param defines defines the Base texture to use.
  109307. * @param fallbacks defines the current fallback list.
  109308. * @param currentRank defines the current fallback rank.
  109309. * @returns the new fallback rank.
  109310. */
  109311. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109312. /**
  109313. * Add the required uniforms to the current list.
  109314. * @param uniforms defines the current uniform list.
  109315. */
  109316. static AddUniforms(uniforms: string[]): void;
  109317. /**
  109318. * Add the required uniforms to the current buffer.
  109319. * @param uniformBuffer defines the current uniform buffer.
  109320. */
  109321. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109322. /**
  109323. * Add the required samplers to the current list.
  109324. * @param samplers defines the current sampler list.
  109325. */
  109326. static AddSamplers(samplers: string[]): void;
  109327. /**
  109328. * Makes a duplicate of the current configuration into another one.
  109329. * @param sheenConfiguration define the config where to copy the info
  109330. */
  109331. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  109332. /**
  109333. * Serializes this BRDF configuration.
  109334. * @returns - An object with the serialized config.
  109335. */
  109336. serialize(): any;
  109337. /**
  109338. * Parses a anisotropy Configuration from a serialized object.
  109339. * @param source - Serialized object.
  109340. * @param scene Defines the scene we are parsing for
  109341. * @param rootUrl Defines the rootUrl to load from
  109342. */
  109343. parse(source: any, scene: Scene, rootUrl: string): void;
  109344. }
  109345. }
  109346. declare module BABYLON {
  109347. /**
  109348. * @hidden
  109349. */
  109350. export interface IMaterialSubSurfaceDefines {
  109351. SUBSURFACE: boolean;
  109352. SS_REFRACTION: boolean;
  109353. SS_TRANSLUCENCY: boolean;
  109354. SS_SCATERRING: boolean;
  109355. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109356. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109357. SS_REFRACTIONMAP_3D: boolean;
  109358. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109359. SS_LODINREFRACTIONALPHA: boolean;
  109360. SS_GAMMAREFRACTION: boolean;
  109361. SS_RGBDREFRACTION: boolean;
  109362. SS_LINEARSPECULARREFRACTION: boolean;
  109363. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109364. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109365. /** @hidden */
  109366. _areTexturesDirty: boolean;
  109367. }
  109368. /**
  109369. * Define the code related to the sub surface parameters of the pbr material.
  109370. */
  109371. export class PBRSubSurfaceConfiguration {
  109372. private _isRefractionEnabled;
  109373. /**
  109374. * Defines if the refraction is enabled in the material.
  109375. */
  109376. isRefractionEnabled: boolean;
  109377. private _isTranslucencyEnabled;
  109378. /**
  109379. * Defines if the translucency is enabled in the material.
  109380. */
  109381. isTranslucencyEnabled: boolean;
  109382. private _isScatteringEnabled;
  109383. /**
  109384. * Defines the refraction intensity of the material.
  109385. * The refraction when enabled replaces the Diffuse part of the material.
  109386. * The intensity helps transitionning between diffuse and refraction.
  109387. */
  109388. refractionIntensity: number;
  109389. /**
  109390. * Defines the translucency intensity of the material.
  109391. * When translucency has been enabled, this defines how much of the "translucency"
  109392. * is addded to the diffuse part of the material.
  109393. */
  109394. translucencyIntensity: number;
  109395. /**
  109396. * Defines the scattering intensity of the material.
  109397. * When scattering has been enabled, this defines how much of the "scattered light"
  109398. * is addded to the diffuse part of the material.
  109399. */
  109400. scatteringIntensity: number;
  109401. private _thicknessTexture;
  109402. /**
  109403. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  109404. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  109405. * 0 would mean minimumThickness
  109406. * 1 would mean maximumThickness
  109407. * The other channels might be use as a mask to vary the different effects intensity.
  109408. */
  109409. thicknessTexture: Nullable<BaseTexture>;
  109410. private _refractionTexture;
  109411. /**
  109412. * Defines the texture to use for refraction.
  109413. */
  109414. refractionTexture: Nullable<BaseTexture>;
  109415. private _indexOfRefraction;
  109416. /**
  109417. * Defines the index of refraction used in the material.
  109418. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  109419. */
  109420. indexOfRefraction: number;
  109421. private _invertRefractionY;
  109422. /**
  109423. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  109424. */
  109425. invertRefractionY: boolean;
  109426. private _linkRefractionWithTransparency;
  109427. /**
  109428. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  109429. * Materials half opaque for instance using refraction could benefit from this control.
  109430. */
  109431. linkRefractionWithTransparency: boolean;
  109432. /**
  109433. * Defines the minimum thickness stored in the thickness map.
  109434. * If no thickness map is defined, this value will be used to simulate thickness.
  109435. */
  109436. minimumThickness: number;
  109437. /**
  109438. * Defines the maximum thickness stored in the thickness map.
  109439. */
  109440. maximumThickness: number;
  109441. /**
  109442. * Defines the volume tint of the material.
  109443. * This is used for both translucency and scattering.
  109444. */
  109445. tintColor: Color3;
  109446. /**
  109447. * Defines the distance at which the tint color should be found in the media.
  109448. * This is used for refraction only.
  109449. */
  109450. tintColorAtDistance: number;
  109451. /**
  109452. * Defines how far each channel transmit through the media.
  109453. * It is defined as a color to simplify it selection.
  109454. */
  109455. diffusionDistance: Color3;
  109456. private _useMaskFromThicknessTexture;
  109457. /**
  109458. * Stores the intensity of the different subsurface effects in the thickness texture.
  109459. * * the green channel is the translucency intensity.
  109460. * * the blue channel is the scattering intensity.
  109461. * * the alpha channel is the refraction intensity.
  109462. */
  109463. useMaskFromThicknessTexture: boolean;
  109464. /** @hidden */
  109465. private _internalMarkAllSubMeshesAsTexturesDirty;
  109466. /** @hidden */
  109467. _markAllSubMeshesAsTexturesDirty(): void;
  109468. /**
  109469. * Instantiate a new istance of sub surface configuration.
  109470. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  109471. */
  109472. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  109473. /**
  109474. * Gets wehter the submesh is ready to be used or not.
  109475. * @param defines the list of "defines" to update.
  109476. * @param scene defines the scene the material belongs to.
  109477. * @returns - boolean indicating that the submesh is ready or not.
  109478. */
  109479. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  109480. /**
  109481. * Checks to see if a texture is used in the material.
  109482. * @param defines the list of "defines" to update.
  109483. * @param scene defines the scene to the material belongs to.
  109484. */
  109485. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  109486. /**
  109487. * Binds the material data.
  109488. * @param uniformBuffer defines the Uniform buffer to fill in.
  109489. * @param scene defines the scene the material belongs to.
  109490. * @param engine defines the engine the material belongs to.
  109491. * @param isFrozen defines wether the material is frozen or not.
  109492. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  109493. */
  109494. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  109495. /**
  109496. * Unbinds the material from the mesh.
  109497. * @param activeEffect defines the effect that should be unbound from.
  109498. * @returns true if unbound, otherwise false
  109499. */
  109500. unbind(activeEffect: Effect): boolean;
  109501. /**
  109502. * Returns the texture used for refraction or null if none is used.
  109503. * @param scene defines the scene the material belongs to.
  109504. * @returns - Refraction texture if present. If no refraction texture and refraction
  109505. * is linked with transparency, returns environment texture. Otherwise, returns null.
  109506. */
  109507. private _getRefractionTexture;
  109508. /**
  109509. * Returns true if alpha blending should be disabled.
  109510. */
  109511. readonly disableAlphaBlending: boolean;
  109512. /**
  109513. * Fills the list of render target textures.
  109514. * @param renderTargets the list of render targets to update
  109515. */
  109516. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  109517. /**
  109518. * Checks to see if a texture is used in the material.
  109519. * @param texture - Base texture to use.
  109520. * @returns - Boolean specifying if a texture is used in the material.
  109521. */
  109522. hasTexture(texture: BaseTexture): boolean;
  109523. /**
  109524. * Gets a boolean indicating that current material needs to register RTT
  109525. * @returns true if this uses a render target otherwise false.
  109526. */
  109527. hasRenderTargetTextures(): boolean;
  109528. /**
  109529. * Returns an array of the actively used textures.
  109530. * @param activeTextures Array of BaseTextures
  109531. */
  109532. getActiveTextures(activeTextures: BaseTexture[]): void;
  109533. /**
  109534. * Returns the animatable textures.
  109535. * @param animatables Array of animatable textures.
  109536. */
  109537. getAnimatables(animatables: IAnimatable[]): void;
  109538. /**
  109539. * Disposes the resources of the material.
  109540. * @param forceDisposeTextures - Forces the disposal of all textures.
  109541. */
  109542. dispose(forceDisposeTextures?: boolean): void;
  109543. /**
  109544. * Get the current class name of the texture useful for serialization or dynamic coding.
  109545. * @returns "PBRSubSurfaceConfiguration"
  109546. */
  109547. getClassName(): string;
  109548. /**
  109549. * Add fallbacks to the effect fallbacks list.
  109550. * @param defines defines the Base texture to use.
  109551. * @param fallbacks defines the current fallback list.
  109552. * @param currentRank defines the current fallback rank.
  109553. * @returns the new fallback rank.
  109554. */
  109555. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  109556. /**
  109557. * Add the required uniforms to the current list.
  109558. * @param uniforms defines the current uniform list.
  109559. */
  109560. static AddUniforms(uniforms: string[]): void;
  109561. /**
  109562. * Add the required samplers to the current list.
  109563. * @param samplers defines the current sampler list.
  109564. */
  109565. static AddSamplers(samplers: string[]): void;
  109566. /**
  109567. * Add the required uniforms to the current buffer.
  109568. * @param uniformBuffer defines the current uniform buffer.
  109569. */
  109570. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  109571. /**
  109572. * Makes a duplicate of the current configuration into another one.
  109573. * @param configuration define the config where to copy the info
  109574. */
  109575. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  109576. /**
  109577. * Serializes this Sub Surface configuration.
  109578. * @returns - An object with the serialized config.
  109579. */
  109580. serialize(): any;
  109581. /**
  109582. * Parses a anisotropy Configuration from a serialized object.
  109583. * @param source - Serialized object.
  109584. * @param scene Defines the scene we are parsing for
  109585. * @param rootUrl Defines the rootUrl to load from
  109586. */
  109587. parse(source: any, scene: Scene, rootUrl: string): void;
  109588. }
  109589. }
  109590. declare module BABYLON {
  109591. /** @hidden */
  109592. export var pbrFragmentDeclaration: {
  109593. name: string;
  109594. shader: string;
  109595. };
  109596. }
  109597. declare module BABYLON {
  109598. /** @hidden */
  109599. export var pbrUboDeclaration: {
  109600. name: string;
  109601. shader: string;
  109602. };
  109603. }
  109604. declare module BABYLON {
  109605. /** @hidden */
  109606. export var pbrFragmentExtraDeclaration: {
  109607. name: string;
  109608. shader: string;
  109609. };
  109610. }
  109611. declare module BABYLON {
  109612. /** @hidden */
  109613. export var pbrFragmentSamplersDeclaration: {
  109614. name: string;
  109615. shader: string;
  109616. };
  109617. }
  109618. declare module BABYLON {
  109619. /** @hidden */
  109620. export var pbrHelperFunctions: {
  109621. name: string;
  109622. shader: string;
  109623. };
  109624. }
  109625. declare module BABYLON {
  109626. /** @hidden */
  109627. export var harmonicsFunctions: {
  109628. name: string;
  109629. shader: string;
  109630. };
  109631. }
  109632. declare module BABYLON {
  109633. /** @hidden */
  109634. export var pbrDirectLightingSetupFunctions: {
  109635. name: string;
  109636. shader: string;
  109637. };
  109638. }
  109639. declare module BABYLON {
  109640. /** @hidden */
  109641. export var pbrDirectLightingFalloffFunctions: {
  109642. name: string;
  109643. shader: string;
  109644. };
  109645. }
  109646. declare module BABYLON {
  109647. /** @hidden */
  109648. export var pbrBRDFFunctions: {
  109649. name: string;
  109650. shader: string;
  109651. };
  109652. }
  109653. declare module BABYLON {
  109654. /** @hidden */
  109655. export var pbrDirectLightingFunctions: {
  109656. name: string;
  109657. shader: string;
  109658. };
  109659. }
  109660. declare module BABYLON {
  109661. /** @hidden */
  109662. export var pbrIBLFunctions: {
  109663. name: string;
  109664. shader: string;
  109665. };
  109666. }
  109667. declare module BABYLON {
  109668. /** @hidden */
  109669. export var pbrDebug: {
  109670. name: string;
  109671. shader: string;
  109672. };
  109673. }
  109674. declare module BABYLON {
  109675. /** @hidden */
  109676. export var pbrPixelShader: {
  109677. name: string;
  109678. shader: string;
  109679. };
  109680. }
  109681. declare module BABYLON {
  109682. /** @hidden */
  109683. export var pbrVertexDeclaration: {
  109684. name: string;
  109685. shader: string;
  109686. };
  109687. }
  109688. declare module BABYLON {
  109689. /** @hidden */
  109690. export var pbrVertexShader: {
  109691. name: string;
  109692. shader: string;
  109693. };
  109694. }
  109695. declare module BABYLON {
  109696. /**
  109697. * Manages the defines for the PBR Material.
  109698. * @hidden
  109699. */
  109700. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  109701. PBR: boolean;
  109702. MAINUV1: boolean;
  109703. MAINUV2: boolean;
  109704. UV1: boolean;
  109705. UV2: boolean;
  109706. ALBEDO: boolean;
  109707. ALBEDODIRECTUV: number;
  109708. VERTEXCOLOR: boolean;
  109709. AMBIENT: boolean;
  109710. AMBIENTDIRECTUV: number;
  109711. AMBIENTINGRAYSCALE: boolean;
  109712. OPACITY: boolean;
  109713. VERTEXALPHA: boolean;
  109714. OPACITYDIRECTUV: number;
  109715. OPACITYRGB: boolean;
  109716. ALPHATEST: boolean;
  109717. DEPTHPREPASS: boolean;
  109718. ALPHABLEND: boolean;
  109719. ALPHAFROMALBEDO: boolean;
  109720. ALPHATESTVALUE: string;
  109721. SPECULAROVERALPHA: boolean;
  109722. RADIANCEOVERALPHA: boolean;
  109723. ALPHAFRESNEL: boolean;
  109724. LINEARALPHAFRESNEL: boolean;
  109725. PREMULTIPLYALPHA: boolean;
  109726. EMISSIVE: boolean;
  109727. EMISSIVEDIRECTUV: number;
  109728. REFLECTIVITY: boolean;
  109729. REFLECTIVITYDIRECTUV: number;
  109730. SPECULARTERM: boolean;
  109731. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  109732. MICROSURFACEAUTOMATIC: boolean;
  109733. LODBASEDMICROSFURACE: boolean;
  109734. MICROSURFACEMAP: boolean;
  109735. MICROSURFACEMAPDIRECTUV: number;
  109736. METALLICWORKFLOW: boolean;
  109737. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  109738. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  109739. METALLNESSSTOREINMETALMAPBLUE: boolean;
  109740. AOSTOREINMETALMAPRED: boolean;
  109741. ENVIRONMENTBRDF: boolean;
  109742. ENVIRONMENTBRDF_RGBD: boolean;
  109743. NORMAL: boolean;
  109744. TANGENT: boolean;
  109745. BUMP: boolean;
  109746. BUMPDIRECTUV: number;
  109747. OBJECTSPACE_NORMALMAP: boolean;
  109748. PARALLAX: boolean;
  109749. PARALLAXOCCLUSION: boolean;
  109750. NORMALXYSCALE: boolean;
  109751. LIGHTMAP: boolean;
  109752. LIGHTMAPDIRECTUV: number;
  109753. USELIGHTMAPASSHADOWMAP: boolean;
  109754. GAMMALIGHTMAP: boolean;
  109755. REFLECTION: boolean;
  109756. REFLECTIONMAP_3D: boolean;
  109757. REFLECTIONMAP_SPHERICAL: boolean;
  109758. REFLECTIONMAP_PLANAR: boolean;
  109759. REFLECTIONMAP_CUBIC: boolean;
  109760. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  109761. REFLECTIONMAP_PROJECTION: boolean;
  109762. REFLECTIONMAP_SKYBOX: boolean;
  109763. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  109764. REFLECTIONMAP_EXPLICIT: boolean;
  109765. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  109766. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  109767. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  109768. INVERTCUBICMAP: boolean;
  109769. USESPHERICALFROMREFLECTIONMAP: boolean;
  109770. USEIRRADIANCEMAP: boolean;
  109771. SPHERICAL_HARMONICS: boolean;
  109772. USESPHERICALINVERTEX: boolean;
  109773. REFLECTIONMAP_OPPOSITEZ: boolean;
  109774. LODINREFLECTIONALPHA: boolean;
  109775. GAMMAREFLECTION: boolean;
  109776. RGBDREFLECTION: boolean;
  109777. LINEARSPECULARREFLECTION: boolean;
  109778. RADIANCEOCCLUSION: boolean;
  109779. HORIZONOCCLUSION: boolean;
  109780. INSTANCES: boolean;
  109781. NUM_BONE_INFLUENCERS: number;
  109782. BonesPerMesh: number;
  109783. BONETEXTURE: boolean;
  109784. NONUNIFORMSCALING: boolean;
  109785. MORPHTARGETS: boolean;
  109786. MORPHTARGETS_NORMAL: boolean;
  109787. MORPHTARGETS_TANGENT: boolean;
  109788. MORPHTARGETS_UV: boolean;
  109789. NUM_MORPH_INFLUENCERS: number;
  109790. IMAGEPROCESSING: boolean;
  109791. VIGNETTE: boolean;
  109792. VIGNETTEBLENDMODEMULTIPLY: boolean;
  109793. VIGNETTEBLENDMODEOPAQUE: boolean;
  109794. TONEMAPPING: boolean;
  109795. TONEMAPPING_ACES: boolean;
  109796. CONTRAST: boolean;
  109797. COLORCURVES: boolean;
  109798. COLORGRADING: boolean;
  109799. COLORGRADING3D: boolean;
  109800. SAMPLER3DGREENDEPTH: boolean;
  109801. SAMPLER3DBGRMAP: boolean;
  109802. IMAGEPROCESSINGPOSTPROCESS: boolean;
  109803. EXPOSURE: boolean;
  109804. MULTIVIEW: boolean;
  109805. USEPHYSICALLIGHTFALLOFF: boolean;
  109806. USEGLTFLIGHTFALLOFF: boolean;
  109807. TWOSIDEDLIGHTING: boolean;
  109808. SHADOWFLOAT: boolean;
  109809. CLIPPLANE: boolean;
  109810. CLIPPLANE2: boolean;
  109811. CLIPPLANE3: boolean;
  109812. CLIPPLANE4: boolean;
  109813. POINTSIZE: boolean;
  109814. FOG: boolean;
  109815. LOGARITHMICDEPTH: boolean;
  109816. FORCENORMALFORWARD: boolean;
  109817. SPECULARAA: boolean;
  109818. CLEARCOAT: boolean;
  109819. CLEARCOAT_DEFAULTIOR: boolean;
  109820. CLEARCOAT_TEXTURE: boolean;
  109821. CLEARCOAT_TEXTUREDIRECTUV: number;
  109822. CLEARCOAT_BUMP: boolean;
  109823. CLEARCOAT_BUMPDIRECTUV: number;
  109824. CLEARCOAT_TINT: boolean;
  109825. CLEARCOAT_TINT_TEXTURE: boolean;
  109826. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  109827. ANISOTROPIC: boolean;
  109828. ANISOTROPIC_TEXTURE: boolean;
  109829. ANISOTROPIC_TEXTUREDIRECTUV: number;
  109830. BRDF_V_HEIGHT_CORRELATED: boolean;
  109831. MS_BRDF_ENERGY_CONSERVATION: boolean;
  109832. SHEEN: boolean;
  109833. SHEEN_TEXTURE: boolean;
  109834. SHEEN_TEXTUREDIRECTUV: number;
  109835. SHEEN_LINKWITHALBEDO: boolean;
  109836. SUBSURFACE: boolean;
  109837. SS_REFRACTION: boolean;
  109838. SS_TRANSLUCENCY: boolean;
  109839. SS_SCATERRING: boolean;
  109840. SS_THICKNESSANDMASK_TEXTURE: boolean;
  109841. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  109842. SS_REFRACTIONMAP_3D: boolean;
  109843. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  109844. SS_LODINREFRACTIONALPHA: boolean;
  109845. SS_GAMMAREFRACTION: boolean;
  109846. SS_RGBDREFRACTION: boolean;
  109847. SS_LINEARSPECULARREFRACTION: boolean;
  109848. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  109849. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  109850. UNLIT: boolean;
  109851. DEBUGMODE: number;
  109852. /**
  109853. * Initializes the PBR Material defines.
  109854. */
  109855. constructor();
  109856. /**
  109857. * Resets the PBR Material defines.
  109858. */
  109859. reset(): void;
  109860. }
  109861. /**
  109862. * The Physically based material base class of BJS.
  109863. *
  109864. * This offers the main features of a standard PBR material.
  109865. * For more information, please refer to the documentation :
  109866. * https://doc.babylonjs.com/how_to/physically_based_rendering
  109867. */
  109868. export abstract class PBRBaseMaterial extends PushMaterial {
  109869. /**
  109870. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  109871. */
  109872. static readonly PBRMATERIAL_OPAQUE: number;
  109873. /**
  109874. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  109875. */
  109876. static readonly PBRMATERIAL_ALPHATEST: number;
  109877. /**
  109878. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109879. */
  109880. static readonly PBRMATERIAL_ALPHABLEND: number;
  109881. /**
  109882. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  109883. * They are also discarded below the alpha cutoff threshold to improve performances.
  109884. */
  109885. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  109886. /**
  109887. * Defines the default value of how much AO map is occluding the analytical lights
  109888. * (point spot...).
  109889. */
  109890. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  109891. /**
  109892. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  109893. */
  109894. static readonly LIGHTFALLOFF_PHYSICAL: number;
  109895. /**
  109896. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  109897. * to enhance interoperability with other engines.
  109898. */
  109899. static readonly LIGHTFALLOFF_GLTF: number;
  109900. /**
  109901. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  109902. * to enhance interoperability with other materials.
  109903. */
  109904. static readonly LIGHTFALLOFF_STANDARD: number;
  109905. /**
  109906. * Intensity of the direct lights e.g. the four lights available in your scene.
  109907. * This impacts both the direct diffuse and specular highlights.
  109908. */
  109909. protected _directIntensity: number;
  109910. /**
  109911. * Intensity of the emissive part of the material.
  109912. * This helps controlling the emissive effect without modifying the emissive color.
  109913. */
  109914. protected _emissiveIntensity: number;
  109915. /**
  109916. * Intensity of the environment e.g. how much the environment will light the object
  109917. * either through harmonics for rough material or through the refelction for shiny ones.
  109918. */
  109919. protected _environmentIntensity: number;
  109920. /**
  109921. * This is a special control allowing the reduction of the specular highlights coming from the
  109922. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  109923. */
  109924. protected _specularIntensity: number;
  109925. /**
  109926. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  109927. */
  109928. private _lightingInfos;
  109929. /**
  109930. * Debug Control allowing disabling the bump map on this material.
  109931. */
  109932. protected _disableBumpMap: boolean;
  109933. /**
  109934. * AKA Diffuse Texture in standard nomenclature.
  109935. */
  109936. protected _albedoTexture: Nullable<BaseTexture>;
  109937. /**
  109938. * AKA Occlusion Texture in other nomenclature.
  109939. */
  109940. protected _ambientTexture: Nullable<BaseTexture>;
  109941. /**
  109942. * AKA Occlusion Texture Intensity in other nomenclature.
  109943. */
  109944. protected _ambientTextureStrength: number;
  109945. /**
  109946. * Defines how much the AO map is occluding the analytical lights (point spot...).
  109947. * 1 means it completely occludes it
  109948. * 0 mean it has no impact
  109949. */
  109950. protected _ambientTextureImpactOnAnalyticalLights: number;
  109951. /**
  109952. * Stores the alpha values in a texture.
  109953. */
  109954. protected _opacityTexture: Nullable<BaseTexture>;
  109955. /**
  109956. * Stores the reflection values in a texture.
  109957. */
  109958. protected _reflectionTexture: Nullable<BaseTexture>;
  109959. /**
  109960. * Stores the emissive values in a texture.
  109961. */
  109962. protected _emissiveTexture: Nullable<BaseTexture>;
  109963. /**
  109964. * AKA Specular texture in other nomenclature.
  109965. */
  109966. protected _reflectivityTexture: Nullable<BaseTexture>;
  109967. /**
  109968. * Used to switch from specular/glossiness to metallic/roughness workflow.
  109969. */
  109970. protected _metallicTexture: Nullable<BaseTexture>;
  109971. /**
  109972. * Specifies the metallic scalar of the metallic/roughness workflow.
  109973. * Can also be used to scale the metalness values of the metallic texture.
  109974. */
  109975. protected _metallic: Nullable<number>;
  109976. /**
  109977. * Specifies the roughness scalar of the metallic/roughness workflow.
  109978. * Can also be used to scale the roughness values of the metallic texture.
  109979. */
  109980. protected _roughness: Nullable<number>;
  109981. /**
  109982. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  109983. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  109984. */
  109985. protected _microSurfaceTexture: Nullable<BaseTexture>;
  109986. /**
  109987. * Stores surface normal data used to displace a mesh in a texture.
  109988. */
  109989. protected _bumpTexture: Nullable<BaseTexture>;
  109990. /**
  109991. * Stores the pre-calculated light information of a mesh in a texture.
  109992. */
  109993. protected _lightmapTexture: Nullable<BaseTexture>;
  109994. /**
  109995. * The color of a material in ambient lighting.
  109996. */
  109997. protected _ambientColor: Color3;
  109998. /**
  109999. * AKA Diffuse Color in other nomenclature.
  110000. */
  110001. protected _albedoColor: Color3;
  110002. /**
  110003. * AKA Specular Color in other nomenclature.
  110004. */
  110005. protected _reflectivityColor: Color3;
  110006. /**
  110007. * The color applied when light is reflected from a material.
  110008. */
  110009. protected _reflectionColor: Color3;
  110010. /**
  110011. * The color applied when light is emitted from a material.
  110012. */
  110013. protected _emissiveColor: Color3;
  110014. /**
  110015. * AKA Glossiness in other nomenclature.
  110016. */
  110017. protected _microSurface: number;
  110018. /**
  110019. * Specifies that the material will use the light map as a show map.
  110020. */
  110021. protected _useLightmapAsShadowmap: boolean;
  110022. /**
  110023. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110024. * makes the reflect vector face the model (under horizon).
  110025. */
  110026. protected _useHorizonOcclusion: boolean;
  110027. /**
  110028. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110029. * too much the area relying on ambient texture to define their ambient occlusion.
  110030. */
  110031. protected _useRadianceOcclusion: boolean;
  110032. /**
  110033. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110034. */
  110035. protected _useAlphaFromAlbedoTexture: boolean;
  110036. /**
  110037. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  110038. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110039. */
  110040. protected _useSpecularOverAlpha: boolean;
  110041. /**
  110042. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110043. */
  110044. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110045. /**
  110046. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110047. */
  110048. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  110049. /**
  110050. * Specifies if the metallic texture contains the roughness information in its green channel.
  110051. */
  110052. protected _useRoughnessFromMetallicTextureGreen: boolean;
  110053. /**
  110054. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110055. */
  110056. protected _useMetallnessFromMetallicTextureBlue: boolean;
  110057. /**
  110058. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110059. */
  110060. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  110061. /**
  110062. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110063. */
  110064. protected _useAmbientInGrayScale: boolean;
  110065. /**
  110066. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110067. * The material will try to infer what glossiness each pixel should be.
  110068. */
  110069. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  110070. /**
  110071. * Defines the falloff type used in this material.
  110072. * It by default is Physical.
  110073. */
  110074. protected _lightFalloff: number;
  110075. /**
  110076. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110077. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110078. */
  110079. protected _useRadianceOverAlpha: boolean;
  110080. /**
  110081. * Allows using an object space normal map (instead of tangent space).
  110082. */
  110083. protected _useObjectSpaceNormalMap: boolean;
  110084. /**
  110085. * Allows using the bump map in parallax mode.
  110086. */
  110087. protected _useParallax: boolean;
  110088. /**
  110089. * Allows using the bump map in parallax occlusion mode.
  110090. */
  110091. protected _useParallaxOcclusion: boolean;
  110092. /**
  110093. * Controls the scale bias of the parallax mode.
  110094. */
  110095. protected _parallaxScaleBias: number;
  110096. /**
  110097. * If sets to true, disables all the lights affecting the material.
  110098. */
  110099. protected _disableLighting: boolean;
  110100. /**
  110101. * Number of Simultaneous lights allowed on the material.
  110102. */
  110103. protected _maxSimultaneousLights: number;
  110104. /**
  110105. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  110106. */
  110107. protected _invertNormalMapX: boolean;
  110108. /**
  110109. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  110110. */
  110111. protected _invertNormalMapY: boolean;
  110112. /**
  110113. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110114. */
  110115. protected _twoSidedLighting: boolean;
  110116. /**
  110117. * Defines the alpha limits in alpha test mode.
  110118. */
  110119. protected _alphaCutOff: number;
  110120. /**
  110121. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110122. */
  110123. protected _forceAlphaTest: boolean;
  110124. /**
  110125. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110126. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110127. */
  110128. protected _useAlphaFresnel: boolean;
  110129. /**
  110130. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110131. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110132. */
  110133. protected _useLinearAlphaFresnel: boolean;
  110134. /**
  110135. * The transparency mode of the material.
  110136. */
  110137. protected _transparencyMode: Nullable<number>;
  110138. /**
  110139. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  110140. * from cos thetav and roughness:
  110141. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  110142. */
  110143. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  110144. /**
  110145. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110146. */
  110147. protected _forceIrradianceInFragment: boolean;
  110148. /**
  110149. * Force normal to face away from face.
  110150. */
  110151. protected _forceNormalForward: boolean;
  110152. /**
  110153. * Enables specular anti aliasing in the PBR shader.
  110154. * It will both interacts on the Geometry for analytical and IBL lighting.
  110155. * It also prefilter the roughness map based on the bump values.
  110156. */
  110157. protected _enableSpecularAntiAliasing: boolean;
  110158. /**
  110159. * Default configuration related to image processing available in the PBR Material.
  110160. */
  110161. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  110162. /**
  110163. * Keep track of the image processing observer to allow dispose and replace.
  110164. */
  110165. private _imageProcessingObserver;
  110166. /**
  110167. * Attaches a new image processing configuration to the PBR Material.
  110168. * @param configuration
  110169. */
  110170. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  110171. /**
  110172. * Stores the available render targets.
  110173. */
  110174. private _renderTargets;
  110175. /**
  110176. * Sets the global ambient color for the material used in lighting calculations.
  110177. */
  110178. private _globalAmbientColor;
  110179. /**
  110180. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  110181. */
  110182. private _useLogarithmicDepth;
  110183. /**
  110184. * If set to true, no lighting calculations will be applied.
  110185. */
  110186. private _unlit;
  110187. private _debugMode;
  110188. /**
  110189. * @hidden
  110190. * This is reserved for the inspector.
  110191. * Defines the material debug mode.
  110192. * It helps seeing only some components of the material while troubleshooting.
  110193. */
  110194. debugMode: number;
  110195. /**
  110196. * @hidden
  110197. * This is reserved for the inspector.
  110198. * Specify from where on screen the debug mode should start.
  110199. * The value goes from -1 (full screen) to 1 (not visible)
  110200. * It helps with side by side comparison against the final render
  110201. * This defaults to -1
  110202. */
  110203. private debugLimit;
  110204. /**
  110205. * @hidden
  110206. * This is reserved for the inspector.
  110207. * As the default viewing range might not be enough (if the ambient is really small for instance)
  110208. * You can use the factor to better multiply the final value.
  110209. */
  110210. private debugFactor;
  110211. /**
  110212. * Defines the clear coat layer parameters for the material.
  110213. */
  110214. readonly clearCoat: PBRClearCoatConfiguration;
  110215. /**
  110216. * Defines the anisotropic parameters for the material.
  110217. */
  110218. readonly anisotropy: PBRAnisotropicConfiguration;
  110219. /**
  110220. * Defines the BRDF parameters for the material.
  110221. */
  110222. readonly brdf: PBRBRDFConfiguration;
  110223. /**
  110224. * Defines the Sheen parameters for the material.
  110225. */
  110226. readonly sheen: PBRSheenConfiguration;
  110227. /**
  110228. * Defines the SubSurface parameters for the material.
  110229. */
  110230. readonly subSurface: PBRSubSurfaceConfiguration;
  110231. /**
  110232. * Custom callback helping to override the default shader used in the material.
  110233. */
  110234. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  110235. /**
  110236. * Instantiates a new PBRMaterial instance.
  110237. *
  110238. * @param name The material name
  110239. * @param scene The scene the material will be use in.
  110240. */
  110241. constructor(name: string, scene: Scene);
  110242. /**
  110243. * Gets a boolean indicating that current material needs to register RTT
  110244. */
  110245. readonly hasRenderTargetTextures: boolean;
  110246. /**
  110247. * Gets the name of the material class.
  110248. */
  110249. getClassName(): string;
  110250. /**
  110251. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110252. */
  110253. /**
  110254. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  110255. */
  110256. useLogarithmicDepth: boolean;
  110257. /**
  110258. * Gets the current transparency mode.
  110259. */
  110260. /**
  110261. * Sets the transparency mode of the material.
  110262. *
  110263. * | Value | Type | Description |
  110264. * | ----- | ----------------------------------- | ----------- |
  110265. * | 0 | OPAQUE | |
  110266. * | 1 | ALPHATEST | |
  110267. * | 2 | ALPHABLEND | |
  110268. * | 3 | ALPHATESTANDBLEND | |
  110269. *
  110270. */
  110271. transparencyMode: Nullable<number>;
  110272. /**
  110273. * Returns true if alpha blending should be disabled.
  110274. */
  110275. private readonly _disableAlphaBlending;
  110276. /**
  110277. * Specifies whether or not this material should be rendered in alpha blend mode.
  110278. */
  110279. needAlphaBlending(): boolean;
  110280. /**
  110281. * Specifies if the mesh will require alpha blending.
  110282. * @param mesh - BJS mesh.
  110283. */
  110284. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110285. /**
  110286. * Specifies whether or not this material should be rendered in alpha test mode.
  110287. */
  110288. needAlphaTesting(): boolean;
  110289. /**
  110290. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  110291. */
  110292. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  110293. /**
  110294. * Gets the texture used for the alpha test.
  110295. */
  110296. getAlphaTestTexture(): Nullable<BaseTexture>;
  110297. /**
  110298. * Specifies that the submesh is ready to be used.
  110299. * @param mesh - BJS mesh.
  110300. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  110301. * @param useInstances - Specifies that instances should be used.
  110302. * @returns - boolean indicating that the submesh is ready or not.
  110303. */
  110304. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110305. /**
  110306. * Specifies if the material uses metallic roughness workflow.
  110307. * @returns boolean specifiying if the material uses metallic roughness workflow.
  110308. */
  110309. isMetallicWorkflow(): boolean;
  110310. private _prepareEffect;
  110311. private _prepareDefines;
  110312. /**
  110313. * Force shader compilation
  110314. */
  110315. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  110316. clipPlane: boolean;
  110317. }>): void;
  110318. /**
  110319. * Initializes the uniform buffer layout for the shader.
  110320. */
  110321. buildUniformLayout(): void;
  110322. /**
  110323. * Unbinds the material from the mesh
  110324. */
  110325. unbind(): void;
  110326. /**
  110327. * Binds the submesh data.
  110328. * @param world - The world matrix.
  110329. * @param mesh - The BJS mesh.
  110330. * @param subMesh - A submesh of the BJS mesh.
  110331. */
  110332. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110333. /**
  110334. * Returns the animatable textures.
  110335. * @returns - Array of animatable textures.
  110336. */
  110337. getAnimatables(): IAnimatable[];
  110338. /**
  110339. * Returns the texture used for reflections.
  110340. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  110341. */
  110342. private _getReflectionTexture;
  110343. /**
  110344. * Returns an array of the actively used textures.
  110345. * @returns - Array of BaseTextures
  110346. */
  110347. getActiveTextures(): BaseTexture[];
  110348. /**
  110349. * Checks to see if a texture is used in the material.
  110350. * @param texture - Base texture to use.
  110351. * @returns - Boolean specifying if a texture is used in the material.
  110352. */
  110353. hasTexture(texture: BaseTexture): boolean;
  110354. /**
  110355. * Disposes the resources of the material.
  110356. * @param forceDisposeEffect - Forces the disposal of effects.
  110357. * @param forceDisposeTextures - Forces the disposal of all textures.
  110358. */
  110359. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  110360. }
  110361. }
  110362. declare module BABYLON {
  110363. /**
  110364. * The Physically based material of BJS.
  110365. *
  110366. * This offers the main features of a standard PBR material.
  110367. * For more information, please refer to the documentation :
  110368. * https://doc.babylonjs.com/how_to/physically_based_rendering
  110369. */
  110370. export class PBRMaterial extends PBRBaseMaterial {
  110371. /**
  110372. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110373. */
  110374. static readonly PBRMATERIAL_OPAQUE: number;
  110375. /**
  110376. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110377. */
  110378. static readonly PBRMATERIAL_ALPHATEST: number;
  110379. /**
  110380. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110381. */
  110382. static readonly PBRMATERIAL_ALPHABLEND: number;
  110383. /**
  110384. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110385. * They are also discarded below the alpha cutoff threshold to improve performances.
  110386. */
  110387. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  110388. /**
  110389. * Defines the default value of how much AO map is occluding the analytical lights
  110390. * (point spot...).
  110391. */
  110392. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  110393. /**
  110394. * Intensity of the direct lights e.g. the four lights available in your scene.
  110395. * This impacts both the direct diffuse and specular highlights.
  110396. */
  110397. directIntensity: number;
  110398. /**
  110399. * Intensity of the emissive part of the material.
  110400. * This helps controlling the emissive effect without modifying the emissive color.
  110401. */
  110402. emissiveIntensity: number;
  110403. /**
  110404. * Intensity of the environment e.g. how much the environment will light the object
  110405. * either through harmonics for rough material or through the refelction for shiny ones.
  110406. */
  110407. environmentIntensity: number;
  110408. /**
  110409. * This is a special control allowing the reduction of the specular highlights coming from the
  110410. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  110411. */
  110412. specularIntensity: number;
  110413. /**
  110414. * Debug Control allowing disabling the bump map on this material.
  110415. */
  110416. disableBumpMap: boolean;
  110417. /**
  110418. * AKA Diffuse Texture in standard nomenclature.
  110419. */
  110420. albedoTexture: BaseTexture;
  110421. /**
  110422. * AKA Occlusion Texture in other nomenclature.
  110423. */
  110424. ambientTexture: BaseTexture;
  110425. /**
  110426. * AKA Occlusion Texture Intensity in other nomenclature.
  110427. */
  110428. ambientTextureStrength: number;
  110429. /**
  110430. * Defines how much the AO map is occluding the analytical lights (point spot...).
  110431. * 1 means it completely occludes it
  110432. * 0 mean it has no impact
  110433. */
  110434. ambientTextureImpactOnAnalyticalLights: number;
  110435. /**
  110436. * Stores the alpha values in a texture.
  110437. */
  110438. opacityTexture: BaseTexture;
  110439. /**
  110440. * Stores the reflection values in a texture.
  110441. */
  110442. reflectionTexture: Nullable<BaseTexture>;
  110443. /**
  110444. * Stores the emissive values in a texture.
  110445. */
  110446. emissiveTexture: BaseTexture;
  110447. /**
  110448. * AKA Specular texture in other nomenclature.
  110449. */
  110450. reflectivityTexture: BaseTexture;
  110451. /**
  110452. * Used to switch from specular/glossiness to metallic/roughness workflow.
  110453. */
  110454. metallicTexture: BaseTexture;
  110455. /**
  110456. * Specifies the metallic scalar of the metallic/roughness workflow.
  110457. * Can also be used to scale the metalness values of the metallic texture.
  110458. */
  110459. metallic: Nullable<number>;
  110460. /**
  110461. * Specifies the roughness scalar of the metallic/roughness workflow.
  110462. * Can also be used to scale the roughness values of the metallic texture.
  110463. */
  110464. roughness: Nullable<number>;
  110465. /**
  110466. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  110467. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  110468. */
  110469. microSurfaceTexture: BaseTexture;
  110470. /**
  110471. * Stores surface normal data used to displace a mesh in a texture.
  110472. */
  110473. bumpTexture: BaseTexture;
  110474. /**
  110475. * Stores the pre-calculated light information of a mesh in a texture.
  110476. */
  110477. lightmapTexture: BaseTexture;
  110478. /**
  110479. * Stores the refracted light information in a texture.
  110480. */
  110481. refractionTexture: Nullable<BaseTexture>;
  110482. /**
  110483. * The color of a material in ambient lighting.
  110484. */
  110485. ambientColor: Color3;
  110486. /**
  110487. * AKA Diffuse Color in other nomenclature.
  110488. */
  110489. albedoColor: Color3;
  110490. /**
  110491. * AKA Specular Color in other nomenclature.
  110492. */
  110493. reflectivityColor: Color3;
  110494. /**
  110495. * The color reflected from the material.
  110496. */
  110497. reflectionColor: Color3;
  110498. /**
  110499. * The color emitted from the material.
  110500. */
  110501. emissiveColor: Color3;
  110502. /**
  110503. * AKA Glossiness in other nomenclature.
  110504. */
  110505. microSurface: number;
  110506. /**
  110507. * source material index of refraction (IOR)' / 'destination material IOR.
  110508. */
  110509. indexOfRefraction: number;
  110510. /**
  110511. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  110512. */
  110513. invertRefractionY: boolean;
  110514. /**
  110515. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  110516. * Materials half opaque for instance using refraction could benefit from this control.
  110517. */
  110518. linkRefractionWithTransparency: boolean;
  110519. /**
  110520. * If true, the light map contains occlusion information instead of lighting info.
  110521. */
  110522. useLightmapAsShadowmap: boolean;
  110523. /**
  110524. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  110525. */
  110526. useAlphaFromAlbedoTexture: boolean;
  110527. /**
  110528. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110529. */
  110530. forceAlphaTest: boolean;
  110531. /**
  110532. * Defines the alpha limits in alpha test mode.
  110533. */
  110534. alphaCutOff: number;
  110535. /**
  110536. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110537. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110538. */
  110539. useSpecularOverAlpha: boolean;
  110540. /**
  110541. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  110542. */
  110543. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  110544. /**
  110545. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  110546. */
  110547. useRoughnessFromMetallicTextureAlpha: boolean;
  110548. /**
  110549. * Specifies if the metallic texture contains the roughness information in its green channel.
  110550. */
  110551. useRoughnessFromMetallicTextureGreen: boolean;
  110552. /**
  110553. * Specifies if the metallic texture contains the metallness information in its blue channel.
  110554. */
  110555. useMetallnessFromMetallicTextureBlue: boolean;
  110556. /**
  110557. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  110558. */
  110559. useAmbientOcclusionFromMetallicTextureRed: boolean;
  110560. /**
  110561. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  110562. */
  110563. useAmbientInGrayScale: boolean;
  110564. /**
  110565. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  110566. * The material will try to infer what glossiness each pixel should be.
  110567. */
  110568. useAutoMicroSurfaceFromReflectivityMap: boolean;
  110569. /**
  110570. * BJS is using an harcoded light falloff based on a manually sets up range.
  110571. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110572. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110573. */
  110574. /**
  110575. * BJS is using an harcoded light falloff based on a manually sets up range.
  110576. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  110577. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  110578. */
  110579. usePhysicalLightFalloff: boolean;
  110580. /**
  110581. * In order to support the falloff compatibility with gltf, a special mode has been added
  110582. * to reproduce the gltf light falloff.
  110583. */
  110584. /**
  110585. * In order to support the falloff compatibility with gltf, a special mode has been added
  110586. * to reproduce the gltf light falloff.
  110587. */
  110588. useGLTFLightFalloff: boolean;
  110589. /**
  110590. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110591. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110592. */
  110593. useRadianceOverAlpha: boolean;
  110594. /**
  110595. * Allows using an object space normal map (instead of tangent space).
  110596. */
  110597. useObjectSpaceNormalMap: boolean;
  110598. /**
  110599. * Allows using the bump map in parallax mode.
  110600. */
  110601. useParallax: boolean;
  110602. /**
  110603. * Allows using the bump map in parallax occlusion mode.
  110604. */
  110605. useParallaxOcclusion: boolean;
  110606. /**
  110607. * Controls the scale bias of the parallax mode.
  110608. */
  110609. parallaxScaleBias: number;
  110610. /**
  110611. * If sets to true, disables all the lights affecting the material.
  110612. */
  110613. disableLighting: boolean;
  110614. /**
  110615. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  110616. */
  110617. forceIrradianceInFragment: boolean;
  110618. /**
  110619. * Number of Simultaneous lights allowed on the material.
  110620. */
  110621. maxSimultaneousLights: number;
  110622. /**
  110623. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  110624. */
  110625. invertNormalMapX: boolean;
  110626. /**
  110627. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  110628. */
  110629. invertNormalMapY: boolean;
  110630. /**
  110631. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  110632. */
  110633. twoSidedLighting: boolean;
  110634. /**
  110635. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110636. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  110637. */
  110638. useAlphaFresnel: boolean;
  110639. /**
  110640. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  110641. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  110642. */
  110643. useLinearAlphaFresnel: boolean;
  110644. /**
  110645. * Let user defines the brdf lookup texture used for IBL.
  110646. * A default 8bit version is embedded but you could point at :
  110647. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  110648. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  110649. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  110650. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  110651. */
  110652. environmentBRDFTexture: Nullable<BaseTexture>;
  110653. /**
  110654. * Force normal to face away from face.
  110655. */
  110656. forceNormalForward: boolean;
  110657. /**
  110658. * Enables specular anti aliasing in the PBR shader.
  110659. * It will both interacts on the Geometry for analytical and IBL lighting.
  110660. * It also prefilter the roughness map based on the bump values.
  110661. */
  110662. enableSpecularAntiAliasing: boolean;
  110663. /**
  110664. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  110665. * makes the reflect vector face the model (under horizon).
  110666. */
  110667. useHorizonOcclusion: boolean;
  110668. /**
  110669. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  110670. * too much the area relying on ambient texture to define their ambient occlusion.
  110671. */
  110672. useRadianceOcclusion: boolean;
  110673. /**
  110674. * If set to true, no lighting calculations will be applied.
  110675. */
  110676. unlit: boolean;
  110677. /**
  110678. * Gets the image processing configuration used either in this material.
  110679. */
  110680. /**
  110681. * Sets the Default image processing configuration used either in the this material.
  110682. *
  110683. * If sets to null, the scene one is in use.
  110684. */
  110685. imageProcessingConfiguration: ImageProcessingConfiguration;
  110686. /**
  110687. * Gets wether the color curves effect is enabled.
  110688. */
  110689. /**
  110690. * Sets wether the color curves effect is enabled.
  110691. */
  110692. cameraColorCurvesEnabled: boolean;
  110693. /**
  110694. * Gets wether the color grading effect is enabled.
  110695. */
  110696. /**
  110697. * Gets wether the color grading effect is enabled.
  110698. */
  110699. cameraColorGradingEnabled: boolean;
  110700. /**
  110701. * Gets wether tonemapping is enabled or not.
  110702. */
  110703. /**
  110704. * Sets wether tonemapping is enabled or not
  110705. */
  110706. cameraToneMappingEnabled: boolean;
  110707. /**
  110708. * The camera exposure used on this material.
  110709. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110710. * This corresponds to a photographic exposure.
  110711. */
  110712. /**
  110713. * The camera exposure used on this material.
  110714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  110715. * This corresponds to a photographic exposure.
  110716. */
  110717. cameraExposure: number;
  110718. /**
  110719. * Gets The camera contrast used on this material.
  110720. */
  110721. /**
  110722. * Sets The camera contrast used on this material.
  110723. */
  110724. cameraContrast: number;
  110725. /**
  110726. * Gets the Color Grading 2D Lookup Texture.
  110727. */
  110728. /**
  110729. * Sets the Color Grading 2D Lookup Texture.
  110730. */
  110731. cameraColorGradingTexture: Nullable<BaseTexture>;
  110732. /**
  110733. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110734. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110735. * 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;
  110736. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110737. */
  110738. /**
  110739. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  110740. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  110741. * 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;
  110742. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  110743. */
  110744. cameraColorCurves: Nullable<ColorCurves>;
  110745. /**
  110746. * Instantiates a new PBRMaterial instance.
  110747. *
  110748. * @param name The material name
  110749. * @param scene The scene the material will be use in.
  110750. */
  110751. constructor(name: string, scene: Scene);
  110752. /**
  110753. * Returns the name of this material class.
  110754. */
  110755. getClassName(): string;
  110756. /**
  110757. * Makes a duplicate of the current material.
  110758. * @param name - name to use for the new material.
  110759. */
  110760. clone(name: string): PBRMaterial;
  110761. /**
  110762. * Serializes this PBR Material.
  110763. * @returns - An object with the serialized material.
  110764. */
  110765. serialize(): any;
  110766. /**
  110767. * Parses a PBR Material from a serialized object.
  110768. * @param source - Serialized object.
  110769. * @param scene - BJS scene instance.
  110770. * @param rootUrl - url for the scene object
  110771. * @returns - PBRMaterial
  110772. */
  110773. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  110774. }
  110775. }
  110776. declare module BABYLON {
  110777. /**
  110778. * Direct draw surface info
  110779. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  110780. */
  110781. export interface DDSInfo {
  110782. /**
  110783. * Width of the texture
  110784. */
  110785. width: number;
  110786. /**
  110787. * Width of the texture
  110788. */
  110789. height: number;
  110790. /**
  110791. * Number of Mipmaps for the texture
  110792. * @see https://en.wikipedia.org/wiki/Mipmap
  110793. */
  110794. mipmapCount: number;
  110795. /**
  110796. * If the textures format is a known fourCC format
  110797. * @see https://www.fourcc.org/
  110798. */
  110799. isFourCC: boolean;
  110800. /**
  110801. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  110802. */
  110803. isRGB: boolean;
  110804. /**
  110805. * If the texture is a lumincance format
  110806. */
  110807. isLuminance: boolean;
  110808. /**
  110809. * If this is a cube texture
  110810. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  110811. */
  110812. isCube: boolean;
  110813. /**
  110814. * If the texture is a compressed format eg. FOURCC_DXT1
  110815. */
  110816. isCompressed: boolean;
  110817. /**
  110818. * The dxgiFormat of the texture
  110819. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  110820. */
  110821. dxgiFormat: number;
  110822. /**
  110823. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  110824. */
  110825. textureType: number;
  110826. /**
  110827. * Sphericle polynomial created for the dds texture
  110828. */
  110829. sphericalPolynomial?: SphericalPolynomial;
  110830. }
  110831. /**
  110832. * Class used to provide DDS decompression tools
  110833. */
  110834. export class DDSTools {
  110835. /**
  110836. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  110837. */
  110838. static StoreLODInAlphaChannel: boolean;
  110839. /**
  110840. * Gets DDS information from an array buffer
  110841. * @param arrayBuffer defines the array buffer to read data from
  110842. * @returns the DDS information
  110843. */
  110844. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  110845. private static _FloatView;
  110846. private static _Int32View;
  110847. private static _ToHalfFloat;
  110848. private static _FromHalfFloat;
  110849. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  110850. private static _GetHalfFloatRGBAArrayBuffer;
  110851. private static _GetFloatRGBAArrayBuffer;
  110852. private static _GetFloatAsUIntRGBAArrayBuffer;
  110853. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  110854. private static _GetRGBAArrayBuffer;
  110855. private static _ExtractLongWordOrder;
  110856. private static _GetRGBArrayBuffer;
  110857. private static _GetLuminanceArrayBuffer;
  110858. /**
  110859. * Uploads DDS Levels to a Babylon Texture
  110860. * @hidden
  110861. */
  110862. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  110863. }
  110864. interface Engine {
  110865. /**
  110866. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  110867. * @param rootUrl defines the url where the file to load is located
  110868. * @param scene defines the current scene
  110869. * @param lodScale defines scale to apply to the mip map selection
  110870. * @param lodOffset defines offset to apply to the mip map selection
  110871. * @param onLoad defines an optional callback raised when the texture is loaded
  110872. * @param onError defines an optional callback raised if there is an issue to load the texture
  110873. * @param format defines the format of the data
  110874. * @param forcedExtension defines the extension to use to pick the right loader
  110875. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  110876. * @returns the cube texture as an InternalTexture
  110877. */
  110878. 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;
  110879. }
  110880. }
  110881. declare module BABYLON {
  110882. /**
  110883. * Implementation of the DDS Texture Loader.
  110884. * @hidden
  110885. */
  110886. export class _DDSTextureLoader implements IInternalTextureLoader {
  110887. /**
  110888. * Defines wether the loader supports cascade loading the different faces.
  110889. */
  110890. readonly supportCascades: boolean;
  110891. /**
  110892. * This returns if the loader support the current file information.
  110893. * @param extension defines the file extension of the file being loaded
  110894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110895. * @param fallback defines the fallback internal texture if any
  110896. * @param isBase64 defines whether the texture is encoded as a base64
  110897. * @param isBuffer defines whether the texture data are stored as a buffer
  110898. * @returns true if the loader can load the specified file
  110899. */
  110900. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  110901. /**
  110902. * Transform the url before loading if required.
  110903. * @param rootUrl the url of the texture
  110904. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110905. * @returns the transformed texture
  110906. */
  110907. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  110908. /**
  110909. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  110910. * @param rootUrl the url of the texture
  110911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  110912. * @returns the fallback texture
  110913. */
  110914. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  110915. /**
  110916. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  110917. * @param data contains the texture data
  110918. * @param texture defines the BabylonJS internal texture
  110919. * @param createPolynomials will be true if polynomials have been requested
  110920. * @param onLoad defines the callback to trigger once the texture is ready
  110921. * @param onError defines the callback to trigger in case of error
  110922. */
  110923. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  110924. /**
  110925. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  110926. * @param data contains the texture data
  110927. * @param texture defines the BabylonJS internal texture
  110928. * @param callback defines the method to call once ready to upload
  110929. */
  110930. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  110931. }
  110932. }
  110933. declare module BABYLON {
  110934. /** @hidden */
  110935. export var rgbdEncodePixelShader: {
  110936. name: string;
  110937. shader: string;
  110938. };
  110939. }
  110940. declare module BABYLON {
  110941. /**
  110942. * Raw texture data and descriptor sufficient for WebGL texture upload
  110943. */
  110944. export interface EnvironmentTextureInfo {
  110945. /**
  110946. * Version of the environment map
  110947. */
  110948. version: number;
  110949. /**
  110950. * Width of image
  110951. */
  110952. width: number;
  110953. /**
  110954. * Irradiance information stored in the file.
  110955. */
  110956. irradiance: any;
  110957. /**
  110958. * Specular information stored in the file.
  110959. */
  110960. specular: any;
  110961. }
  110962. /**
  110963. * Sets of helpers addressing the serialization and deserialization of environment texture
  110964. * stored in a BabylonJS env file.
  110965. * Those files are usually stored as .env files.
  110966. */
  110967. export class EnvironmentTextureTools {
  110968. /**
  110969. * Magic number identifying the env file.
  110970. */
  110971. private static _MagicBytes;
  110972. /**
  110973. * Gets the environment info from an env file.
  110974. * @param data The array buffer containing the .env bytes.
  110975. * @returns the environment file info (the json header) if successfully parsed.
  110976. */
  110977. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  110978. /**
  110979. * Creates an environment texture from a loaded cube texture.
  110980. * @param texture defines the cube texture to convert in env file
  110981. * @return a promise containing the environment data if succesfull.
  110982. */
  110983. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  110984. /**
  110985. * Creates a JSON representation of the spherical data.
  110986. * @param texture defines the texture containing the polynomials
  110987. * @return the JSON representation of the spherical info
  110988. */
  110989. private static _CreateEnvTextureIrradiance;
  110990. /**
  110991. * Uploads the texture info contained in the env file to the GPU.
  110992. * @param texture defines the internal texture to upload to
  110993. * @param arrayBuffer defines the buffer cotaining the data to load
  110994. * @param info defines the texture info retrieved through the GetEnvInfo method
  110995. * @returns a promise
  110996. */
  110997. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  110998. /**
  110999. * Uploads the levels of image data to the GPU.
  111000. * @param texture defines the internal texture to upload to
  111001. * @param imageData defines the array buffer views of image data [mipmap][face]
  111002. * @returns a promise
  111003. */
  111004. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111005. /**
  111006. * Uploads spherical polynomials information to the texture.
  111007. * @param texture defines the texture we are trying to upload the information to
  111008. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111009. */
  111010. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111011. /** @hidden */
  111012. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111013. }
  111014. }
  111015. declare module BABYLON {
  111016. /**
  111017. * Implementation of the ENV Texture Loader.
  111018. * @hidden
  111019. */
  111020. export class _ENVTextureLoader implements IInternalTextureLoader {
  111021. /**
  111022. * Defines wether the loader supports cascade loading the different faces.
  111023. */
  111024. readonly supportCascades: boolean;
  111025. /**
  111026. * This returns if the loader support the current file information.
  111027. * @param extension defines the file extension of the file being loaded
  111028. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111029. * @param fallback defines the fallback internal texture if any
  111030. * @param isBase64 defines whether the texture is encoded as a base64
  111031. * @param isBuffer defines whether the texture data are stored as a buffer
  111032. * @returns true if the loader can load the specified file
  111033. */
  111034. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111035. /**
  111036. * Transform the url before loading if required.
  111037. * @param rootUrl the url of the texture
  111038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111039. * @returns the transformed texture
  111040. */
  111041. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111042. /**
  111043. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111044. * @param rootUrl the url of the texture
  111045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111046. * @returns the fallback texture
  111047. */
  111048. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111049. /**
  111050. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111051. * @param data contains the texture data
  111052. * @param texture defines the BabylonJS internal texture
  111053. * @param createPolynomials will be true if polynomials have been requested
  111054. * @param onLoad defines the callback to trigger once the texture is ready
  111055. * @param onError defines the callback to trigger in case of error
  111056. */
  111057. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111058. /**
  111059. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111060. * @param data contains the texture data
  111061. * @param texture defines the BabylonJS internal texture
  111062. * @param callback defines the method to call once ready to upload
  111063. */
  111064. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111065. }
  111066. }
  111067. declare module BABYLON {
  111068. /**
  111069. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  111070. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  111071. */
  111072. export class KhronosTextureContainer {
  111073. /** contents of the KTX container file */
  111074. arrayBuffer: any;
  111075. private static HEADER_LEN;
  111076. private static COMPRESSED_2D;
  111077. private static COMPRESSED_3D;
  111078. private static TEX_2D;
  111079. private static TEX_3D;
  111080. /**
  111081. * Gets the openGL type
  111082. */
  111083. glType: number;
  111084. /**
  111085. * Gets the openGL type size
  111086. */
  111087. glTypeSize: number;
  111088. /**
  111089. * Gets the openGL format
  111090. */
  111091. glFormat: number;
  111092. /**
  111093. * Gets the openGL internal format
  111094. */
  111095. glInternalFormat: number;
  111096. /**
  111097. * Gets the base internal format
  111098. */
  111099. glBaseInternalFormat: number;
  111100. /**
  111101. * Gets image width in pixel
  111102. */
  111103. pixelWidth: number;
  111104. /**
  111105. * Gets image height in pixel
  111106. */
  111107. pixelHeight: number;
  111108. /**
  111109. * Gets image depth in pixels
  111110. */
  111111. pixelDepth: number;
  111112. /**
  111113. * Gets the number of array elements
  111114. */
  111115. numberOfArrayElements: number;
  111116. /**
  111117. * Gets the number of faces
  111118. */
  111119. numberOfFaces: number;
  111120. /**
  111121. * Gets the number of mipmap levels
  111122. */
  111123. numberOfMipmapLevels: number;
  111124. /**
  111125. * Gets the bytes of key value data
  111126. */
  111127. bytesOfKeyValueData: number;
  111128. /**
  111129. * Gets the load type
  111130. */
  111131. loadType: number;
  111132. /**
  111133. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  111134. */
  111135. isInvalid: boolean;
  111136. /**
  111137. * Creates a new KhronosTextureContainer
  111138. * @param arrayBuffer contents of the KTX container file
  111139. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  111140. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  111141. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  111142. */
  111143. constructor(
  111144. /** contents of the KTX container file */
  111145. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  111146. /**
  111147. * Uploads KTX content to a Babylon Texture.
  111148. * It is assumed that the texture has already been created & is currently bound
  111149. * @hidden
  111150. */
  111151. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  111152. private _upload2DCompressedLevels;
  111153. }
  111154. }
  111155. declare module BABYLON {
  111156. /**
  111157. * Implementation of the KTX Texture Loader.
  111158. * @hidden
  111159. */
  111160. export class _KTXTextureLoader implements IInternalTextureLoader {
  111161. /**
  111162. * Defines wether the loader supports cascade loading the different faces.
  111163. */
  111164. readonly supportCascades: boolean;
  111165. /**
  111166. * This returns if the loader support the current file information.
  111167. * @param extension defines the file extension of the file being loaded
  111168. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111169. * @param fallback defines the fallback internal texture if any
  111170. * @param isBase64 defines whether the texture is encoded as a base64
  111171. * @param isBuffer defines whether the texture data are stored as a buffer
  111172. * @returns true if the loader can load the specified file
  111173. */
  111174. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111175. /**
  111176. * Transform the url before loading if required.
  111177. * @param rootUrl the url of the texture
  111178. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111179. * @returns the transformed texture
  111180. */
  111181. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111182. /**
  111183. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111184. * @param rootUrl the url of the texture
  111185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111186. * @returns the fallback texture
  111187. */
  111188. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111189. /**
  111190. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111191. * @param data contains the texture data
  111192. * @param texture defines the BabylonJS internal texture
  111193. * @param createPolynomials will be true if polynomials have been requested
  111194. * @param onLoad defines the callback to trigger once the texture is ready
  111195. * @param onError defines the callback to trigger in case of error
  111196. */
  111197. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111198. /**
  111199. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111200. * @param data contains the texture data
  111201. * @param texture defines the BabylonJS internal texture
  111202. * @param callback defines the method to call once ready to upload
  111203. */
  111204. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  111205. }
  111206. }
  111207. declare module BABYLON {
  111208. /**
  111209. * Options for the default xr helper
  111210. */
  111211. export class WebXRDefaultExperienceOptions {
  111212. /**
  111213. * Floor meshes that should be used for teleporting
  111214. */
  111215. floorMeshes: Array<AbstractMesh>;
  111216. }
  111217. /**
  111218. * Default experience which provides a similar setup to the previous webVRExperience
  111219. */
  111220. export class WebXRDefaultExperience {
  111221. /**
  111222. * Base experience
  111223. */
  111224. baseExperience: WebXRExperienceHelper;
  111225. /**
  111226. * Input experience extension
  111227. */
  111228. input: WebXRInput;
  111229. /**
  111230. * Loads the controller models
  111231. */
  111232. controllerModelLoader: WebXRControllerModelLoader;
  111233. /**
  111234. * Enables laser pointer and selection
  111235. */
  111236. pointerSelection: WebXRControllerPointerSelection;
  111237. /**
  111238. * Enables teleportation
  111239. */
  111240. teleportation: WebXRControllerTeleportation;
  111241. /**
  111242. * Enables ui for enetering/exiting xr
  111243. */
  111244. enterExitUI: WebXREnterExitUI;
  111245. /**
  111246. * Default output canvas xr should render to
  111247. */
  111248. outputCanvas: WebXRManagedOutputCanvas;
  111249. /**
  111250. * Creates the default xr experience
  111251. * @param scene scene
  111252. * @param options options for basic configuration
  111253. * @returns resulting WebXRDefaultExperience
  111254. */
  111255. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111256. private constructor();
  111257. /**
  111258. * DIsposes of the experience helper
  111259. */
  111260. dispose(): void;
  111261. }
  111262. }
  111263. declare module BABYLON {
  111264. /** @hidden */
  111265. export var _forceSceneHelpersToBundle: boolean;
  111266. interface Scene {
  111267. /**
  111268. * Creates a default light for the scene.
  111269. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  111270. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  111271. */
  111272. createDefaultLight(replace?: boolean): void;
  111273. /**
  111274. * Creates a default camera for the scene.
  111275. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  111276. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111277. * @param replace has default false, when true replaces the active camera in the scene
  111278. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  111279. */
  111280. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111281. /**
  111282. * Creates a default camera and a default light.
  111283. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  111284. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  111285. * @param replace has the default false, when true replaces the active camera/light in the scene
  111286. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  111287. */
  111288. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  111289. /**
  111290. * Creates a new sky box
  111291. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  111292. * @param environmentTexture defines the texture to use as environment texture
  111293. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  111294. * @param scale defines the overall scale of the skybox
  111295. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  111296. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  111297. * @returns a new mesh holding the sky box
  111298. */
  111299. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  111300. /**
  111301. * Creates a new environment
  111302. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  111303. * @param options defines the options you can use to configure the environment
  111304. * @returns the new EnvironmentHelper
  111305. */
  111306. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  111307. /**
  111308. * Creates a new VREXperienceHelper
  111309. * @see http://doc.babylonjs.com/how_to/webvr_helper
  111310. * @param webVROptions defines the options used to create the new VREXperienceHelper
  111311. * @returns a new VREXperienceHelper
  111312. */
  111313. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  111314. /**
  111315. * Creates a new WebXRDefaultExperience
  111316. * @see http://doc.babylonjs.com/how_to/webxr
  111317. * @param options experience options
  111318. * @returns a promise for a new WebXRDefaultExperience
  111319. */
  111320. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  111321. }
  111322. }
  111323. declare module BABYLON {
  111324. /**
  111325. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  111326. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  111327. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  111328. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  111329. */
  111330. export class VideoDome extends TransformNode {
  111331. /**
  111332. * Define the video source as a Monoscopic panoramic 360 video.
  111333. */
  111334. static readonly MODE_MONOSCOPIC: number;
  111335. /**
  111336. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111337. */
  111338. static readonly MODE_TOPBOTTOM: number;
  111339. /**
  111340. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111341. */
  111342. static readonly MODE_SIDEBYSIDE: number;
  111343. private _useDirectMapping;
  111344. /**
  111345. * The video texture being displayed on the sphere
  111346. */
  111347. protected _videoTexture: VideoTexture;
  111348. /**
  111349. * Gets the video texture being displayed on the sphere
  111350. */
  111351. readonly videoTexture: VideoTexture;
  111352. /**
  111353. * The skybox material
  111354. */
  111355. protected _material: BackgroundMaterial;
  111356. /**
  111357. * The surface used for the skybox
  111358. */
  111359. protected _mesh: Mesh;
  111360. /**
  111361. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  111362. * Also see the options.resolution property.
  111363. */
  111364. fovMultiplier: number;
  111365. private _videoMode;
  111366. /**
  111367. * Gets or set the current video mode for the video. It can be:
  111368. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  111369. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  111370. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  111371. */
  111372. videoMode: number;
  111373. /**
  111374. * Oberserver used in Stereoscopic VR Mode.
  111375. */
  111376. private _onBeforeCameraRenderObserver;
  111377. /**
  111378. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  111379. * @param name Element's name, child elements will append suffixes for their own names.
  111380. * @param urlsOrVideo defines the url(s) or the video element to use
  111381. * @param options An object containing optional or exposed sub element properties
  111382. */
  111383. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  111384. resolution?: number;
  111385. clickToPlay?: boolean;
  111386. autoPlay?: boolean;
  111387. loop?: boolean;
  111388. size?: number;
  111389. poster?: string;
  111390. faceForward?: boolean;
  111391. useDirectMapping?: boolean;
  111392. }, scene: Scene);
  111393. private _changeVideoMode;
  111394. /**
  111395. * Releases resources associated with this node.
  111396. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  111397. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  111398. */
  111399. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  111400. }
  111401. }
  111402. declare module BABYLON {
  111403. /**
  111404. * This class can be used to get instrumentation data from a Babylon engine
  111405. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111406. */
  111407. export class EngineInstrumentation implements IDisposable {
  111408. /**
  111409. * Define the instrumented engine.
  111410. */
  111411. engine: Engine;
  111412. private _captureGPUFrameTime;
  111413. private _gpuFrameTimeToken;
  111414. private _gpuFrameTime;
  111415. private _captureShaderCompilationTime;
  111416. private _shaderCompilationTime;
  111417. private _onBeginFrameObserver;
  111418. private _onEndFrameObserver;
  111419. private _onBeforeShaderCompilationObserver;
  111420. private _onAfterShaderCompilationObserver;
  111421. /**
  111422. * Gets the perf counter used for GPU frame time
  111423. */
  111424. readonly gpuFrameTimeCounter: PerfCounter;
  111425. /**
  111426. * Gets the GPU frame time capture status
  111427. */
  111428. /**
  111429. * Enable or disable the GPU frame time capture
  111430. */
  111431. captureGPUFrameTime: boolean;
  111432. /**
  111433. * Gets the perf counter used for shader compilation time
  111434. */
  111435. readonly shaderCompilationTimeCounter: PerfCounter;
  111436. /**
  111437. * Gets the shader compilation time capture status
  111438. */
  111439. /**
  111440. * Enable or disable the shader compilation time capture
  111441. */
  111442. captureShaderCompilationTime: boolean;
  111443. /**
  111444. * Instantiates a new engine instrumentation.
  111445. * This class can be used to get instrumentation data from a Babylon engine
  111446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  111447. * @param engine Defines the engine to instrument
  111448. */
  111449. constructor(
  111450. /**
  111451. * Define the instrumented engine.
  111452. */
  111453. engine: Engine);
  111454. /**
  111455. * Dispose and release associated resources.
  111456. */
  111457. dispose(): void;
  111458. }
  111459. }
  111460. declare module BABYLON {
  111461. /**
  111462. * This class can be used to get instrumentation data from a Babylon engine
  111463. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111464. */
  111465. export class SceneInstrumentation implements IDisposable {
  111466. /**
  111467. * Defines the scene to instrument
  111468. */
  111469. scene: Scene;
  111470. private _captureActiveMeshesEvaluationTime;
  111471. private _activeMeshesEvaluationTime;
  111472. private _captureRenderTargetsRenderTime;
  111473. private _renderTargetsRenderTime;
  111474. private _captureFrameTime;
  111475. private _frameTime;
  111476. private _captureRenderTime;
  111477. private _renderTime;
  111478. private _captureInterFrameTime;
  111479. private _interFrameTime;
  111480. private _captureParticlesRenderTime;
  111481. private _particlesRenderTime;
  111482. private _captureSpritesRenderTime;
  111483. private _spritesRenderTime;
  111484. private _capturePhysicsTime;
  111485. private _physicsTime;
  111486. private _captureAnimationsTime;
  111487. private _animationsTime;
  111488. private _captureCameraRenderTime;
  111489. private _cameraRenderTime;
  111490. private _onBeforeActiveMeshesEvaluationObserver;
  111491. private _onAfterActiveMeshesEvaluationObserver;
  111492. private _onBeforeRenderTargetsRenderObserver;
  111493. private _onAfterRenderTargetsRenderObserver;
  111494. private _onAfterRenderObserver;
  111495. private _onBeforeDrawPhaseObserver;
  111496. private _onAfterDrawPhaseObserver;
  111497. private _onBeforeAnimationsObserver;
  111498. private _onBeforeParticlesRenderingObserver;
  111499. private _onAfterParticlesRenderingObserver;
  111500. private _onBeforeSpritesRenderingObserver;
  111501. private _onAfterSpritesRenderingObserver;
  111502. private _onBeforePhysicsObserver;
  111503. private _onAfterPhysicsObserver;
  111504. private _onAfterAnimationsObserver;
  111505. private _onBeforeCameraRenderObserver;
  111506. private _onAfterCameraRenderObserver;
  111507. /**
  111508. * Gets the perf counter used for active meshes evaluation time
  111509. */
  111510. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  111511. /**
  111512. * Gets the active meshes evaluation time capture status
  111513. */
  111514. /**
  111515. * Enable or disable the active meshes evaluation time capture
  111516. */
  111517. captureActiveMeshesEvaluationTime: boolean;
  111518. /**
  111519. * Gets the perf counter used for render targets render time
  111520. */
  111521. readonly renderTargetsRenderTimeCounter: PerfCounter;
  111522. /**
  111523. * Gets the render targets render time capture status
  111524. */
  111525. /**
  111526. * Enable or disable the render targets render time capture
  111527. */
  111528. captureRenderTargetsRenderTime: boolean;
  111529. /**
  111530. * Gets the perf counter used for particles render time
  111531. */
  111532. readonly particlesRenderTimeCounter: PerfCounter;
  111533. /**
  111534. * Gets the particles render time capture status
  111535. */
  111536. /**
  111537. * Enable or disable the particles render time capture
  111538. */
  111539. captureParticlesRenderTime: boolean;
  111540. /**
  111541. * Gets the perf counter used for sprites render time
  111542. */
  111543. readonly spritesRenderTimeCounter: PerfCounter;
  111544. /**
  111545. * Gets the sprites render time capture status
  111546. */
  111547. /**
  111548. * Enable or disable the sprites render time capture
  111549. */
  111550. captureSpritesRenderTime: boolean;
  111551. /**
  111552. * Gets the perf counter used for physics time
  111553. */
  111554. readonly physicsTimeCounter: PerfCounter;
  111555. /**
  111556. * Gets the physics time capture status
  111557. */
  111558. /**
  111559. * Enable or disable the physics time capture
  111560. */
  111561. capturePhysicsTime: boolean;
  111562. /**
  111563. * Gets the perf counter used for animations time
  111564. */
  111565. readonly animationsTimeCounter: PerfCounter;
  111566. /**
  111567. * Gets the animations time capture status
  111568. */
  111569. /**
  111570. * Enable or disable the animations time capture
  111571. */
  111572. captureAnimationsTime: boolean;
  111573. /**
  111574. * Gets the perf counter used for frame time capture
  111575. */
  111576. readonly frameTimeCounter: PerfCounter;
  111577. /**
  111578. * Gets the frame time capture status
  111579. */
  111580. /**
  111581. * Enable or disable the frame time capture
  111582. */
  111583. captureFrameTime: boolean;
  111584. /**
  111585. * Gets the perf counter used for inter-frames time capture
  111586. */
  111587. readonly interFrameTimeCounter: PerfCounter;
  111588. /**
  111589. * Gets the inter-frames time capture status
  111590. */
  111591. /**
  111592. * Enable or disable the inter-frames time capture
  111593. */
  111594. captureInterFrameTime: boolean;
  111595. /**
  111596. * Gets the perf counter used for render time capture
  111597. */
  111598. readonly renderTimeCounter: PerfCounter;
  111599. /**
  111600. * Gets the render time capture status
  111601. */
  111602. /**
  111603. * Enable or disable the render time capture
  111604. */
  111605. captureRenderTime: boolean;
  111606. /**
  111607. * Gets the perf counter used for camera render time capture
  111608. */
  111609. readonly cameraRenderTimeCounter: PerfCounter;
  111610. /**
  111611. * Gets the camera render time capture status
  111612. */
  111613. /**
  111614. * Enable or disable the camera render time capture
  111615. */
  111616. captureCameraRenderTime: boolean;
  111617. /**
  111618. * Gets the perf counter used for draw calls
  111619. */
  111620. readonly drawCallsCounter: PerfCounter;
  111621. /**
  111622. * Instantiates a new scene instrumentation.
  111623. * This class can be used to get instrumentation data from a Babylon engine
  111624. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  111625. * @param scene Defines the scene to instrument
  111626. */
  111627. constructor(
  111628. /**
  111629. * Defines the scene to instrument
  111630. */
  111631. scene: Scene);
  111632. /**
  111633. * Dispose and release associated resources.
  111634. */
  111635. dispose(): void;
  111636. }
  111637. }
  111638. declare module BABYLON {
  111639. /** @hidden */
  111640. export var glowMapGenerationPixelShader: {
  111641. name: string;
  111642. shader: string;
  111643. };
  111644. }
  111645. declare module BABYLON {
  111646. /** @hidden */
  111647. export var glowMapGenerationVertexShader: {
  111648. name: string;
  111649. shader: string;
  111650. };
  111651. }
  111652. declare module BABYLON {
  111653. /**
  111654. * Effect layer options. This helps customizing the behaviour
  111655. * of the effect layer.
  111656. */
  111657. export interface IEffectLayerOptions {
  111658. /**
  111659. * Multiplication factor apply to the canvas size to compute the render target size
  111660. * used to generated the objects (the smaller the faster).
  111661. */
  111662. mainTextureRatio: number;
  111663. /**
  111664. * Enforces a fixed size texture to ensure effect stability across devices.
  111665. */
  111666. mainTextureFixedSize?: number;
  111667. /**
  111668. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  111669. */
  111670. alphaBlendingMode: number;
  111671. /**
  111672. * The camera attached to the layer.
  111673. */
  111674. camera: Nullable<Camera>;
  111675. /**
  111676. * The rendering group to draw the layer in.
  111677. */
  111678. renderingGroupId: number;
  111679. }
  111680. /**
  111681. * The effect layer Helps adding post process effect blended with the main pass.
  111682. *
  111683. * This can be for instance use to generate glow or higlight effects on the scene.
  111684. *
  111685. * The effect layer class can not be used directly and is intented to inherited from to be
  111686. * customized per effects.
  111687. */
  111688. export abstract class EffectLayer {
  111689. private _vertexBuffers;
  111690. private _indexBuffer;
  111691. private _cachedDefines;
  111692. private _effectLayerMapGenerationEffect;
  111693. private _effectLayerOptions;
  111694. private _mergeEffect;
  111695. protected _scene: Scene;
  111696. protected _engine: Engine;
  111697. protected _maxSize: number;
  111698. protected _mainTextureDesiredSize: ISize;
  111699. protected _mainTexture: RenderTargetTexture;
  111700. protected _shouldRender: boolean;
  111701. protected _postProcesses: PostProcess[];
  111702. protected _textures: BaseTexture[];
  111703. protected _emissiveTextureAndColor: {
  111704. texture: Nullable<BaseTexture>;
  111705. color: Color4;
  111706. };
  111707. /**
  111708. * The name of the layer
  111709. */
  111710. name: string;
  111711. /**
  111712. * The clear color of the texture used to generate the glow map.
  111713. */
  111714. neutralColor: Color4;
  111715. /**
  111716. * Specifies wether the highlight layer is enabled or not.
  111717. */
  111718. isEnabled: boolean;
  111719. /**
  111720. * Gets the camera attached to the layer.
  111721. */
  111722. readonly camera: Nullable<Camera>;
  111723. /**
  111724. * Gets the rendering group id the layer should render in.
  111725. */
  111726. renderingGroupId: number;
  111727. /**
  111728. * An event triggered when the effect layer has been disposed.
  111729. */
  111730. onDisposeObservable: Observable<EffectLayer>;
  111731. /**
  111732. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  111733. */
  111734. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  111735. /**
  111736. * An event triggered when the generated texture is being merged in the scene.
  111737. */
  111738. onBeforeComposeObservable: Observable<EffectLayer>;
  111739. /**
  111740. * An event triggered when the generated texture has been merged in the scene.
  111741. */
  111742. onAfterComposeObservable: Observable<EffectLayer>;
  111743. /**
  111744. * An event triggered when the efffect layer changes its size.
  111745. */
  111746. onSizeChangedObservable: Observable<EffectLayer>;
  111747. /** @hidden */
  111748. static _SceneComponentInitialization: (scene: Scene) => void;
  111749. /**
  111750. * Instantiates a new effect Layer and references it in the scene.
  111751. * @param name The name of the layer
  111752. * @param scene The scene to use the layer in
  111753. */
  111754. constructor(
  111755. /** The Friendly of the effect in the scene */
  111756. name: string, scene: Scene);
  111757. /**
  111758. * Get the effect name of the layer.
  111759. * @return The effect name
  111760. */
  111761. abstract getEffectName(): string;
  111762. /**
  111763. * Checks for the readiness of the element composing the layer.
  111764. * @param subMesh the mesh to check for
  111765. * @param useInstances specify wether or not to use instances to render the mesh
  111766. * @return true if ready otherwise, false
  111767. */
  111768. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  111769. /**
  111770. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  111771. * @returns true if the effect requires stencil during the main canvas render pass.
  111772. */
  111773. abstract needStencil(): boolean;
  111774. /**
  111775. * Create the merge effect. This is the shader use to blit the information back
  111776. * to the main canvas at the end of the scene rendering.
  111777. * @returns The effect containing the shader used to merge the effect on the main canvas
  111778. */
  111779. protected abstract _createMergeEffect(): Effect;
  111780. /**
  111781. * Creates the render target textures and post processes used in the effect layer.
  111782. */
  111783. protected abstract _createTextureAndPostProcesses(): void;
  111784. /**
  111785. * Implementation specific of rendering the generating effect on the main canvas.
  111786. * @param effect The effect used to render through
  111787. */
  111788. protected abstract _internalRender(effect: Effect): void;
  111789. /**
  111790. * Sets the required values for both the emissive texture and and the main color.
  111791. */
  111792. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  111793. /**
  111794. * Free any resources and references associated to a mesh.
  111795. * Internal use
  111796. * @param mesh The mesh to free.
  111797. */
  111798. abstract _disposeMesh(mesh: Mesh): void;
  111799. /**
  111800. * Serializes this layer (Glow or Highlight for example)
  111801. * @returns a serialized layer object
  111802. */
  111803. abstract serialize?(): any;
  111804. /**
  111805. * Initializes the effect layer with the required options.
  111806. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  111807. */
  111808. protected _init(options: Partial<IEffectLayerOptions>): void;
  111809. /**
  111810. * Generates the index buffer of the full screen quad blending to the main canvas.
  111811. */
  111812. private _generateIndexBuffer;
  111813. /**
  111814. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  111815. */
  111816. private _generateVertexBuffer;
  111817. /**
  111818. * Sets the main texture desired size which is the closest power of two
  111819. * of the engine canvas size.
  111820. */
  111821. private _setMainTextureSize;
  111822. /**
  111823. * Creates the main texture for the effect layer.
  111824. */
  111825. protected _createMainTexture(): void;
  111826. /**
  111827. * Adds specific effects defines.
  111828. * @param defines The defines to add specifics to.
  111829. */
  111830. protected _addCustomEffectDefines(defines: string[]): void;
  111831. /**
  111832. * Checks for the readiness of the element composing the layer.
  111833. * @param subMesh the mesh to check for
  111834. * @param useInstances specify wether or not to use instances to render the mesh
  111835. * @param emissiveTexture the associated emissive texture used to generate the glow
  111836. * @return true if ready otherwise, false
  111837. */
  111838. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  111839. /**
  111840. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  111841. */
  111842. render(): void;
  111843. /**
  111844. * Determine if a given mesh will be used in the current effect.
  111845. * @param mesh mesh to test
  111846. * @returns true if the mesh will be used
  111847. */
  111848. hasMesh(mesh: AbstractMesh): boolean;
  111849. /**
  111850. * Returns true if the layer contains information to display, otherwise false.
  111851. * @returns true if the glow layer should be rendered
  111852. */
  111853. shouldRender(): boolean;
  111854. /**
  111855. * Returns true if the mesh should render, otherwise false.
  111856. * @param mesh The mesh to render
  111857. * @returns true if it should render otherwise false
  111858. */
  111859. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  111860. /**
  111861. * Returns true if the mesh can be rendered, otherwise false.
  111862. * @param mesh The mesh to render
  111863. * @param material The material used on the mesh
  111864. * @returns true if it can be rendered otherwise false
  111865. */
  111866. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  111867. /**
  111868. * Returns true if the mesh should render, otherwise false.
  111869. * @param mesh The mesh to render
  111870. * @returns true if it should render otherwise false
  111871. */
  111872. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  111873. /**
  111874. * Renders the submesh passed in parameter to the generation map.
  111875. */
  111876. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  111877. /**
  111878. * Rebuild the required buffers.
  111879. * @hidden Internal use only.
  111880. */
  111881. _rebuild(): void;
  111882. /**
  111883. * Dispose only the render target textures and post process.
  111884. */
  111885. private _disposeTextureAndPostProcesses;
  111886. /**
  111887. * Dispose the highlight layer and free resources.
  111888. */
  111889. dispose(): void;
  111890. /**
  111891. * Gets the class name of the effect layer
  111892. * @returns the string with the class name of the effect layer
  111893. */
  111894. getClassName(): string;
  111895. /**
  111896. * Creates an effect layer from parsed effect layer data
  111897. * @param parsedEffectLayer defines effect layer data
  111898. * @param scene defines the current scene
  111899. * @param rootUrl defines the root URL containing the effect layer information
  111900. * @returns a parsed effect Layer
  111901. */
  111902. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  111903. }
  111904. }
  111905. declare module BABYLON {
  111906. interface AbstractScene {
  111907. /**
  111908. * The list of effect layers (highlights/glow) added to the scene
  111909. * @see http://doc.babylonjs.com/how_to/highlight_layer
  111910. * @see http://doc.babylonjs.com/how_to/glow_layer
  111911. */
  111912. effectLayers: Array<EffectLayer>;
  111913. /**
  111914. * Removes the given effect layer from this scene.
  111915. * @param toRemove defines the effect layer to remove
  111916. * @returns the index of the removed effect layer
  111917. */
  111918. removeEffectLayer(toRemove: EffectLayer): number;
  111919. /**
  111920. * Adds the given effect layer to this scene
  111921. * @param newEffectLayer defines the effect layer to add
  111922. */
  111923. addEffectLayer(newEffectLayer: EffectLayer): void;
  111924. }
  111925. /**
  111926. * Defines the layer scene component responsible to manage any effect layers
  111927. * in a given scene.
  111928. */
  111929. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  111930. /**
  111931. * The component name helpfull to identify the component in the list of scene components.
  111932. */
  111933. readonly name: string;
  111934. /**
  111935. * The scene the component belongs to.
  111936. */
  111937. scene: Scene;
  111938. private _engine;
  111939. private _renderEffects;
  111940. private _needStencil;
  111941. private _previousStencilState;
  111942. /**
  111943. * Creates a new instance of the component for the given scene
  111944. * @param scene Defines the scene to register the component in
  111945. */
  111946. constructor(scene: Scene);
  111947. /**
  111948. * Registers the component in a given scene
  111949. */
  111950. register(): void;
  111951. /**
  111952. * Rebuilds the elements related to this component in case of
  111953. * context lost for instance.
  111954. */
  111955. rebuild(): void;
  111956. /**
  111957. * Serializes the component data to the specified json object
  111958. * @param serializationObject The object to serialize to
  111959. */
  111960. serialize(serializationObject: any): void;
  111961. /**
  111962. * Adds all the elements from the container to the scene
  111963. * @param container the container holding the elements
  111964. */
  111965. addFromContainer(container: AbstractScene): void;
  111966. /**
  111967. * Removes all the elements in the container from the scene
  111968. * @param container contains the elements to remove
  111969. * @param dispose if the removed element should be disposed (default: false)
  111970. */
  111971. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111972. /**
  111973. * Disposes the component and the associated ressources.
  111974. */
  111975. dispose(): void;
  111976. private _isReadyForMesh;
  111977. private _renderMainTexture;
  111978. private _setStencil;
  111979. private _setStencilBack;
  111980. private _draw;
  111981. private _drawCamera;
  111982. private _drawRenderingGroup;
  111983. }
  111984. }
  111985. declare module BABYLON {
  111986. /** @hidden */
  111987. export var glowMapMergePixelShader: {
  111988. name: string;
  111989. shader: string;
  111990. };
  111991. }
  111992. declare module BABYLON {
  111993. /** @hidden */
  111994. export var glowMapMergeVertexShader: {
  111995. name: string;
  111996. shader: string;
  111997. };
  111998. }
  111999. declare module BABYLON {
  112000. interface AbstractScene {
  112001. /**
  112002. * Return a the first highlight layer of the scene with a given name.
  112003. * @param name The name of the highlight layer to look for.
  112004. * @return The highlight layer if found otherwise null.
  112005. */
  112006. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  112007. }
  112008. /**
  112009. * Glow layer options. This helps customizing the behaviour
  112010. * of the glow layer.
  112011. */
  112012. export interface IGlowLayerOptions {
  112013. /**
  112014. * Multiplication factor apply to the canvas size to compute the render target size
  112015. * used to generated the glowing objects (the smaller the faster).
  112016. */
  112017. mainTextureRatio: number;
  112018. /**
  112019. * Enforces a fixed size texture to ensure resize independant blur.
  112020. */
  112021. mainTextureFixedSize?: number;
  112022. /**
  112023. * How big is the kernel of the blur texture.
  112024. */
  112025. blurKernelSize: number;
  112026. /**
  112027. * The camera attached to the layer.
  112028. */
  112029. camera: Nullable<Camera>;
  112030. /**
  112031. * Enable MSAA by chosing the number of samples.
  112032. */
  112033. mainTextureSamples?: number;
  112034. /**
  112035. * The rendering group to draw the layer in.
  112036. */
  112037. renderingGroupId: number;
  112038. }
  112039. /**
  112040. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  112041. *
  112042. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112043. * glowy meshes to your scene.
  112044. *
  112045. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  112046. */
  112047. export class GlowLayer extends EffectLayer {
  112048. /**
  112049. * Effect Name of the layer.
  112050. */
  112051. static readonly EffectName: string;
  112052. /**
  112053. * The default blur kernel size used for the glow.
  112054. */
  112055. static DefaultBlurKernelSize: number;
  112056. /**
  112057. * The default texture size ratio used for the glow.
  112058. */
  112059. static DefaultTextureRatio: number;
  112060. /**
  112061. * Sets the kernel size of the blur.
  112062. */
  112063. /**
  112064. * Gets the kernel size of the blur.
  112065. */
  112066. blurKernelSize: number;
  112067. /**
  112068. * Sets the glow intensity.
  112069. */
  112070. /**
  112071. * Gets the glow intensity.
  112072. */
  112073. intensity: number;
  112074. private _options;
  112075. private _intensity;
  112076. private _horizontalBlurPostprocess1;
  112077. private _verticalBlurPostprocess1;
  112078. private _horizontalBlurPostprocess2;
  112079. private _verticalBlurPostprocess2;
  112080. private _blurTexture1;
  112081. private _blurTexture2;
  112082. private _postProcesses1;
  112083. private _postProcesses2;
  112084. private _includedOnlyMeshes;
  112085. private _excludedMeshes;
  112086. /**
  112087. * Callback used to let the user override the color selection on a per mesh basis
  112088. */
  112089. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  112090. /**
  112091. * Callback used to let the user override the texture selection on a per mesh basis
  112092. */
  112093. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  112094. /**
  112095. * Instantiates a new glow Layer and references it to the scene.
  112096. * @param name The name of the layer
  112097. * @param scene The scene to use the layer in
  112098. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  112099. */
  112100. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  112101. /**
  112102. * Get the effect name of the layer.
  112103. * @return The effect name
  112104. */
  112105. getEffectName(): string;
  112106. /**
  112107. * Create the merge effect. This is the shader use to blit the information back
  112108. * to the main canvas at the end of the scene rendering.
  112109. */
  112110. protected _createMergeEffect(): Effect;
  112111. /**
  112112. * Creates the render target textures and post processes used in the glow layer.
  112113. */
  112114. protected _createTextureAndPostProcesses(): void;
  112115. /**
  112116. * Checks for the readiness of the element composing the layer.
  112117. * @param subMesh the mesh to check for
  112118. * @param useInstances specify wether or not to use instances to render the mesh
  112119. * @param emissiveTexture the associated emissive texture used to generate the glow
  112120. * @return true if ready otherwise, false
  112121. */
  112122. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112123. /**
  112124. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112125. */
  112126. needStencil(): boolean;
  112127. /**
  112128. * Returns true if the mesh can be rendered, otherwise false.
  112129. * @param mesh The mesh to render
  112130. * @param material The material used on the mesh
  112131. * @returns true if it can be rendered otherwise false
  112132. */
  112133. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  112134. /**
  112135. * Implementation specific of rendering the generating effect on the main canvas.
  112136. * @param effect The effect used to render through
  112137. */
  112138. protected _internalRender(effect: Effect): void;
  112139. /**
  112140. * Sets the required values for both the emissive texture and and the main color.
  112141. */
  112142. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112143. /**
  112144. * Returns true if the mesh should render, otherwise false.
  112145. * @param mesh The mesh to render
  112146. * @returns true if it should render otherwise false
  112147. */
  112148. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112149. /**
  112150. * Adds specific effects defines.
  112151. * @param defines The defines to add specifics to.
  112152. */
  112153. protected _addCustomEffectDefines(defines: string[]): void;
  112154. /**
  112155. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  112156. * @param mesh The mesh to exclude from the glow layer
  112157. */
  112158. addExcludedMesh(mesh: Mesh): void;
  112159. /**
  112160. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  112161. * @param mesh The mesh to remove
  112162. */
  112163. removeExcludedMesh(mesh: Mesh): void;
  112164. /**
  112165. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  112166. * @param mesh The mesh to include in the glow layer
  112167. */
  112168. addIncludedOnlyMesh(mesh: Mesh): void;
  112169. /**
  112170. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  112171. * @param mesh The mesh to remove
  112172. */
  112173. removeIncludedOnlyMesh(mesh: Mesh): void;
  112174. /**
  112175. * Determine if a given mesh will be used in the glow layer
  112176. * @param mesh The mesh to test
  112177. * @returns true if the mesh will be highlighted by the current glow layer
  112178. */
  112179. hasMesh(mesh: AbstractMesh): boolean;
  112180. /**
  112181. * Free any resources and references associated to a mesh.
  112182. * Internal use
  112183. * @param mesh The mesh to free.
  112184. * @hidden
  112185. */
  112186. _disposeMesh(mesh: Mesh): void;
  112187. /**
  112188. * Gets the class name of the effect layer
  112189. * @returns the string with the class name of the effect layer
  112190. */
  112191. getClassName(): string;
  112192. /**
  112193. * Serializes this glow layer
  112194. * @returns a serialized glow layer object
  112195. */
  112196. serialize(): any;
  112197. /**
  112198. * Creates a Glow Layer from parsed glow layer data
  112199. * @param parsedGlowLayer defines glow layer data
  112200. * @param scene defines the current scene
  112201. * @param rootUrl defines the root URL containing the glow layer information
  112202. * @returns a parsed Glow Layer
  112203. */
  112204. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  112205. }
  112206. }
  112207. declare module BABYLON {
  112208. /** @hidden */
  112209. export var glowBlurPostProcessPixelShader: {
  112210. name: string;
  112211. shader: string;
  112212. };
  112213. }
  112214. declare module BABYLON {
  112215. interface AbstractScene {
  112216. /**
  112217. * Return a the first highlight layer of the scene with a given name.
  112218. * @param name The name of the highlight layer to look for.
  112219. * @return The highlight layer if found otherwise null.
  112220. */
  112221. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  112222. }
  112223. /**
  112224. * Highlight layer options. This helps customizing the behaviour
  112225. * of the highlight layer.
  112226. */
  112227. export interface IHighlightLayerOptions {
  112228. /**
  112229. * Multiplication factor apply to the canvas size to compute the render target size
  112230. * used to generated the glowing objects (the smaller the faster).
  112231. */
  112232. mainTextureRatio: number;
  112233. /**
  112234. * Enforces a fixed size texture to ensure resize independant blur.
  112235. */
  112236. mainTextureFixedSize?: number;
  112237. /**
  112238. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  112239. * of the picture to blur (the smaller the faster).
  112240. */
  112241. blurTextureSizeRatio: number;
  112242. /**
  112243. * How big in texel of the blur texture is the vertical blur.
  112244. */
  112245. blurVerticalSize: number;
  112246. /**
  112247. * How big in texel of the blur texture is the horizontal blur.
  112248. */
  112249. blurHorizontalSize: number;
  112250. /**
  112251. * Alpha blending mode used to apply the blur. Default is combine.
  112252. */
  112253. alphaBlendingMode: number;
  112254. /**
  112255. * The camera attached to the layer.
  112256. */
  112257. camera: Nullable<Camera>;
  112258. /**
  112259. * Should we display highlight as a solid stroke?
  112260. */
  112261. isStroke?: boolean;
  112262. /**
  112263. * The rendering group to draw the layer in.
  112264. */
  112265. renderingGroupId: number;
  112266. }
  112267. /**
  112268. * The highlight layer Helps adding a glow effect around a mesh.
  112269. *
  112270. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  112271. * glowy meshes to your scene.
  112272. *
  112273. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  112274. */
  112275. export class HighlightLayer extends EffectLayer {
  112276. name: string;
  112277. /**
  112278. * Effect Name of the highlight layer.
  112279. */
  112280. static readonly EffectName: string;
  112281. /**
  112282. * The neutral color used during the preparation of the glow effect.
  112283. * This is black by default as the blend operation is a blend operation.
  112284. */
  112285. static NeutralColor: Color4;
  112286. /**
  112287. * Stencil value used for glowing meshes.
  112288. */
  112289. static GlowingMeshStencilReference: number;
  112290. /**
  112291. * Stencil value used for the other meshes in the scene.
  112292. */
  112293. static NormalMeshStencilReference: number;
  112294. /**
  112295. * Specifies whether or not the inner glow is ACTIVE in the layer.
  112296. */
  112297. innerGlow: boolean;
  112298. /**
  112299. * Specifies whether or not the outer glow is ACTIVE in the layer.
  112300. */
  112301. outerGlow: boolean;
  112302. /**
  112303. * Specifies the horizontal size of the blur.
  112304. */
  112305. /**
  112306. * Gets the horizontal size of the blur.
  112307. */
  112308. blurHorizontalSize: number;
  112309. /**
  112310. * Specifies the vertical size of the blur.
  112311. */
  112312. /**
  112313. * Gets the vertical size of the blur.
  112314. */
  112315. blurVerticalSize: number;
  112316. /**
  112317. * An event triggered when the highlight layer is being blurred.
  112318. */
  112319. onBeforeBlurObservable: Observable<HighlightLayer>;
  112320. /**
  112321. * An event triggered when the highlight layer has been blurred.
  112322. */
  112323. onAfterBlurObservable: Observable<HighlightLayer>;
  112324. private _instanceGlowingMeshStencilReference;
  112325. private _options;
  112326. private _downSamplePostprocess;
  112327. private _horizontalBlurPostprocess;
  112328. private _verticalBlurPostprocess;
  112329. private _blurTexture;
  112330. private _meshes;
  112331. private _excludedMeshes;
  112332. /**
  112333. * Instantiates a new highlight Layer and references it to the scene..
  112334. * @param name The name of the layer
  112335. * @param scene The scene to use the layer in
  112336. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  112337. */
  112338. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  112339. /**
  112340. * Get the effect name of the layer.
  112341. * @return The effect name
  112342. */
  112343. getEffectName(): string;
  112344. /**
  112345. * Create the merge effect. This is the shader use to blit the information back
  112346. * to the main canvas at the end of the scene rendering.
  112347. */
  112348. protected _createMergeEffect(): Effect;
  112349. /**
  112350. * Creates the render target textures and post processes used in the highlight layer.
  112351. */
  112352. protected _createTextureAndPostProcesses(): void;
  112353. /**
  112354. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  112355. */
  112356. needStencil(): boolean;
  112357. /**
  112358. * Checks for the readiness of the element composing the layer.
  112359. * @param subMesh the mesh to check for
  112360. * @param useInstances specify wether or not to use instances to render the mesh
  112361. * @param emissiveTexture the associated emissive texture used to generate the glow
  112362. * @return true if ready otherwise, false
  112363. */
  112364. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112365. /**
  112366. * Implementation specific of rendering the generating effect on the main canvas.
  112367. * @param effect The effect used to render through
  112368. */
  112369. protected _internalRender(effect: Effect): void;
  112370. /**
  112371. * Returns true if the layer contains information to display, otherwise false.
  112372. */
  112373. shouldRender(): boolean;
  112374. /**
  112375. * Returns true if the mesh should render, otherwise false.
  112376. * @param mesh The mesh to render
  112377. * @returns true if it should render otherwise false
  112378. */
  112379. protected _shouldRenderMesh(mesh: Mesh): boolean;
  112380. /**
  112381. * Sets the required values for both the emissive texture and and the main color.
  112382. */
  112383. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  112384. /**
  112385. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  112386. * @param mesh The mesh to exclude from the highlight layer
  112387. */
  112388. addExcludedMesh(mesh: Mesh): void;
  112389. /**
  112390. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  112391. * @param mesh The mesh to highlight
  112392. */
  112393. removeExcludedMesh(mesh: Mesh): void;
  112394. /**
  112395. * Determine if a given mesh will be highlighted by the current HighlightLayer
  112396. * @param mesh mesh to test
  112397. * @returns true if the mesh will be highlighted by the current HighlightLayer
  112398. */
  112399. hasMesh(mesh: AbstractMesh): boolean;
  112400. /**
  112401. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  112402. * @param mesh The mesh to highlight
  112403. * @param color The color of the highlight
  112404. * @param glowEmissiveOnly Extract the glow from the emissive texture
  112405. */
  112406. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  112407. /**
  112408. * Remove a mesh from the highlight layer in order to make it stop glowing.
  112409. * @param mesh The mesh to highlight
  112410. */
  112411. removeMesh(mesh: Mesh): void;
  112412. /**
  112413. * Force the stencil to the normal expected value for none glowing parts
  112414. */
  112415. private _defaultStencilReference;
  112416. /**
  112417. * Free any resources and references associated to a mesh.
  112418. * Internal use
  112419. * @param mesh The mesh to free.
  112420. * @hidden
  112421. */
  112422. _disposeMesh(mesh: Mesh): void;
  112423. /**
  112424. * Dispose the highlight layer and free resources.
  112425. */
  112426. dispose(): void;
  112427. /**
  112428. * Gets the class name of the effect layer
  112429. * @returns the string with the class name of the effect layer
  112430. */
  112431. getClassName(): string;
  112432. /**
  112433. * Serializes this Highlight layer
  112434. * @returns a serialized Highlight layer object
  112435. */
  112436. serialize(): any;
  112437. /**
  112438. * Creates a Highlight layer from parsed Highlight layer data
  112439. * @param parsedHightlightLayer defines the Highlight layer data
  112440. * @param scene defines the current scene
  112441. * @param rootUrl defines the root URL containing the Highlight layer information
  112442. * @returns a parsed Highlight layer
  112443. */
  112444. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  112445. }
  112446. }
  112447. declare module BABYLON {
  112448. interface AbstractScene {
  112449. /**
  112450. * The list of layers (background and foreground) of the scene
  112451. */
  112452. layers: Array<Layer>;
  112453. }
  112454. /**
  112455. * Defines the layer scene component responsible to manage any layers
  112456. * in a given scene.
  112457. */
  112458. export class LayerSceneComponent implements ISceneComponent {
  112459. /**
  112460. * The component name helpfull to identify the component in the list of scene components.
  112461. */
  112462. readonly name: string;
  112463. /**
  112464. * The scene the component belongs to.
  112465. */
  112466. scene: Scene;
  112467. private _engine;
  112468. /**
  112469. * Creates a new instance of the component for the given scene
  112470. * @param scene Defines the scene to register the component in
  112471. */
  112472. constructor(scene: Scene);
  112473. /**
  112474. * Registers the component in a given scene
  112475. */
  112476. register(): void;
  112477. /**
  112478. * Rebuilds the elements related to this component in case of
  112479. * context lost for instance.
  112480. */
  112481. rebuild(): void;
  112482. /**
  112483. * Disposes the component and the associated ressources.
  112484. */
  112485. dispose(): void;
  112486. private _draw;
  112487. private _drawCameraPredicate;
  112488. private _drawCameraBackground;
  112489. private _drawCameraForeground;
  112490. private _drawRenderTargetPredicate;
  112491. private _drawRenderTargetBackground;
  112492. private _drawRenderTargetForeground;
  112493. /**
  112494. * Adds all the elements from the container to the scene
  112495. * @param container the container holding the elements
  112496. */
  112497. addFromContainer(container: AbstractScene): void;
  112498. /**
  112499. * Removes all the elements in the container from the scene
  112500. * @param container contains the elements to remove
  112501. * @param dispose if the removed element should be disposed (default: false)
  112502. */
  112503. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112504. }
  112505. }
  112506. declare module BABYLON {
  112507. /** @hidden */
  112508. export var layerPixelShader: {
  112509. name: string;
  112510. shader: string;
  112511. };
  112512. }
  112513. declare module BABYLON {
  112514. /** @hidden */
  112515. export var layerVertexShader: {
  112516. name: string;
  112517. shader: string;
  112518. };
  112519. }
  112520. declare module BABYLON {
  112521. /**
  112522. * This represents a full screen 2d layer.
  112523. * This can be useful to display a picture in the background of your scene for instance.
  112524. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112525. */
  112526. export class Layer {
  112527. /**
  112528. * Define the name of the layer.
  112529. */
  112530. name: string;
  112531. /**
  112532. * Define the texture the layer should display.
  112533. */
  112534. texture: Nullable<Texture>;
  112535. /**
  112536. * Is the layer in background or foreground.
  112537. */
  112538. isBackground: boolean;
  112539. /**
  112540. * Define the color of the layer (instead of texture).
  112541. */
  112542. color: Color4;
  112543. /**
  112544. * Define the scale of the layer in order to zoom in out of the texture.
  112545. */
  112546. scale: Vector2;
  112547. /**
  112548. * Define an offset for the layer in order to shift the texture.
  112549. */
  112550. offset: Vector2;
  112551. /**
  112552. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  112553. */
  112554. alphaBlendingMode: number;
  112555. /**
  112556. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  112557. * Alpha test will not mix with the background color in case of transparency.
  112558. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  112559. */
  112560. alphaTest: boolean;
  112561. /**
  112562. * Define a mask to restrict the layer to only some of the scene cameras.
  112563. */
  112564. layerMask: number;
  112565. /**
  112566. * Define the list of render target the layer is visible into.
  112567. */
  112568. renderTargetTextures: RenderTargetTexture[];
  112569. /**
  112570. * Define if the layer is only used in renderTarget or if it also
  112571. * renders in the main frame buffer of the canvas.
  112572. */
  112573. renderOnlyInRenderTargetTextures: boolean;
  112574. private _scene;
  112575. private _vertexBuffers;
  112576. private _indexBuffer;
  112577. private _effect;
  112578. private _alphaTestEffect;
  112579. /**
  112580. * An event triggered when the layer is disposed.
  112581. */
  112582. onDisposeObservable: Observable<Layer>;
  112583. private _onDisposeObserver;
  112584. /**
  112585. * Back compatibility with callback before the onDisposeObservable existed.
  112586. * The set callback will be triggered when the layer has been disposed.
  112587. */
  112588. onDispose: () => void;
  112589. /**
  112590. * An event triggered before rendering the scene
  112591. */
  112592. onBeforeRenderObservable: Observable<Layer>;
  112593. private _onBeforeRenderObserver;
  112594. /**
  112595. * Back compatibility with callback before the onBeforeRenderObservable existed.
  112596. * The set callback will be triggered just before rendering the layer.
  112597. */
  112598. onBeforeRender: () => void;
  112599. /**
  112600. * An event triggered after rendering the scene
  112601. */
  112602. onAfterRenderObservable: Observable<Layer>;
  112603. private _onAfterRenderObserver;
  112604. /**
  112605. * Back compatibility with callback before the onAfterRenderObservable existed.
  112606. * The set callback will be triggered just after rendering the layer.
  112607. */
  112608. onAfterRender: () => void;
  112609. /**
  112610. * Instantiates a new layer.
  112611. * This represents a full screen 2d layer.
  112612. * This can be useful to display a picture in the background of your scene for instance.
  112613. * @see https://www.babylonjs-playground.com/#08A2BS#1
  112614. * @param name Define the name of the layer in the scene
  112615. * @param imgUrl Define the url of the texture to display in the layer
  112616. * @param scene Define the scene the layer belongs to
  112617. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  112618. * @param color Defines a color for the layer
  112619. */
  112620. constructor(
  112621. /**
  112622. * Define the name of the layer.
  112623. */
  112624. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  112625. private _createIndexBuffer;
  112626. /** @hidden */
  112627. _rebuild(): void;
  112628. /**
  112629. * Renders the layer in the scene.
  112630. */
  112631. render(): void;
  112632. /**
  112633. * Disposes and releases the associated ressources.
  112634. */
  112635. dispose(): void;
  112636. }
  112637. }
  112638. declare module BABYLON {
  112639. /** @hidden */
  112640. export var lensFlarePixelShader: {
  112641. name: string;
  112642. shader: string;
  112643. };
  112644. }
  112645. declare module BABYLON {
  112646. /** @hidden */
  112647. export var lensFlareVertexShader: {
  112648. name: string;
  112649. shader: string;
  112650. };
  112651. }
  112652. declare module BABYLON {
  112653. /**
  112654. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112655. * It is usually composed of several `lensFlare`.
  112656. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112657. */
  112658. export class LensFlareSystem {
  112659. /**
  112660. * Define the name of the lens flare system
  112661. */
  112662. name: string;
  112663. /**
  112664. * List of lens flares used in this system.
  112665. */
  112666. lensFlares: LensFlare[];
  112667. /**
  112668. * Define a limit from the border the lens flare can be visible.
  112669. */
  112670. borderLimit: number;
  112671. /**
  112672. * Define a viewport border we do not want to see the lens flare in.
  112673. */
  112674. viewportBorder: number;
  112675. /**
  112676. * Define a predicate which could limit the list of meshes able to occlude the effect.
  112677. */
  112678. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  112679. /**
  112680. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  112681. */
  112682. layerMask: number;
  112683. /**
  112684. * Define the id of the lens flare system in the scene.
  112685. * (equal to name by default)
  112686. */
  112687. id: string;
  112688. private _scene;
  112689. private _emitter;
  112690. private _vertexBuffers;
  112691. private _indexBuffer;
  112692. private _effect;
  112693. private _positionX;
  112694. private _positionY;
  112695. private _isEnabled;
  112696. /** @hidden */
  112697. static _SceneComponentInitialization: (scene: Scene) => void;
  112698. /**
  112699. * Instantiates a lens flare system.
  112700. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  112701. * It is usually composed of several `lensFlare`.
  112702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112703. * @param name Define the name of the lens flare system in the scene
  112704. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  112705. * @param scene Define the scene the lens flare system belongs to
  112706. */
  112707. constructor(
  112708. /**
  112709. * Define the name of the lens flare system
  112710. */
  112711. name: string, emitter: any, scene: Scene);
  112712. /**
  112713. * Define if the lens flare system is enabled.
  112714. */
  112715. isEnabled: boolean;
  112716. /**
  112717. * Get the scene the effects belongs to.
  112718. * @returns the scene holding the lens flare system
  112719. */
  112720. getScene(): Scene;
  112721. /**
  112722. * Get the emitter of the lens flare system.
  112723. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112724. * @returns the emitter of the lens flare system
  112725. */
  112726. getEmitter(): any;
  112727. /**
  112728. * Set the emitter of the lens flare system.
  112729. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  112730. * @param newEmitter Define the new emitter of the system
  112731. */
  112732. setEmitter(newEmitter: any): void;
  112733. /**
  112734. * Get the lens flare system emitter position.
  112735. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  112736. * @returns the position
  112737. */
  112738. getEmitterPosition(): Vector3;
  112739. /**
  112740. * @hidden
  112741. */
  112742. computeEffectivePosition(globalViewport: Viewport): boolean;
  112743. /** @hidden */
  112744. _isVisible(): boolean;
  112745. /**
  112746. * @hidden
  112747. */
  112748. render(): boolean;
  112749. /**
  112750. * Dispose and release the lens flare with its associated resources.
  112751. */
  112752. dispose(): void;
  112753. /**
  112754. * Parse a lens flare system from a JSON repressentation
  112755. * @param parsedLensFlareSystem Define the JSON to parse
  112756. * @param scene Define the scene the parsed system should be instantiated in
  112757. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  112758. * @returns the parsed system
  112759. */
  112760. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  112761. /**
  112762. * Serialize the current Lens Flare System into a JSON representation.
  112763. * @returns the serialized JSON
  112764. */
  112765. serialize(): any;
  112766. }
  112767. }
  112768. declare module BABYLON {
  112769. /**
  112770. * This represents one of the lens effect in a `lensFlareSystem`.
  112771. * It controls one of the indiviual texture used in the effect.
  112772. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112773. */
  112774. export class LensFlare {
  112775. /**
  112776. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112777. */
  112778. size: number;
  112779. /**
  112780. * 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.
  112781. */
  112782. position: number;
  112783. /**
  112784. * Define the lens color.
  112785. */
  112786. color: Color3;
  112787. /**
  112788. * Define the lens texture.
  112789. */
  112790. texture: Nullable<Texture>;
  112791. /**
  112792. * Define the alpha mode to render this particular lens.
  112793. */
  112794. alphaMode: number;
  112795. private _system;
  112796. /**
  112797. * Creates a new Lens Flare.
  112798. * This represents one of the lens effect in a `lensFlareSystem`.
  112799. * It controls one of the indiviual texture used in the effect.
  112800. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112801. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  112802. * @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.
  112803. * @param color Define the lens color
  112804. * @param imgUrl Define the lens texture url
  112805. * @param system Define the `lensFlareSystem` this flare is part of
  112806. * @returns The newly created Lens Flare
  112807. */
  112808. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  112809. /**
  112810. * Instantiates a new Lens Flare.
  112811. * This represents one of the lens effect in a `lensFlareSystem`.
  112812. * It controls one of the indiviual texture used in the effect.
  112813. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112814. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  112815. * @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.
  112816. * @param color Define the lens color
  112817. * @param imgUrl Define the lens texture url
  112818. * @param system Define the `lensFlareSystem` this flare is part of
  112819. */
  112820. constructor(
  112821. /**
  112822. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  112823. */
  112824. size: number,
  112825. /**
  112826. * 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.
  112827. */
  112828. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  112829. /**
  112830. * Dispose and release the lens flare with its associated resources.
  112831. */
  112832. dispose(): void;
  112833. }
  112834. }
  112835. declare module BABYLON {
  112836. interface AbstractScene {
  112837. /**
  112838. * The list of lens flare system added to the scene
  112839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112840. */
  112841. lensFlareSystems: Array<LensFlareSystem>;
  112842. /**
  112843. * Removes the given lens flare system from this scene.
  112844. * @param toRemove The lens flare system to remove
  112845. * @returns The index of the removed lens flare system
  112846. */
  112847. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  112848. /**
  112849. * Adds the given lens flare system to this scene
  112850. * @param newLensFlareSystem The lens flare system to add
  112851. */
  112852. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  112853. /**
  112854. * Gets a lens flare system using its name
  112855. * @param name defines the name to look for
  112856. * @returns the lens flare system or null if not found
  112857. */
  112858. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  112859. /**
  112860. * Gets a lens flare system using its id
  112861. * @param id defines the id to look for
  112862. * @returns the lens flare system or null if not found
  112863. */
  112864. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  112865. }
  112866. /**
  112867. * Defines the lens flare scene component responsible to manage any lens flares
  112868. * in a given scene.
  112869. */
  112870. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  112871. /**
  112872. * The component name helpfull to identify the component in the list of scene components.
  112873. */
  112874. readonly name: string;
  112875. /**
  112876. * The scene the component belongs to.
  112877. */
  112878. scene: Scene;
  112879. /**
  112880. * Creates a new instance of the component for the given scene
  112881. * @param scene Defines the scene to register the component in
  112882. */
  112883. constructor(scene: Scene);
  112884. /**
  112885. * Registers the component in a given scene
  112886. */
  112887. register(): void;
  112888. /**
  112889. * Rebuilds the elements related to this component in case of
  112890. * context lost for instance.
  112891. */
  112892. rebuild(): void;
  112893. /**
  112894. * Adds all the elements from the container to the scene
  112895. * @param container the container holding the elements
  112896. */
  112897. addFromContainer(container: AbstractScene): void;
  112898. /**
  112899. * Removes all the elements in the container from the scene
  112900. * @param container contains the elements to remove
  112901. * @param dispose if the removed element should be disposed (default: false)
  112902. */
  112903. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112904. /**
  112905. * Serializes the component data to the specified json object
  112906. * @param serializationObject The object to serialize to
  112907. */
  112908. serialize(serializationObject: any): void;
  112909. /**
  112910. * Disposes the component and the associated ressources.
  112911. */
  112912. dispose(): void;
  112913. private _draw;
  112914. }
  112915. }
  112916. declare module BABYLON {
  112917. /**
  112918. * Defines the shadow generator component responsible to manage any shadow generators
  112919. * in a given scene.
  112920. */
  112921. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  112922. /**
  112923. * The component name helpfull to identify the component in the list of scene components.
  112924. */
  112925. readonly name: string;
  112926. /**
  112927. * The scene the component belongs to.
  112928. */
  112929. scene: Scene;
  112930. /**
  112931. * Creates a new instance of the component for the given scene
  112932. * @param scene Defines the scene to register the component in
  112933. */
  112934. constructor(scene: Scene);
  112935. /**
  112936. * Registers the component in a given scene
  112937. */
  112938. register(): void;
  112939. /**
  112940. * Rebuilds the elements related to this component in case of
  112941. * context lost for instance.
  112942. */
  112943. rebuild(): void;
  112944. /**
  112945. * Serializes the component data to the specified json object
  112946. * @param serializationObject The object to serialize to
  112947. */
  112948. serialize(serializationObject: any): void;
  112949. /**
  112950. * Adds all the elements from the container to the scene
  112951. * @param container the container holding the elements
  112952. */
  112953. addFromContainer(container: AbstractScene): void;
  112954. /**
  112955. * Removes all the elements in the container from the scene
  112956. * @param container contains the elements to remove
  112957. * @param dispose if the removed element should be disposed (default: false)
  112958. */
  112959. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112960. /**
  112961. * Rebuilds the elements related to this component in case of
  112962. * context lost for instance.
  112963. */
  112964. dispose(): void;
  112965. private _gatherRenderTargets;
  112966. }
  112967. }
  112968. declare module BABYLON {
  112969. /**
  112970. * A point light is a light defined by an unique point in world space.
  112971. * The light is emitted in every direction from this point.
  112972. * A good example of a point light is a standard light bulb.
  112973. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112974. */
  112975. export class PointLight extends ShadowLight {
  112976. private _shadowAngle;
  112977. /**
  112978. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112979. * This specifies what angle the shadow will use to be created.
  112980. *
  112981. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112982. */
  112983. /**
  112984. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112985. * This specifies what angle the shadow will use to be created.
  112986. *
  112987. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  112988. */
  112989. shadowAngle: number;
  112990. /**
  112991. * Gets the direction if it has been set.
  112992. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112993. */
  112994. /**
  112995. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  112996. */
  112997. direction: Vector3;
  112998. /**
  112999. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  113000. * A PointLight emits the light in every direction.
  113001. * It can cast shadows.
  113002. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  113003. * ```javascript
  113004. * var pointLight = new PointLight("pl", camera.position, scene);
  113005. * ```
  113006. * Documentation : https://doc.babylonjs.com/babylon101/lights
  113007. * @param name The light friendly name
  113008. * @param position The position of the point light in the scene
  113009. * @param scene The scene the lights belongs to
  113010. */
  113011. constructor(name: string, position: Vector3, scene: Scene);
  113012. /**
  113013. * Returns the string "PointLight"
  113014. * @returns the class name
  113015. */
  113016. getClassName(): string;
  113017. /**
  113018. * Returns the integer 0.
  113019. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  113020. */
  113021. getTypeID(): number;
  113022. /**
  113023. * Specifies wether or not the shadowmap should be a cube texture.
  113024. * @returns true if the shadowmap needs to be a cube texture.
  113025. */
  113026. needCube(): boolean;
  113027. /**
  113028. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  113029. * @param faceIndex The index of the face we are computed the direction to generate shadow
  113030. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  113031. */
  113032. getShadowDirection(faceIndex?: number): Vector3;
  113033. /**
  113034. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  113035. * - fov = PI / 2
  113036. * - aspect ratio : 1.0
  113037. * - z-near and far equal to the active camera minZ and maxZ.
  113038. * Returns the PointLight.
  113039. */
  113040. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  113041. protected _buildUniformLayout(): void;
  113042. /**
  113043. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  113044. * @param effect The effect to update
  113045. * @param lightIndex The index of the light in the effect to update
  113046. * @returns The point light
  113047. */
  113048. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  113049. /**
  113050. * Prepares the list of defines specific to the light type.
  113051. * @param defines the list of defines
  113052. * @param lightIndex defines the index of the light for the effect
  113053. */
  113054. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  113055. }
  113056. }
  113057. declare module BABYLON {
  113058. /**
  113059. * Header information of HDR texture files.
  113060. */
  113061. export interface HDRInfo {
  113062. /**
  113063. * The height of the texture in pixels.
  113064. */
  113065. height: number;
  113066. /**
  113067. * The width of the texture in pixels.
  113068. */
  113069. width: number;
  113070. /**
  113071. * The index of the beginning of the data in the binary file.
  113072. */
  113073. dataPosition: number;
  113074. }
  113075. /**
  113076. * This groups tools to convert HDR texture to native colors array.
  113077. */
  113078. export class HDRTools {
  113079. private static Ldexp;
  113080. private static Rgbe2float;
  113081. private static readStringLine;
  113082. /**
  113083. * Reads header information from an RGBE texture stored in a native array.
  113084. * More information on this format are available here:
  113085. * https://en.wikipedia.org/wiki/RGBE_image_format
  113086. *
  113087. * @param uint8array The binary file stored in native array.
  113088. * @return The header information.
  113089. */
  113090. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  113091. /**
  113092. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  113093. * This RGBE texture needs to store the information as a panorama.
  113094. *
  113095. * More information on this format are available here:
  113096. * https://en.wikipedia.org/wiki/RGBE_image_format
  113097. *
  113098. * @param buffer The binary file stored in an array buffer.
  113099. * @param size The expected size of the extracted cubemap.
  113100. * @return The Cube Map information.
  113101. */
  113102. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  113103. /**
  113104. * Returns the pixels data extracted from an RGBE texture.
  113105. * This pixels will be stored left to right up to down in the R G B order in one array.
  113106. *
  113107. * More information on this format are available here:
  113108. * https://en.wikipedia.org/wiki/RGBE_image_format
  113109. *
  113110. * @param uint8array The binary file stored in an array buffer.
  113111. * @param hdrInfo The header information of the file.
  113112. * @return The pixels data in RGB right to left up to down order.
  113113. */
  113114. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  113115. private static RGBE_ReadPixels_RLE;
  113116. }
  113117. }
  113118. declare module BABYLON {
  113119. /**
  113120. * This represents a texture coming from an HDR input.
  113121. *
  113122. * The only supported format is currently panorama picture stored in RGBE format.
  113123. * Example of such files can be found on HDRLib: http://hdrlib.com/
  113124. */
  113125. export class HDRCubeTexture extends BaseTexture {
  113126. private static _facesMapping;
  113127. private _generateHarmonics;
  113128. private _noMipmap;
  113129. private _textureMatrix;
  113130. private _size;
  113131. private _onLoad;
  113132. private _onError;
  113133. /**
  113134. * The texture URL.
  113135. */
  113136. url: string;
  113137. /**
  113138. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  113139. */
  113140. coordinatesMode: number;
  113141. protected _isBlocking: boolean;
  113142. /**
  113143. * Sets wether or not the texture is blocking during loading.
  113144. */
  113145. /**
  113146. * Gets wether or not the texture is blocking during loading.
  113147. */
  113148. isBlocking: boolean;
  113149. protected _rotationY: number;
  113150. /**
  113151. * Sets texture matrix rotation angle around Y axis in radians.
  113152. */
  113153. /**
  113154. * Gets texture matrix rotation angle around Y axis radians.
  113155. */
  113156. rotationY: number;
  113157. /**
  113158. * Gets or sets the center of the bounding box associated with the cube texture
  113159. * It must define where the camera used to render the texture was set
  113160. */
  113161. boundingBoxPosition: Vector3;
  113162. private _boundingBoxSize;
  113163. /**
  113164. * Gets or sets the size of the bounding box associated with the cube texture
  113165. * When defined, the cubemap will switch to local mode
  113166. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  113167. * @example https://www.babylonjs-playground.com/#RNASML
  113168. */
  113169. boundingBoxSize: Vector3;
  113170. /**
  113171. * Instantiates an HDRTexture from the following parameters.
  113172. *
  113173. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  113174. * @param scene The scene the texture will be used in
  113175. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  113176. * @param noMipmap Forces to not generate the mipmap if true
  113177. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  113178. * @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)
  113179. * @param reserved Reserved flag for internal use.
  113180. */
  113181. 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>);
  113182. /**
  113183. * Get the current class name of the texture useful for serialization or dynamic coding.
  113184. * @returns "HDRCubeTexture"
  113185. */
  113186. getClassName(): string;
  113187. /**
  113188. * Occurs when the file is raw .hdr file.
  113189. */
  113190. private loadTexture;
  113191. clone(): HDRCubeTexture;
  113192. delayLoad(): void;
  113193. /**
  113194. * Get the texture reflection matrix used to rotate/transform the reflection.
  113195. * @returns the reflection matrix
  113196. */
  113197. getReflectionTextureMatrix(): Matrix;
  113198. /**
  113199. * Set the texture reflection matrix used to rotate/transform the reflection.
  113200. * @param value Define the reflection matrix to set
  113201. */
  113202. setReflectionTextureMatrix(value: Matrix): void;
  113203. /**
  113204. * Parses a JSON representation of an HDR Texture in order to create the texture
  113205. * @param parsedTexture Define the JSON representation
  113206. * @param scene Define the scene the texture should be created in
  113207. * @param rootUrl Define the root url in case we need to load relative dependencies
  113208. * @returns the newly created texture after parsing
  113209. */
  113210. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  113211. serialize(): any;
  113212. }
  113213. }
  113214. declare module BABYLON {
  113215. /**
  113216. * Class used to control physics engine
  113217. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  113218. */
  113219. export class PhysicsEngine implements IPhysicsEngine {
  113220. private _physicsPlugin;
  113221. /**
  113222. * Global value used to control the smallest number supported by the simulation
  113223. */
  113224. static Epsilon: number;
  113225. private _impostors;
  113226. private _joints;
  113227. /**
  113228. * Gets the gravity vector used by the simulation
  113229. */
  113230. gravity: Vector3;
  113231. /**
  113232. * Factory used to create the default physics plugin.
  113233. * @returns The default physics plugin
  113234. */
  113235. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  113236. /**
  113237. * Creates a new Physics Engine
  113238. * @param gravity defines the gravity vector used by the simulation
  113239. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  113240. */
  113241. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  113242. /**
  113243. * Sets the gravity vector used by the simulation
  113244. * @param gravity defines the gravity vector to use
  113245. */
  113246. setGravity(gravity: Vector3): void;
  113247. /**
  113248. * Set the time step of the physics engine.
  113249. * Default is 1/60.
  113250. * To slow it down, enter 1/600 for example.
  113251. * To speed it up, 1/30
  113252. * @param newTimeStep defines the new timestep to apply to this world.
  113253. */
  113254. setTimeStep(newTimeStep?: number): void;
  113255. /**
  113256. * Get the time step of the physics engine.
  113257. * @returns the current time step
  113258. */
  113259. getTimeStep(): number;
  113260. /**
  113261. * Release all resources
  113262. */
  113263. dispose(): void;
  113264. /**
  113265. * Gets the name of the current physics plugin
  113266. * @returns the name of the plugin
  113267. */
  113268. getPhysicsPluginName(): string;
  113269. /**
  113270. * Adding a new impostor for the impostor tracking.
  113271. * This will be done by the impostor itself.
  113272. * @param impostor the impostor to add
  113273. */
  113274. addImpostor(impostor: PhysicsImpostor): void;
  113275. /**
  113276. * Remove an impostor from the engine.
  113277. * This impostor and its mesh will not longer be updated by the physics engine.
  113278. * @param impostor the impostor to remove
  113279. */
  113280. removeImpostor(impostor: PhysicsImpostor): void;
  113281. /**
  113282. * Add a joint to the physics engine
  113283. * @param mainImpostor defines the main impostor to which the joint is added.
  113284. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113285. * @param joint defines the joint that will connect both impostors.
  113286. */
  113287. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113288. /**
  113289. * Removes a joint from the simulation
  113290. * @param mainImpostor defines the impostor used with the joint
  113291. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113292. * @param joint defines the joint to remove
  113293. */
  113294. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113295. /**
  113296. * Called by the scene. No need to call it.
  113297. * @param delta defines the timespam between frames
  113298. */
  113299. _step(delta: number): void;
  113300. /**
  113301. * Gets the current plugin used to run the simulation
  113302. * @returns current plugin
  113303. */
  113304. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113305. /**
  113306. * Gets the list of physic impostors
  113307. * @returns an array of PhysicsImpostor
  113308. */
  113309. getImpostors(): Array<PhysicsImpostor>;
  113310. /**
  113311. * Gets the impostor for a physics enabled object
  113312. * @param object defines the object impersonated by the impostor
  113313. * @returns the PhysicsImpostor or null if not found
  113314. */
  113315. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113316. /**
  113317. * Gets the impostor for a physics body object
  113318. * @param body defines physics body used by the impostor
  113319. * @returns the PhysicsImpostor or null if not found
  113320. */
  113321. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113322. /**
  113323. * Does a raycast in the physics world
  113324. * @param from when should the ray start?
  113325. * @param to when should the ray end?
  113326. * @returns PhysicsRaycastResult
  113327. */
  113328. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113329. }
  113330. }
  113331. declare module BABYLON {
  113332. /** @hidden */
  113333. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  113334. private _useDeltaForWorldStep;
  113335. world: any;
  113336. name: string;
  113337. private _physicsMaterials;
  113338. private _fixedTimeStep;
  113339. private _cannonRaycastResult;
  113340. private _raycastResult;
  113341. private _physicsBodysToRemoveAfterStep;
  113342. BJSCANNON: any;
  113343. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  113344. setGravity(gravity: Vector3): void;
  113345. setTimeStep(timeStep: number): void;
  113346. getTimeStep(): number;
  113347. executeStep(delta: number): void;
  113348. private _removeMarkedPhysicsBodiesFromWorld;
  113349. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113350. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113351. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113352. private _processChildMeshes;
  113353. removePhysicsBody(impostor: PhysicsImpostor): void;
  113354. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113355. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113356. private _addMaterial;
  113357. private _checkWithEpsilon;
  113358. private _createShape;
  113359. private _createHeightmap;
  113360. private _minus90X;
  113361. private _plus90X;
  113362. private _tmpPosition;
  113363. private _tmpDeltaPosition;
  113364. private _tmpUnityRotation;
  113365. private _updatePhysicsBodyTransformation;
  113366. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113368. isSupported(): boolean;
  113369. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113370. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113371. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113372. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113373. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113374. getBodyMass(impostor: PhysicsImpostor): number;
  113375. getBodyFriction(impostor: PhysicsImpostor): number;
  113376. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113377. getBodyRestitution(impostor: PhysicsImpostor): number;
  113378. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113379. sleepBody(impostor: PhysicsImpostor): void;
  113380. wakeUpBody(impostor: PhysicsImpostor): void;
  113381. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  113382. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113383. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113384. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113385. getRadius(impostor: PhysicsImpostor): number;
  113386. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113387. dispose(): void;
  113388. private _extendNamespace;
  113389. /**
  113390. * Does a raycast in the physics world
  113391. * @param from when should the ray start?
  113392. * @param to when should the ray end?
  113393. * @returns PhysicsRaycastResult
  113394. */
  113395. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113396. }
  113397. }
  113398. declare module BABYLON {
  113399. /** @hidden */
  113400. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  113401. world: any;
  113402. name: string;
  113403. BJSOIMO: any;
  113404. private _raycastResult;
  113405. constructor(iterations?: number, oimoInjection?: any);
  113406. setGravity(gravity: Vector3): void;
  113407. setTimeStep(timeStep: number): void;
  113408. getTimeStep(): number;
  113409. private _tmpImpostorsArray;
  113410. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113411. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113412. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113413. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113414. private _tmpPositionVector;
  113415. removePhysicsBody(impostor: PhysicsImpostor): void;
  113416. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113417. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113418. isSupported(): boolean;
  113419. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113420. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113421. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113422. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113423. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113424. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113425. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113426. getBodyMass(impostor: PhysicsImpostor): number;
  113427. getBodyFriction(impostor: PhysicsImpostor): number;
  113428. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113429. getBodyRestitution(impostor: PhysicsImpostor): number;
  113430. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113431. sleepBody(impostor: PhysicsImpostor): void;
  113432. wakeUpBody(impostor: PhysicsImpostor): void;
  113433. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113434. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  113435. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113436. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113437. getRadius(impostor: PhysicsImpostor): number;
  113438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113439. dispose(): void;
  113440. /**
  113441. * Does a raycast in the physics world
  113442. * @param from when should the ray start?
  113443. * @param to when should the ray end?
  113444. * @returns PhysicsRaycastResult
  113445. */
  113446. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113447. }
  113448. }
  113449. declare module BABYLON {
  113450. /**
  113451. * Class containing static functions to help procedurally build meshes
  113452. */
  113453. export class RibbonBuilder {
  113454. /**
  113455. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  113456. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  113457. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  113458. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  113459. * * 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
  113460. * * 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
  113461. * * 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
  113462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113465. * * 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
  113466. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  113467. * * 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
  113468. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  113469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113470. * @param name defines the name of the mesh
  113471. * @param options defines the options used to create the mesh
  113472. * @param scene defines the hosting scene
  113473. * @returns the ribbon mesh
  113474. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  113475. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113476. */
  113477. static CreateRibbon(name: string, options: {
  113478. pathArray: Vector3[][];
  113479. closeArray?: boolean;
  113480. closePath?: boolean;
  113481. offset?: number;
  113482. updatable?: boolean;
  113483. sideOrientation?: number;
  113484. frontUVs?: Vector4;
  113485. backUVs?: Vector4;
  113486. instance?: Mesh;
  113487. invertUV?: boolean;
  113488. uvs?: Vector2[];
  113489. colors?: Color4[];
  113490. }, scene?: Nullable<Scene>): Mesh;
  113491. }
  113492. }
  113493. declare module BABYLON {
  113494. /**
  113495. * Class containing static functions to help procedurally build meshes
  113496. */
  113497. export class ShapeBuilder {
  113498. /**
  113499. * 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.
  113500. * * 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.
  113501. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113502. * * 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.
  113503. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  113504. * * 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
  113505. * * 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
  113506. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  113507. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113508. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113509. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  113510. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113511. * @param name defines the name of the mesh
  113512. * @param options defines the options used to create the mesh
  113513. * @param scene defines the hosting scene
  113514. * @returns the extruded shape mesh
  113515. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113516. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113517. */
  113518. static ExtrudeShape(name: string, options: {
  113519. shape: Vector3[];
  113520. path: Vector3[];
  113521. scale?: number;
  113522. rotation?: number;
  113523. cap?: number;
  113524. updatable?: boolean;
  113525. sideOrientation?: number;
  113526. frontUVs?: Vector4;
  113527. backUVs?: Vector4;
  113528. instance?: Mesh;
  113529. invertUV?: boolean;
  113530. }, scene?: Nullable<Scene>): Mesh;
  113531. /**
  113532. * Creates an custom extruded shape mesh.
  113533. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  113534. * * 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.
  113535. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  113536. * * 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
  113537. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  113538. * * 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
  113539. * * It must returns a float value that will be the scale value applied to the shape on each path point
  113540. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  113541. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  113542. * * 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
  113543. * * 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
  113544. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  113545. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113546. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113547. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  113548. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113549. * @param name defines the name of the mesh
  113550. * @param options defines the options used to create the mesh
  113551. * @param scene defines the hosting scene
  113552. * @returns the custom extruded shape mesh
  113553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  113554. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  113555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  113556. */
  113557. static ExtrudeShapeCustom(name: string, options: {
  113558. shape: Vector3[];
  113559. path: Vector3[];
  113560. scaleFunction?: any;
  113561. rotationFunction?: any;
  113562. ribbonCloseArray?: boolean;
  113563. ribbonClosePath?: boolean;
  113564. cap?: number;
  113565. updatable?: boolean;
  113566. sideOrientation?: number;
  113567. frontUVs?: Vector4;
  113568. backUVs?: Vector4;
  113569. instance?: Mesh;
  113570. invertUV?: boolean;
  113571. }, scene?: Nullable<Scene>): Mesh;
  113572. private static _ExtrudeShapeGeneric;
  113573. }
  113574. }
  113575. declare module BABYLON {
  113576. /**
  113577. * AmmoJS Physics plugin
  113578. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113579. * @see https://github.com/kripken/ammo.js/
  113580. */
  113581. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  113582. private _useDeltaForWorldStep;
  113583. /**
  113584. * Reference to the Ammo library
  113585. */
  113586. bjsAMMO: any;
  113587. /**
  113588. * Created ammoJS world which physics bodies are added to
  113589. */
  113590. world: any;
  113591. /**
  113592. * Name of the plugin
  113593. */
  113594. name: string;
  113595. private _timeStep;
  113596. private _fixedTimeStep;
  113597. private _maxSteps;
  113598. private _tmpQuaternion;
  113599. private _tmpAmmoTransform;
  113600. private _tmpAmmoQuaternion;
  113601. private _tmpAmmoConcreteContactResultCallback;
  113602. private _collisionConfiguration;
  113603. private _dispatcher;
  113604. private _overlappingPairCache;
  113605. private _solver;
  113606. private _softBodySolver;
  113607. private _tmpAmmoVectorA;
  113608. private _tmpAmmoVectorB;
  113609. private _tmpAmmoVectorC;
  113610. private _tmpAmmoVectorD;
  113611. private _tmpContactCallbackResult;
  113612. private _tmpAmmoVectorRCA;
  113613. private _tmpAmmoVectorRCB;
  113614. private _raycastResult;
  113615. private static readonly DISABLE_COLLISION_FLAG;
  113616. private static readonly KINEMATIC_FLAG;
  113617. private static readonly DISABLE_DEACTIVATION_FLAG;
  113618. /**
  113619. * Initializes the ammoJS plugin
  113620. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  113621. * @param ammoInjection can be used to inject your own ammo reference
  113622. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  113623. */
  113624. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  113625. /**
  113626. * Sets the gravity of the physics world (m/(s^2))
  113627. * @param gravity Gravity to set
  113628. */
  113629. setGravity(gravity: Vector3): void;
  113630. /**
  113631. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  113632. * @param timeStep timestep to use in seconds
  113633. */
  113634. setTimeStep(timeStep: number): void;
  113635. /**
  113636. * 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)
  113637. * @param fixedTimeStep fixedTimeStep to use in seconds
  113638. */
  113639. setFixedTimeStep(fixedTimeStep: number): void;
  113640. /**
  113641. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  113642. * @param maxSteps the maximum number of steps by the physics engine per frame
  113643. */
  113644. setMaxSteps(maxSteps: number): void;
  113645. /**
  113646. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  113647. * @returns the current timestep in seconds
  113648. */
  113649. getTimeStep(): number;
  113650. private _isImpostorInContact;
  113651. private _isImpostorPairInContact;
  113652. private _stepSimulation;
  113653. /**
  113654. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  113655. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  113656. * After the step the babylon meshes are set to the position of the physics imposters
  113657. * @param delta amount of time to step forward
  113658. * @param impostors array of imposters to update before/after the step
  113659. */
  113660. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113661. /**
  113662. * Update babylon mesh to match physics world object
  113663. * @param impostor imposter to match
  113664. */
  113665. private _afterSoftStep;
  113666. /**
  113667. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113668. * @param impostor imposter to match
  113669. */
  113670. private _ropeStep;
  113671. /**
  113672. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  113673. * @param impostor imposter to match
  113674. */
  113675. private _softbodyOrClothStep;
  113676. private _tmpVector;
  113677. private _tmpMatrix;
  113678. /**
  113679. * Applies an impulse on the imposter
  113680. * @param impostor imposter to apply impulse to
  113681. * @param force amount of force to be applied to the imposter
  113682. * @param contactPoint the location to apply the impulse on the imposter
  113683. */
  113684. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113685. /**
  113686. * Applies a force on the imposter
  113687. * @param impostor imposter to apply force
  113688. * @param force amount of force to be applied to the imposter
  113689. * @param contactPoint the location to apply the force on the imposter
  113690. */
  113691. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113692. /**
  113693. * Creates a physics body using the plugin
  113694. * @param impostor the imposter to create the physics body on
  113695. */
  113696. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113697. /**
  113698. * Removes the physics body from the imposter and disposes of the body's memory
  113699. * @param impostor imposter to remove the physics body from
  113700. */
  113701. removePhysicsBody(impostor: PhysicsImpostor): void;
  113702. /**
  113703. * Generates a joint
  113704. * @param impostorJoint the imposter joint to create the joint with
  113705. */
  113706. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  113707. /**
  113708. * Removes a joint
  113709. * @param impostorJoint the imposter joint to remove the joint from
  113710. */
  113711. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  113712. private _addMeshVerts;
  113713. /**
  113714. * Initialise the soft body vertices to match its object's (mesh) vertices
  113715. * Softbody vertices (nodes) are in world space and to match this
  113716. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  113717. * @param impostor to create the softbody for
  113718. */
  113719. private _softVertexData;
  113720. /**
  113721. * Create an impostor's soft body
  113722. * @param impostor to create the softbody for
  113723. */
  113724. private _createSoftbody;
  113725. /**
  113726. * Create cloth for an impostor
  113727. * @param impostor to create the softbody for
  113728. */
  113729. private _createCloth;
  113730. /**
  113731. * Create rope for an impostor
  113732. * @param impostor to create the softbody for
  113733. */
  113734. private _createRope;
  113735. private _addHullVerts;
  113736. private _createShape;
  113737. /**
  113738. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  113739. * @param impostor imposter containing the physics body and babylon object
  113740. */
  113741. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113742. /**
  113743. * Sets the babylon object's position/rotation from the physics body's position/rotation
  113744. * @param impostor imposter containing the physics body and babylon object
  113745. * @param newPosition new position
  113746. * @param newRotation new rotation
  113747. */
  113748. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113749. /**
  113750. * If this plugin is supported
  113751. * @returns true if its supported
  113752. */
  113753. isSupported(): boolean;
  113754. /**
  113755. * Sets the linear velocity of the physics body
  113756. * @param impostor imposter to set the velocity on
  113757. * @param velocity velocity to set
  113758. */
  113759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113760. /**
  113761. * Sets the angular velocity of the physics body
  113762. * @param impostor imposter to set the velocity on
  113763. * @param velocity velocity to set
  113764. */
  113765. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  113766. /**
  113767. * gets the linear velocity
  113768. * @param impostor imposter to get linear velocity from
  113769. * @returns linear velocity
  113770. */
  113771. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113772. /**
  113773. * gets the angular velocity
  113774. * @param impostor imposter to get angular velocity from
  113775. * @returns angular velocity
  113776. */
  113777. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113778. /**
  113779. * Sets the mass of physics body
  113780. * @param impostor imposter to set the mass on
  113781. * @param mass mass to set
  113782. */
  113783. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113784. /**
  113785. * Gets the mass of the physics body
  113786. * @param impostor imposter to get the mass from
  113787. * @returns mass
  113788. */
  113789. getBodyMass(impostor: PhysicsImpostor): number;
  113790. /**
  113791. * Gets friction of the impostor
  113792. * @param impostor impostor to get friction from
  113793. * @returns friction value
  113794. */
  113795. getBodyFriction(impostor: PhysicsImpostor): number;
  113796. /**
  113797. * Sets friction of the impostor
  113798. * @param impostor impostor to set friction on
  113799. * @param friction friction value
  113800. */
  113801. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113802. /**
  113803. * Gets restitution of the impostor
  113804. * @param impostor impostor to get restitution from
  113805. * @returns restitution value
  113806. */
  113807. getBodyRestitution(impostor: PhysicsImpostor): number;
  113808. /**
  113809. * Sets resitution of the impostor
  113810. * @param impostor impostor to set resitution on
  113811. * @param restitution resitution value
  113812. */
  113813. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113814. /**
  113815. * Gets pressure inside the impostor
  113816. * @param impostor impostor to get pressure from
  113817. * @returns pressure value
  113818. */
  113819. getBodyPressure(impostor: PhysicsImpostor): number;
  113820. /**
  113821. * Sets pressure inside a soft body impostor
  113822. * Cloth and rope must remain 0 pressure
  113823. * @param impostor impostor to set pressure on
  113824. * @param pressure pressure value
  113825. */
  113826. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  113827. /**
  113828. * Gets stiffness of the impostor
  113829. * @param impostor impostor to get stiffness from
  113830. * @returns pressure value
  113831. */
  113832. getBodyStiffness(impostor: PhysicsImpostor): number;
  113833. /**
  113834. * Sets stiffness of the impostor
  113835. * @param impostor impostor to set stiffness on
  113836. * @param stiffness stiffness value from 0 to 1
  113837. */
  113838. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  113839. /**
  113840. * Gets velocityIterations of the impostor
  113841. * @param impostor impostor to get velocity iterations from
  113842. * @returns velocityIterations value
  113843. */
  113844. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  113845. /**
  113846. * Sets velocityIterations of the impostor
  113847. * @param impostor impostor to set velocity iterations on
  113848. * @param velocityIterations velocityIterations value
  113849. */
  113850. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  113851. /**
  113852. * Gets positionIterations of the impostor
  113853. * @param impostor impostor to get position iterations from
  113854. * @returns positionIterations value
  113855. */
  113856. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  113857. /**
  113858. * Sets positionIterations of the impostor
  113859. * @param impostor impostor to set position on
  113860. * @param positionIterations positionIterations value
  113861. */
  113862. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  113863. /**
  113864. * Append an anchor to a cloth object
  113865. * @param impostor is the cloth impostor to add anchor to
  113866. * @param otherImpostor is the rigid impostor to anchor to
  113867. * @param width ratio across width from 0 to 1
  113868. * @param height ratio up height from 0 to 1
  113869. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113870. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113871. */
  113872. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113873. /**
  113874. * Append an hook to a rope object
  113875. * @param impostor is the rope impostor to add hook to
  113876. * @param otherImpostor is the rigid impostor to hook to
  113877. * @param length ratio along the rope from 0 to 1
  113878. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  113879. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113880. */
  113881. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  113882. /**
  113883. * Sleeps the physics body and stops it from being active
  113884. * @param impostor impostor to sleep
  113885. */
  113886. sleepBody(impostor: PhysicsImpostor): void;
  113887. /**
  113888. * Activates the physics body
  113889. * @param impostor impostor to activate
  113890. */
  113891. wakeUpBody(impostor: PhysicsImpostor): void;
  113892. /**
  113893. * Updates the distance parameters of the joint
  113894. * @param joint joint to update
  113895. * @param maxDistance maximum distance of the joint
  113896. * @param minDistance minimum distance of the joint
  113897. */
  113898. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113899. /**
  113900. * Sets a motor on the joint
  113901. * @param joint joint to set motor on
  113902. * @param speed speed of the motor
  113903. * @param maxForce maximum force of the motor
  113904. * @param motorIndex index of the motor
  113905. */
  113906. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  113907. /**
  113908. * Sets the motors limit
  113909. * @param joint joint to set limit on
  113910. * @param upperLimit upper limit
  113911. * @param lowerLimit lower limit
  113912. */
  113913. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  113914. /**
  113915. * Syncs the position and rotation of a mesh with the impostor
  113916. * @param mesh mesh to sync
  113917. * @param impostor impostor to update the mesh with
  113918. */
  113919. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113920. /**
  113921. * Gets the radius of the impostor
  113922. * @param impostor impostor to get radius from
  113923. * @returns the radius
  113924. */
  113925. getRadius(impostor: PhysicsImpostor): number;
  113926. /**
  113927. * Gets the box size of the impostor
  113928. * @param impostor impostor to get box size from
  113929. * @param result the resulting box size
  113930. */
  113931. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113932. /**
  113933. * Disposes of the impostor
  113934. */
  113935. dispose(): void;
  113936. /**
  113937. * Does a raycast in the physics world
  113938. * @param from when should the ray start?
  113939. * @param to when should the ray end?
  113940. * @returns PhysicsRaycastResult
  113941. */
  113942. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113943. }
  113944. }
  113945. declare module BABYLON {
  113946. interface AbstractScene {
  113947. /**
  113948. * The list of reflection probes added to the scene
  113949. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113950. */
  113951. reflectionProbes: Array<ReflectionProbe>;
  113952. /**
  113953. * Removes the given reflection probe from this scene.
  113954. * @param toRemove The reflection probe to remove
  113955. * @returns The index of the removed reflection probe
  113956. */
  113957. removeReflectionProbe(toRemove: ReflectionProbe): number;
  113958. /**
  113959. * Adds the given reflection probe to this scene.
  113960. * @param newReflectionProbe The reflection probe to add
  113961. */
  113962. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  113963. }
  113964. /**
  113965. * Class used to generate realtime reflection / refraction cube textures
  113966. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  113967. */
  113968. export class ReflectionProbe {
  113969. /** defines the name of the probe */
  113970. name: string;
  113971. private _scene;
  113972. private _renderTargetTexture;
  113973. private _projectionMatrix;
  113974. private _viewMatrix;
  113975. private _target;
  113976. private _add;
  113977. private _attachedMesh;
  113978. private _invertYAxis;
  113979. /** Gets or sets probe position (center of the cube map) */
  113980. position: Vector3;
  113981. /**
  113982. * Creates a new reflection probe
  113983. * @param name defines the name of the probe
  113984. * @param size defines the texture resolution (for each face)
  113985. * @param scene defines the hosting scene
  113986. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  113987. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  113988. */
  113989. constructor(
  113990. /** defines the name of the probe */
  113991. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  113992. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  113993. samples: number;
  113994. /** Gets or sets the refresh rate to use (on every frame by default) */
  113995. refreshRate: number;
  113996. /**
  113997. * Gets the hosting scene
  113998. * @returns a Scene
  113999. */
  114000. getScene(): Scene;
  114001. /** Gets the internal CubeTexture used to render to */
  114002. readonly cubeTexture: RenderTargetTexture;
  114003. /** Gets the list of meshes to render */
  114004. readonly renderList: Nullable<AbstractMesh[]>;
  114005. /**
  114006. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  114007. * @param mesh defines the mesh to attach to
  114008. */
  114009. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  114010. /**
  114011. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  114012. * @param renderingGroupId The rendering group id corresponding to its index
  114013. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  114014. */
  114015. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  114016. /**
  114017. * Clean all associated resources
  114018. */
  114019. dispose(): void;
  114020. /**
  114021. * Converts the reflection probe information to a readable string for debug purpose.
  114022. * @param fullDetails Supports for multiple levels of logging within scene loading
  114023. * @returns the human readable reflection probe info
  114024. */
  114025. toString(fullDetails?: boolean): string;
  114026. /**
  114027. * Get the class name of the relfection probe.
  114028. * @returns "ReflectionProbe"
  114029. */
  114030. getClassName(): string;
  114031. /**
  114032. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  114033. * @returns The JSON representation of the texture
  114034. */
  114035. serialize(): any;
  114036. /**
  114037. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  114038. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  114039. * @param scene Define the scene the parsed reflection probe should be instantiated in
  114040. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  114041. * @returns The parsed reflection probe if successful
  114042. */
  114043. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  114044. }
  114045. }
  114046. declare module BABYLON {
  114047. /** @hidden */
  114048. export var _BabylonLoaderRegistered: boolean;
  114049. }
  114050. declare module BABYLON {
  114051. /**
  114052. * The Physically based simple base material of BJS.
  114053. *
  114054. * This enables better naming and convention enforcements on top of the pbrMaterial.
  114055. * It is used as the base class for both the specGloss and metalRough conventions.
  114056. */
  114057. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  114058. /**
  114059. * Number of Simultaneous lights allowed on the material.
  114060. */
  114061. maxSimultaneousLights: number;
  114062. /**
  114063. * If sets to true, disables all the lights affecting the material.
  114064. */
  114065. disableLighting: boolean;
  114066. /**
  114067. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  114068. */
  114069. environmentTexture: BaseTexture;
  114070. /**
  114071. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  114072. */
  114073. invertNormalMapX: boolean;
  114074. /**
  114075. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  114076. */
  114077. invertNormalMapY: boolean;
  114078. /**
  114079. * Normal map used in the model.
  114080. */
  114081. normalTexture: BaseTexture;
  114082. /**
  114083. * Emissivie color used to self-illuminate the model.
  114084. */
  114085. emissiveColor: Color3;
  114086. /**
  114087. * Emissivie texture used to self-illuminate the model.
  114088. */
  114089. emissiveTexture: BaseTexture;
  114090. /**
  114091. * Occlusion Channel Strenght.
  114092. */
  114093. occlusionStrength: number;
  114094. /**
  114095. * Occlusion Texture of the material (adding extra occlusion effects).
  114096. */
  114097. occlusionTexture: BaseTexture;
  114098. /**
  114099. * Defines the alpha limits in alpha test mode.
  114100. */
  114101. alphaCutOff: number;
  114102. /**
  114103. * Gets the current double sided mode.
  114104. */
  114105. /**
  114106. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114107. */
  114108. doubleSided: boolean;
  114109. /**
  114110. * Stores the pre-calculated light information of a mesh in a texture.
  114111. */
  114112. lightmapTexture: BaseTexture;
  114113. /**
  114114. * If true, the light map contains occlusion information instead of lighting info.
  114115. */
  114116. useLightmapAsShadowmap: boolean;
  114117. /**
  114118. * Instantiates a new PBRMaterial instance.
  114119. *
  114120. * @param name The material name
  114121. * @param scene The scene the material will be use in.
  114122. */
  114123. constructor(name: string, scene: Scene);
  114124. getClassName(): string;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /**
  114129. * The PBR material of BJS following the metal roughness convention.
  114130. *
  114131. * This fits to the PBR convention in the GLTF definition:
  114132. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  114133. */
  114134. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  114135. /**
  114136. * The base color has two different interpretations depending on the value of metalness.
  114137. * When the material is a metal, the base color is the specific measured reflectance value
  114138. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  114139. * of the material.
  114140. */
  114141. baseColor: Color3;
  114142. /**
  114143. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  114144. * well as opacity information in the alpha channel.
  114145. */
  114146. baseTexture: BaseTexture;
  114147. /**
  114148. * Specifies the metallic scalar value of the material.
  114149. * Can also be used to scale the metalness values of the metallic texture.
  114150. */
  114151. metallic: number;
  114152. /**
  114153. * Specifies the roughness scalar value of the material.
  114154. * Can also be used to scale the roughness values of the metallic texture.
  114155. */
  114156. roughness: number;
  114157. /**
  114158. * Texture containing both the metallic value in the B channel and the
  114159. * roughness value in the G channel to keep better precision.
  114160. */
  114161. metallicRoughnessTexture: BaseTexture;
  114162. /**
  114163. * Instantiates a new PBRMetalRoughnessMaterial instance.
  114164. *
  114165. * @param name The material name
  114166. * @param scene The scene the material will be use in.
  114167. */
  114168. constructor(name: string, scene: Scene);
  114169. /**
  114170. * Return the currrent class name of the material.
  114171. */
  114172. getClassName(): string;
  114173. /**
  114174. * Makes a duplicate of the current material.
  114175. * @param name - name to use for the new material.
  114176. */
  114177. clone(name: string): PBRMetallicRoughnessMaterial;
  114178. /**
  114179. * Serialize the material to a parsable JSON object.
  114180. */
  114181. serialize(): any;
  114182. /**
  114183. * Parses a JSON object correponding to the serialize function.
  114184. */
  114185. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  114186. }
  114187. }
  114188. declare module BABYLON {
  114189. /**
  114190. * The PBR material of BJS following the specular glossiness convention.
  114191. *
  114192. * This fits to the PBR convention in the GLTF definition:
  114193. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  114194. */
  114195. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  114196. /**
  114197. * Specifies the diffuse color of the material.
  114198. */
  114199. diffuseColor: Color3;
  114200. /**
  114201. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  114202. * channel.
  114203. */
  114204. diffuseTexture: BaseTexture;
  114205. /**
  114206. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  114207. */
  114208. specularColor: Color3;
  114209. /**
  114210. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  114211. */
  114212. glossiness: number;
  114213. /**
  114214. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  114215. */
  114216. specularGlossinessTexture: BaseTexture;
  114217. /**
  114218. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  114219. *
  114220. * @param name The material name
  114221. * @param scene The scene the material will be use in.
  114222. */
  114223. constructor(name: string, scene: Scene);
  114224. /**
  114225. * Return the currrent class name of the material.
  114226. */
  114227. getClassName(): string;
  114228. /**
  114229. * Makes a duplicate of the current material.
  114230. * @param name - name to use for the new material.
  114231. */
  114232. clone(name: string): PBRSpecularGlossinessMaterial;
  114233. /**
  114234. * Serialize the material to a parsable JSON object.
  114235. */
  114236. serialize(): any;
  114237. /**
  114238. * Parses a JSON object correponding to the serialize function.
  114239. */
  114240. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  114241. }
  114242. }
  114243. declare module BABYLON {
  114244. /**
  114245. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  114246. * It can help converting any input color in a desired output one. This can then be used to create effects
  114247. * from sepia, black and white to sixties or futuristic rendering...
  114248. *
  114249. * The only supported format is currently 3dl.
  114250. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  114251. */
  114252. export class ColorGradingTexture extends BaseTexture {
  114253. /**
  114254. * The current texture matrix. (will always be identity in color grading texture)
  114255. */
  114256. private _textureMatrix;
  114257. /**
  114258. * The texture URL.
  114259. */
  114260. url: string;
  114261. /**
  114262. * Empty line regex stored for GC.
  114263. */
  114264. private static _noneEmptyLineRegex;
  114265. private _engine;
  114266. /**
  114267. * Instantiates a ColorGradingTexture from the following parameters.
  114268. *
  114269. * @param url The location of the color gradind data (currently only supporting 3dl)
  114270. * @param scene The scene the texture will be used in
  114271. */
  114272. constructor(url: string, scene: Scene);
  114273. /**
  114274. * Returns the texture matrix used in most of the material.
  114275. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  114276. */
  114277. getTextureMatrix(): Matrix;
  114278. /**
  114279. * Occurs when the file being loaded is a .3dl LUT file.
  114280. */
  114281. private load3dlTexture;
  114282. /**
  114283. * Starts the loading process of the texture.
  114284. */
  114285. private loadTexture;
  114286. /**
  114287. * Clones the color gradind texture.
  114288. */
  114289. clone(): ColorGradingTexture;
  114290. /**
  114291. * Called during delayed load for textures.
  114292. */
  114293. delayLoad(): void;
  114294. /**
  114295. * Parses a color grading texture serialized by Babylon.
  114296. * @param parsedTexture The texture information being parsedTexture
  114297. * @param scene The scene to load the texture in
  114298. * @param rootUrl The root url of the data assets to load
  114299. * @return A color gradind texture
  114300. */
  114301. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  114302. /**
  114303. * Serializes the LUT texture to json format.
  114304. */
  114305. serialize(): any;
  114306. }
  114307. }
  114308. declare module BABYLON {
  114309. /**
  114310. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  114311. */
  114312. export class EquiRectangularCubeTexture extends BaseTexture {
  114313. /** The six faces of the cube. */
  114314. private static _FacesMapping;
  114315. private _noMipmap;
  114316. private _onLoad;
  114317. private _onError;
  114318. /** The size of the cubemap. */
  114319. private _size;
  114320. /** The buffer of the image. */
  114321. private _buffer;
  114322. /** The width of the input image. */
  114323. private _width;
  114324. /** The height of the input image. */
  114325. private _height;
  114326. /** The URL to the image. */
  114327. url: string;
  114328. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  114329. coordinatesMode: number;
  114330. /**
  114331. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  114332. * @param url The location of the image
  114333. * @param scene The scene the texture will be used in
  114334. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  114335. * @param noMipmap Forces to not generate the mipmap if true
  114336. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114337. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114338. * @param onLoad — defines a callback called when texture is loaded
  114339. * @param onError — defines a callback called if there is an error
  114340. */
  114341. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  114342. /**
  114343. * Load the image data, by putting the image on a canvas and extracting its buffer.
  114344. */
  114345. private loadImage;
  114346. /**
  114347. * Convert the image buffer into a cubemap and create a CubeTexture.
  114348. */
  114349. private loadTexture;
  114350. /**
  114351. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  114352. * @param buffer The ArrayBuffer that should be converted.
  114353. * @returns The buffer as Float32Array.
  114354. */
  114355. private getFloat32ArrayFromArrayBuffer;
  114356. /**
  114357. * Get the current class name of the texture useful for serialization or dynamic coding.
  114358. * @returns "EquiRectangularCubeTexture"
  114359. */
  114360. getClassName(): string;
  114361. /**
  114362. * Create a clone of the current EquiRectangularCubeTexture and return it.
  114363. * @returns A clone of the current EquiRectangularCubeTexture.
  114364. */
  114365. clone(): EquiRectangularCubeTexture;
  114366. }
  114367. }
  114368. declare module BABYLON {
  114369. /**
  114370. * Based on jsTGALoader - Javascript loader for TGA file
  114371. * By Vincent Thibault
  114372. * @see http://blog.robrowser.com/javascript-tga-loader.html
  114373. */
  114374. export class TGATools {
  114375. private static _TYPE_INDEXED;
  114376. private static _TYPE_RGB;
  114377. private static _TYPE_GREY;
  114378. private static _TYPE_RLE_INDEXED;
  114379. private static _TYPE_RLE_RGB;
  114380. private static _TYPE_RLE_GREY;
  114381. private static _ORIGIN_MASK;
  114382. private static _ORIGIN_SHIFT;
  114383. private static _ORIGIN_BL;
  114384. private static _ORIGIN_BR;
  114385. private static _ORIGIN_UL;
  114386. private static _ORIGIN_UR;
  114387. /**
  114388. * Gets the header of a TGA file
  114389. * @param data defines the TGA data
  114390. * @returns the header
  114391. */
  114392. static GetTGAHeader(data: Uint8Array): any;
  114393. /**
  114394. * Uploads TGA content to a Babylon Texture
  114395. * @hidden
  114396. */
  114397. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  114398. /** @hidden */
  114399. 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;
  114400. /** @hidden */
  114401. 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;
  114402. /** @hidden */
  114403. 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;
  114404. /** @hidden */
  114405. 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;
  114406. /** @hidden */
  114407. 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;
  114408. /** @hidden */
  114409. 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;
  114410. }
  114411. }
  114412. declare module BABYLON {
  114413. /**
  114414. * Implementation of the TGA Texture Loader.
  114415. * @hidden
  114416. */
  114417. export class _TGATextureLoader implements IInternalTextureLoader {
  114418. /**
  114419. * Defines wether the loader supports cascade loading the different faces.
  114420. */
  114421. readonly supportCascades: boolean;
  114422. /**
  114423. * This returns if the loader support the current file information.
  114424. * @param extension defines the file extension of the file being loaded
  114425. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114426. * @param fallback defines the fallback internal texture if any
  114427. * @param isBase64 defines whether the texture is encoded as a base64
  114428. * @param isBuffer defines whether the texture data are stored as a buffer
  114429. * @returns true if the loader can load the specified file
  114430. */
  114431. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114432. /**
  114433. * Transform the url before loading if required.
  114434. * @param rootUrl the url of the texture
  114435. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114436. * @returns the transformed texture
  114437. */
  114438. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114439. /**
  114440. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114441. * @param rootUrl the url of the texture
  114442. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114443. * @returns the fallback texture
  114444. */
  114445. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114446. /**
  114447. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  114448. * @param data contains the texture data
  114449. * @param texture defines the BabylonJS internal texture
  114450. * @param createPolynomials will be true if polynomials have been requested
  114451. * @param onLoad defines the callback to trigger once the texture is ready
  114452. * @param onError defines the callback to trigger in case of error
  114453. */
  114454. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114455. /**
  114456. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114457. * @param data contains the texture data
  114458. * @param texture defines the BabylonJS internal texture
  114459. * @param callback defines the method to call once ready to upload
  114460. */
  114461. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114462. }
  114463. }
  114464. declare module BABYLON {
  114465. /**
  114466. * Info about the .basis files
  114467. */
  114468. class BasisFileInfo {
  114469. /**
  114470. * If the file has alpha
  114471. */
  114472. hasAlpha: boolean;
  114473. /**
  114474. * Info about each image of the basis file
  114475. */
  114476. images: Array<{
  114477. levels: Array<{
  114478. width: number;
  114479. height: number;
  114480. transcodedPixels: ArrayBufferView;
  114481. }>;
  114482. }>;
  114483. }
  114484. /**
  114485. * Result of transcoding a basis file
  114486. */
  114487. class TranscodeResult {
  114488. /**
  114489. * Info about the .basis file
  114490. */
  114491. fileInfo: BasisFileInfo;
  114492. /**
  114493. * Format to use when loading the file
  114494. */
  114495. format: number;
  114496. }
  114497. /**
  114498. * Configuration options for the Basis transcoder
  114499. */
  114500. export class BasisTranscodeConfiguration {
  114501. /**
  114502. * Supported compression formats used to determine the supported output format of the transcoder
  114503. */
  114504. supportedCompressionFormats?: {
  114505. /**
  114506. * etc1 compression format
  114507. */
  114508. etc1?: boolean;
  114509. /**
  114510. * s3tc compression format
  114511. */
  114512. s3tc?: boolean;
  114513. /**
  114514. * pvrtc compression format
  114515. */
  114516. pvrtc?: boolean;
  114517. /**
  114518. * etc2 compression format
  114519. */
  114520. etc2?: boolean;
  114521. };
  114522. /**
  114523. * If mipmap levels should be loaded for transcoded images (Default: true)
  114524. */
  114525. loadMipmapLevels?: boolean;
  114526. /**
  114527. * Index of a single image to load (Default: all images)
  114528. */
  114529. loadSingleImage?: number;
  114530. }
  114531. /**
  114532. * Used to load .Basis files
  114533. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  114534. */
  114535. export class BasisTools {
  114536. private static _IgnoreSupportedFormats;
  114537. /**
  114538. * URL to use when loading the basis transcoder
  114539. */
  114540. static JSModuleURL: string;
  114541. /**
  114542. * URL to use when loading the wasm module for the transcoder
  114543. */
  114544. static WasmModuleURL: string;
  114545. /**
  114546. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  114547. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  114548. * @returns internal format corresponding to the Basis format
  114549. */
  114550. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  114551. private static _WorkerPromise;
  114552. private static _Worker;
  114553. private static _actionId;
  114554. private static _CreateWorkerAsync;
  114555. /**
  114556. * Transcodes a loaded image file to compressed pixel data
  114557. * @param imageData image data to transcode
  114558. * @param config configuration options for the transcoding
  114559. * @returns a promise resulting in the transcoded image
  114560. */
  114561. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  114562. /**
  114563. * Loads a texture from the transcode result
  114564. * @param texture texture load to
  114565. * @param transcodeResult the result of transcoding the basis file to load from
  114566. */
  114567. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  114568. }
  114569. }
  114570. declare module BABYLON {
  114571. /**
  114572. * Loader for .basis file format
  114573. */
  114574. export class _BasisTextureLoader implements IInternalTextureLoader {
  114575. /**
  114576. * Defines whether the loader supports cascade loading the different faces.
  114577. */
  114578. readonly supportCascades: boolean;
  114579. /**
  114580. * This returns if the loader support the current file information.
  114581. * @param extension defines the file extension of the file being loaded
  114582. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114583. * @param fallback defines the fallback internal texture if any
  114584. * @param isBase64 defines whether the texture is encoded as a base64
  114585. * @param isBuffer defines whether the texture data are stored as a buffer
  114586. * @returns true if the loader can load the specified file
  114587. */
  114588. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  114589. /**
  114590. * Transform the url before loading if required.
  114591. * @param rootUrl the url of the texture
  114592. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114593. * @returns the transformed texture
  114594. */
  114595. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  114596. /**
  114597. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  114598. * @param rootUrl the url of the texture
  114599. * @param textureFormatInUse defines the current compressed format in use iun the engine
  114600. * @returns the fallback texture
  114601. */
  114602. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  114603. /**
  114604. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  114605. * @param data contains the texture data
  114606. * @param texture defines the BabylonJS internal texture
  114607. * @param createPolynomials will be true if polynomials have been requested
  114608. * @param onLoad defines the callback to trigger once the texture is ready
  114609. * @param onError defines the callback to trigger in case of error
  114610. */
  114611. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  114612. /**
  114613. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  114614. * @param data contains the texture data
  114615. * @param texture defines the BabylonJS internal texture
  114616. * @param callback defines the method to call once ready to upload
  114617. */
  114618. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  114619. }
  114620. }
  114621. declare module BABYLON {
  114622. /**
  114623. * 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.
  114624. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114625. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114626. */
  114627. export class CustomProceduralTexture extends ProceduralTexture {
  114628. private _animate;
  114629. private _time;
  114630. private _config;
  114631. private _texturePath;
  114632. /**
  114633. * Instantiates a new Custom Procedural Texture.
  114634. * 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.
  114635. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  114636. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  114637. * @param name Define the name of the texture
  114638. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  114639. * @param size Define the size of the texture to create
  114640. * @param scene Define the scene the texture belongs to
  114641. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  114642. * @param generateMipMaps Define if the texture should creates mip maps or not
  114643. */
  114644. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114645. private _loadJson;
  114646. /**
  114647. * Is the texture ready to be used ? (rendered at least once)
  114648. * @returns true if ready, otherwise, false.
  114649. */
  114650. isReady(): boolean;
  114651. /**
  114652. * Render the texture to its associated render target.
  114653. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  114654. */
  114655. render(useCameraPostProcess?: boolean): void;
  114656. /**
  114657. * Update the list of dependant textures samplers in the shader.
  114658. */
  114659. updateTextures(): void;
  114660. /**
  114661. * Update the uniform values of the procedural texture in the shader.
  114662. */
  114663. updateShaderUniforms(): void;
  114664. /**
  114665. * Define if the texture animates or not.
  114666. */
  114667. animate: boolean;
  114668. }
  114669. }
  114670. declare module BABYLON {
  114671. /** @hidden */
  114672. export var noisePixelShader: {
  114673. name: string;
  114674. shader: string;
  114675. };
  114676. }
  114677. declare module BABYLON {
  114678. /**
  114679. * Class used to generate noise procedural textures
  114680. */
  114681. export class NoiseProceduralTexture extends ProceduralTexture {
  114682. private _time;
  114683. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  114684. brightness: number;
  114685. /** Defines the number of octaves to process */
  114686. octaves: number;
  114687. /** Defines the level of persistence (0.8 by default) */
  114688. persistence: number;
  114689. /** Gets or sets animation speed factor (default is 1) */
  114690. animationSpeedFactor: number;
  114691. /**
  114692. * Creates a new NoiseProceduralTexture
  114693. * @param name defines the name fo the texture
  114694. * @param size defines the size of the texture (default is 256)
  114695. * @param scene defines the hosting scene
  114696. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  114697. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  114698. */
  114699. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  114700. private _updateShaderUniforms;
  114701. protected _getDefines(): string;
  114702. /** Generate the current state of the procedural texture */
  114703. render(useCameraPostProcess?: boolean): void;
  114704. /**
  114705. * Serializes this noise procedural texture
  114706. * @returns a serialized noise procedural texture object
  114707. */
  114708. serialize(): any;
  114709. /**
  114710. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  114711. * @param parsedTexture defines parsed texture data
  114712. * @param scene defines the current scene
  114713. * @param rootUrl defines the root URL containing noise procedural texture information
  114714. * @returns a parsed NoiseProceduralTexture
  114715. */
  114716. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  114717. }
  114718. }
  114719. declare module BABYLON {
  114720. /**
  114721. * Raw cube texture where the raw buffers are passed in
  114722. */
  114723. export class RawCubeTexture extends CubeTexture {
  114724. /**
  114725. * Creates a cube texture where the raw buffers are passed in.
  114726. * @param scene defines the scene the texture is attached to
  114727. * @param data defines the array of data to use to create each face
  114728. * @param size defines the size of the textures
  114729. * @param format defines the format of the data
  114730. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  114731. * @param generateMipMaps defines if the engine should generate the mip levels
  114732. * @param invertY defines if data must be stored with Y axis inverted
  114733. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  114734. * @param compression defines the compression used (null by default)
  114735. */
  114736. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  114737. /**
  114738. * Updates the raw cube texture.
  114739. * @param data defines the data to store
  114740. * @param format defines the data format
  114741. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  114742. * @param invertY defines if data must be stored with Y axis inverted
  114743. * @param compression defines the compression used (null by default)
  114744. * @param level defines which level of the texture to update
  114745. */
  114746. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  114747. /**
  114748. * Updates a raw cube texture with RGBD encoded data.
  114749. * @param data defines the array of data [mipmap][face] to use to create each face
  114750. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  114751. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  114752. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  114753. * @returns a promsie that resolves when the operation is complete
  114754. */
  114755. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  114756. /**
  114757. * Clones the raw cube texture.
  114758. * @return a new cube texture
  114759. */
  114760. clone(): CubeTexture;
  114761. /** @hidden */
  114762. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  114763. }
  114764. }
  114765. declare module BABYLON {
  114766. /**
  114767. * Class used to store 3D textures containing user data
  114768. */
  114769. export class RawTexture3D extends Texture {
  114770. /** Gets or sets the texture format to use */
  114771. format: number;
  114772. private _engine;
  114773. /**
  114774. * Create a new RawTexture3D
  114775. * @param data defines the data of the texture
  114776. * @param width defines the width of the texture
  114777. * @param height defines the height of the texture
  114778. * @param depth defines the depth of the texture
  114779. * @param format defines the texture format to use
  114780. * @param scene defines the hosting scene
  114781. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  114782. * @param invertY defines if texture must be stored with Y axis inverted
  114783. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114784. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  114785. */
  114786. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  114787. /** Gets or sets the texture format to use */
  114788. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  114789. /**
  114790. * Update the texture with new data
  114791. * @param data defines the data to store in the texture
  114792. */
  114793. update(data: ArrayBufferView): void;
  114794. }
  114795. }
  114796. declare module BABYLON {
  114797. /**
  114798. * Creates a refraction texture used by refraction channel of the standard material.
  114799. * It is like a mirror but to see through a material.
  114800. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114801. */
  114802. export class RefractionTexture extends RenderTargetTexture {
  114803. /**
  114804. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  114805. * 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.
  114806. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114807. */
  114808. refractionPlane: Plane;
  114809. /**
  114810. * Define how deep under the surface we should see.
  114811. */
  114812. depth: number;
  114813. /**
  114814. * Creates a refraction texture used by refraction channel of the standard material.
  114815. * It is like a mirror but to see through a material.
  114816. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  114817. * @param name Define the texture name
  114818. * @param size Define the size of the underlying texture
  114819. * @param scene Define the scene the refraction belongs to
  114820. * @param generateMipMaps Define if we need to generate mips level for the refraction
  114821. */
  114822. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  114823. /**
  114824. * Clone the refraction texture.
  114825. * @returns the cloned texture
  114826. */
  114827. clone(): RefractionTexture;
  114828. /**
  114829. * Serialize the texture to a JSON representation you could use in Parse later on
  114830. * @returns the serialized JSON representation
  114831. */
  114832. serialize(): any;
  114833. }
  114834. }
  114835. declare module BABYLON {
  114836. /**
  114837. * Defines the options related to the creation of an HtmlElementTexture
  114838. */
  114839. export interface IHtmlElementTextureOptions {
  114840. /**
  114841. * Defines wether mip maps should be created or not.
  114842. */
  114843. generateMipMaps?: boolean;
  114844. /**
  114845. * Defines the sampling mode of the texture.
  114846. */
  114847. samplingMode?: number;
  114848. /**
  114849. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  114850. */
  114851. engine: Nullable<Engine>;
  114852. /**
  114853. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  114854. */
  114855. scene: Nullable<Scene>;
  114856. }
  114857. /**
  114858. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  114859. * To be as efficient as possible depending on your constraints nothing aside the first upload
  114860. * is automatically managed.
  114861. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  114862. * in your application.
  114863. *
  114864. * As the update is not automatic, you need to call them manually.
  114865. */
  114866. export class HtmlElementTexture extends BaseTexture {
  114867. /**
  114868. * The texture URL.
  114869. */
  114870. element: HTMLVideoElement | HTMLCanvasElement;
  114871. private static readonly DefaultOptions;
  114872. private _textureMatrix;
  114873. private _engine;
  114874. private _isVideo;
  114875. private _generateMipMaps;
  114876. private _samplingMode;
  114877. /**
  114878. * Instantiates a HtmlElementTexture from the following parameters.
  114879. *
  114880. * @param name Defines the name of the texture
  114881. * @param element Defines the video or canvas the texture is filled with
  114882. * @param options Defines the other none mandatory texture creation options
  114883. */
  114884. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  114885. private _createInternalTexture;
  114886. /**
  114887. * Returns the texture matrix used in most of the material.
  114888. */
  114889. getTextureMatrix(): Matrix;
  114890. /**
  114891. * Updates the content of the texture.
  114892. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  114893. */
  114894. update(invertY?: Nullable<boolean>): void;
  114895. }
  114896. }
  114897. declare module BABYLON {
  114898. /**
  114899. * Enum used to define the target of a block
  114900. */
  114901. export enum NodeMaterialBlockTargets {
  114902. /** Vertex shader */
  114903. Vertex = 1,
  114904. /** Fragment shader */
  114905. Fragment = 2,
  114906. /** Neutral */
  114907. Neutral = 4,
  114908. /** Vertex and Fragment */
  114909. VertexAndFragment = 3
  114910. }
  114911. }
  114912. declare module BABYLON {
  114913. /**
  114914. * Defines the kind of connection point for node based material
  114915. */
  114916. export enum NodeMaterialBlockConnectionPointTypes {
  114917. /** Float */
  114918. Float = 1,
  114919. /** Int */
  114920. Int = 2,
  114921. /** Vector2 */
  114922. Vector2 = 4,
  114923. /** Vector3 */
  114924. Vector3 = 8,
  114925. /** Vector4 */
  114926. Vector4 = 16,
  114927. /** Color3 */
  114928. Color3 = 32,
  114929. /** Color4 */
  114930. Color4 = 64,
  114931. /** Matrix */
  114932. Matrix = 128,
  114933. /** Vector3 or Color3 */
  114934. Vector3OrColor3 = 40,
  114935. /** Vector3 or Vector4 */
  114936. Vector3OrVector4 = 24,
  114937. /** Vector4 or Color4 */
  114938. Vector4OrColor4 = 80,
  114939. /** Color3 or Color4 */
  114940. Color3OrColor4 = 96,
  114941. /** Vector2 or Color3 or Color4 */
  114942. Vector2OrColor3OrColor4 = 100,
  114943. /** Vector3 or Color3 or Color4 or Vector4 */
  114944. Vector3OrColor3OrVector4OrColor4 = 120,
  114945. /** Vector2 or Vector3 or Color3 or Color4 or Vector4 */
  114946. Vector2OrVector3OrColor3OrVector4OrColor4 = 124,
  114947. /** Detect type based on connection */
  114948. AutoDetect = 1024,
  114949. /** Output type that will be defined by input type */
  114950. BasedOnInput = 2048
  114951. }
  114952. }
  114953. declare module BABYLON {
  114954. /**
  114955. * Root class for all node material optimizers
  114956. */
  114957. export class NodeMaterialOptimizer {
  114958. /**
  114959. * Function used to optimize a NodeMaterial graph
  114960. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  114961. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  114962. */
  114963. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  114964. }
  114965. }
  114966. declare module BABYLON {
  114967. /**
  114968. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  114969. */
  114970. export class TransformBlock extends NodeMaterialBlock {
  114971. /**
  114972. * Defines the value to use to complement W value to transform it to a Vector4
  114973. */
  114974. complementW: number;
  114975. /**
  114976. * Defines the value to use to complement z value to transform it to a Vector4
  114977. */
  114978. complementZ: number;
  114979. /**
  114980. * Creates a new TransformBlock
  114981. * @param name defines the block name
  114982. */
  114983. constructor(name: string);
  114984. /**
  114985. * Gets the current class name
  114986. * @returns the class name
  114987. */
  114988. getClassName(): string;
  114989. /**
  114990. * Gets the vector input
  114991. */
  114992. readonly vector: NodeMaterialConnectionPoint;
  114993. /**
  114994. * Gets the output component
  114995. */
  114996. readonly output: NodeMaterialConnectionPoint;
  114997. /**
  114998. * Gets the matrix transform input
  114999. */
  115000. readonly transform: NodeMaterialConnectionPoint;
  115001. protected _buildBlock(state: NodeMaterialBuildState): this;
  115002. }
  115003. }
  115004. declare module BABYLON {
  115005. /**
  115006. * Block used to output the vertex position
  115007. */
  115008. export class VertexOutputBlock extends NodeMaterialBlock {
  115009. /**
  115010. * Creates a new VertexOutputBlock
  115011. * @param name defines the block name
  115012. */
  115013. constructor(name: string);
  115014. /**
  115015. * Gets the current class name
  115016. * @returns the class name
  115017. */
  115018. getClassName(): string;
  115019. /**
  115020. * Gets the vector input component
  115021. */
  115022. readonly vector: NodeMaterialConnectionPoint;
  115023. protected _buildBlock(state: NodeMaterialBuildState): this;
  115024. }
  115025. }
  115026. declare module BABYLON {
  115027. /**
  115028. * Block used to output the final color
  115029. */
  115030. export class FragmentOutputBlock extends NodeMaterialBlock {
  115031. /**
  115032. * Gets or sets a boolean indicating if this block will output an alpha value
  115033. */
  115034. alphaBlendingEnabled: boolean;
  115035. /**
  115036. * Create a new FragmentOutputBlock
  115037. * @param name defines the block name
  115038. */
  115039. constructor(name: string);
  115040. /**
  115041. * Gets the current class name
  115042. * @returns the class name
  115043. */
  115044. getClassName(): string;
  115045. /**
  115046. * Gets the rgba input component
  115047. */
  115048. readonly rgba: NodeMaterialConnectionPoint;
  115049. /**
  115050. * Gets the rgb input component
  115051. */
  115052. readonly rgb: NodeMaterialConnectionPoint;
  115053. /**
  115054. * Gets the a input component
  115055. */
  115056. readonly a: NodeMaterialConnectionPoint;
  115057. protected _buildBlock(state: NodeMaterialBuildState): this;
  115058. }
  115059. }
  115060. declare module BABYLON {
  115061. /**
  115062. * Interface used to configure the node material editor
  115063. */
  115064. export interface INodeMaterialEditorOptions {
  115065. /** Define the URl to load node editor script */
  115066. editorURL?: string;
  115067. }
  115068. /** @hidden */
  115069. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  115070. /** BONES */
  115071. NUM_BONE_INFLUENCERS: number;
  115072. BonesPerMesh: number;
  115073. BONETEXTURE: boolean;
  115074. /** MORPH TARGETS */
  115075. MORPHTARGETS: boolean;
  115076. MORPHTARGETS_NORMAL: boolean;
  115077. MORPHTARGETS_TANGENT: boolean;
  115078. MORPHTARGETS_UV: boolean;
  115079. NUM_MORPH_INFLUENCERS: number;
  115080. /** IMAGE PROCESSING */
  115081. IMAGEPROCESSING: boolean;
  115082. VIGNETTE: boolean;
  115083. VIGNETTEBLENDMODEMULTIPLY: boolean;
  115084. VIGNETTEBLENDMODEOPAQUE: boolean;
  115085. TONEMAPPING: boolean;
  115086. TONEMAPPING_ACES: boolean;
  115087. CONTRAST: boolean;
  115088. EXPOSURE: boolean;
  115089. COLORCURVES: boolean;
  115090. COLORGRADING: boolean;
  115091. COLORGRADING3D: boolean;
  115092. SAMPLER3DGREENDEPTH: boolean;
  115093. SAMPLER3DBGRMAP: boolean;
  115094. IMAGEPROCESSINGPOSTPROCESS: boolean;
  115095. constructor();
  115096. setValue(name: string, value: boolean): void;
  115097. }
  115098. /**
  115099. * Class used to configure NodeMaterial
  115100. */
  115101. export interface INodeMaterialOptions {
  115102. /**
  115103. * Defines if blocks should emit comments
  115104. */
  115105. emitComments: boolean;
  115106. }
  115107. /**
  115108. * Class used to create a node based material built by assembling shader blocks
  115109. */
  115110. export class NodeMaterial extends PushMaterial {
  115111. private _options;
  115112. private _vertexCompilationState;
  115113. private _fragmentCompilationState;
  115114. private _sharedData;
  115115. private _buildId;
  115116. private _buildWasSuccessful;
  115117. private _cachedWorldViewMatrix;
  115118. private _cachedWorldViewProjectionMatrix;
  115119. private _optimizers;
  115120. /** Define the URl to load node editor script */
  115121. static EditorURL: string;
  115122. private BJSNODEMATERIALEDITOR;
  115123. /** Get the inspector from bundle or global */
  115124. private _getGlobalNodeMaterialEditor;
  115125. /**
  115126. * Defines the maximum number of lights that can be used in the material
  115127. */
  115128. maxSimultaneousLights: number;
  115129. /**
  115130. * Observable raised when the material is built
  115131. */
  115132. onBuildObservable: Observable<NodeMaterial>;
  115133. /**
  115134. * Gets or sets the root nodes of the material vertex shader
  115135. */
  115136. _vertexOutputNodes: NodeMaterialBlock[];
  115137. /**
  115138. * Gets or sets the root nodes of the material fragment (pixel) shader
  115139. */
  115140. _fragmentOutputNodes: NodeMaterialBlock[];
  115141. /** Gets or sets options to control the node material overall behavior */
  115142. options: INodeMaterialOptions;
  115143. /**
  115144. * Default configuration related to image processing available in the standard Material.
  115145. */
  115146. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115147. /**
  115148. * Gets the image processing configuration used either in this material.
  115149. */
  115150. /**
  115151. * Sets the Default image processing configuration used either in the this material.
  115152. *
  115153. * If sets to null, the scene one is in use.
  115154. */
  115155. imageProcessingConfiguration: ImageProcessingConfiguration;
  115156. /**
  115157. * Create a new node based material
  115158. * @param name defines the material name
  115159. * @param scene defines the hosting scene
  115160. * @param options defines creation option
  115161. */
  115162. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  115163. /**
  115164. * Gets the current class name of the material e.g. "NodeMaterial"
  115165. * @returns the class name
  115166. */
  115167. getClassName(): string;
  115168. /**
  115169. * Keep track of the image processing observer to allow dispose and replace.
  115170. */
  115171. private _imageProcessingObserver;
  115172. /**
  115173. * Attaches a new image processing configuration to the Standard Material.
  115174. * @param configuration
  115175. */
  115176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  115177. /**
  115178. * Adds a new optimizer to the list of optimizers
  115179. * @param optimizer defines the optimizers to add
  115180. * @returns the current material
  115181. */
  115182. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115183. /**
  115184. * Remove an optimizer from the list of optimizers
  115185. * @param optimizer defines the optimizers to remove
  115186. * @returns the current material
  115187. */
  115188. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  115189. /**
  115190. * Add a new block to the list of output nodes
  115191. * @param node defines the node to add
  115192. * @returns the current material
  115193. */
  115194. addOutputNode(node: NodeMaterialBlock): this;
  115195. /**
  115196. * Remove a block from the list of root nodes
  115197. * @param node defines the node to remove
  115198. * @returns the current material
  115199. */
  115200. removeOutputNode(node: NodeMaterialBlock): this;
  115201. private _addVertexOutputNode;
  115202. private _removeVertexOutputNode;
  115203. private _addFragmentOutputNode;
  115204. private _removeFragmentOutputNode;
  115205. /**
  115206. * Specifies if the material will require alpha blending
  115207. * @returns a boolean specifying if alpha blending is needed
  115208. */
  115209. needAlphaBlending(): boolean;
  115210. /**
  115211. * Specifies if this material should be rendered in alpha test mode
  115212. * @returns a boolean specifying if an alpha test is needed.
  115213. */
  115214. needAlphaTesting(): boolean;
  115215. private _initializeBlock;
  115216. private _resetDualBlocks;
  115217. /**
  115218. * Build the material and generates the inner effect
  115219. * @param verbose defines if the build should log activity
  115220. */
  115221. build(verbose?: boolean): void;
  115222. /**
  115223. * Runs an otpimization phase to try to improve the shader code
  115224. */
  115225. optimize(): void;
  115226. private _prepareDefinesForAttributes;
  115227. /**
  115228. * Get if the submesh is ready to be used and all its information available.
  115229. * Child classes can use it to update shaders
  115230. * @param mesh defines the mesh to check
  115231. * @param subMesh defines which submesh to check
  115232. * @param useInstances specifies that instances should be used
  115233. * @returns a boolean indicating that the submesh is ready or not
  115234. */
  115235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  115236. /**
  115237. * Get a string representing the shaders built by the current node graph
  115238. */
  115239. readonly compiledShaders: string;
  115240. /**
  115241. * Binds the world matrix to the material
  115242. * @param world defines the world transformation matrix
  115243. */
  115244. bindOnlyWorldMatrix(world: Matrix): void;
  115245. /**
  115246. * Binds the submesh to this material by preparing the effect and shader to draw
  115247. * @param world defines the world transformation matrix
  115248. * @param mesh defines the mesh containing the submesh
  115249. * @param subMesh defines the submesh to bind the material to
  115250. */
  115251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  115252. /**
  115253. * Gets the active textures from the material
  115254. * @returns an array of textures
  115255. */
  115256. getActiveTextures(): BaseTexture[];
  115257. /**
  115258. * Specifies if the material uses a texture
  115259. * @param texture defines the texture to check against the material
  115260. * @returns a boolean specifying if the material uses the texture
  115261. */
  115262. hasTexture(texture: BaseTexture): boolean;
  115263. /**
  115264. * Disposes the material
  115265. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  115266. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  115267. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  115268. */
  115269. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  115270. /** Creates the node editor window. */
  115271. private _createNodeEditor;
  115272. /**
  115273. * Launch the node material editor
  115274. * @param config Define the configuration of the editor
  115275. * @return a promise fulfilled when the node editor is visible
  115276. */
  115277. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  115278. /**
  115279. * Clear the current material
  115280. */
  115281. clear(): void;
  115282. /**
  115283. * Clear the current material and set it to a default state
  115284. */
  115285. setToDefault(): void;
  115286. private _gatherBlocks;
  115287. /**
  115288. * Serializes this material in a JSON representation
  115289. * @returns the serialized material object
  115290. */
  115291. serialize(): any;
  115292. /**
  115293. * Clear the current graph and load a new one from a serialization object
  115294. * @param source defines the JSON representation of the material
  115295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115296. */
  115297. loadFromSerialization(source: any, rootUrl?: string): void;
  115298. /**
  115299. * Creates a node material from parsed material data
  115300. * @param source defines the JSON representation of the material
  115301. * @param scene defines the hosting scene
  115302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  115303. * @returns a new node material
  115304. */
  115305. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  115306. }
  115307. }
  115308. declare module BABYLON {
  115309. /**
  115310. * Block used to read a texture from a sampler
  115311. */
  115312. export class TextureBlock extends NodeMaterialBlock {
  115313. private _defineName;
  115314. private _samplerName;
  115315. private _transformedUVName;
  115316. private _textureTransformName;
  115317. private _textureInfoName;
  115318. private _mainUVName;
  115319. private _mainUVDefineName;
  115320. /**
  115321. * Gets or sets the texture associated with the node
  115322. */
  115323. texture: Nullable<BaseTexture>;
  115324. /**
  115325. * Create a new TextureBlock
  115326. * @param name defines the block name
  115327. */
  115328. constructor(name: string);
  115329. /**
  115330. * Gets the current class name
  115331. * @returns the class name
  115332. */
  115333. getClassName(): string;
  115334. /**
  115335. * Gets the uv input component
  115336. */
  115337. readonly uv: NodeMaterialConnectionPoint;
  115338. /**
  115339. * Gets the output component
  115340. */
  115341. readonly output: NodeMaterialConnectionPoint;
  115342. autoConfigure(): void;
  115343. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115345. isReady(): boolean;
  115346. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115347. private _injectVertexCode;
  115348. private _writeOutput;
  115349. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  115350. serialize(): any;
  115351. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115352. }
  115353. }
  115354. declare module BABYLON {
  115355. /**
  115356. * Class used to store shared data between 2 NodeMaterialBuildState
  115357. */
  115358. export class NodeMaterialBuildStateSharedData {
  115359. /**
  115360. * Gets the list of emitted varyings
  115361. */
  115362. varyings: string[];
  115363. /**
  115364. * Gets the varying declaration string
  115365. */
  115366. varyingDeclaration: string;
  115367. /**
  115368. * Input blocks
  115369. */
  115370. inputBlocks: InputBlock[];
  115371. /**
  115372. * Input blocks
  115373. */
  115374. textureBlocks: TextureBlock[];
  115375. /**
  115376. * Bindable blocks (Blocks that need to set data to the effect)
  115377. */
  115378. bindableBlocks: NodeMaterialBlock[];
  115379. /**
  115380. * List of blocks that can provide a compilation fallback
  115381. */
  115382. blocksWithFallbacks: NodeMaterialBlock[];
  115383. /**
  115384. * List of blocks that can provide a define update
  115385. */
  115386. blocksWithDefines: NodeMaterialBlock[];
  115387. /**
  115388. * List of blocks that can provide a repeatable content
  115389. */
  115390. repeatableContentBlocks: NodeMaterialBlock[];
  115391. /**
  115392. * List of blocks that can provide a dynamic list of uniforms
  115393. */
  115394. dynamicUniformBlocks: NodeMaterialBlock[];
  115395. /**
  115396. * List of blocks that can block the isReady function for the material
  115397. */
  115398. blockingBlocks: NodeMaterialBlock[];
  115399. /**
  115400. * Build Id used to avoid multiple recompilations
  115401. */
  115402. buildId: number;
  115403. /** List of emitted variables */
  115404. variableNames: {
  115405. [key: string]: number;
  115406. };
  115407. /** List of emitted defines */
  115408. defineNames: {
  115409. [key: string]: number;
  115410. };
  115411. /** Should emit comments? */
  115412. emitComments: boolean;
  115413. /** Emit build activity */
  115414. verbose: boolean;
  115415. /**
  115416. * Gets the compilation hints emitted at compilation time
  115417. */
  115418. hints: {
  115419. needWorldViewMatrix: boolean;
  115420. needWorldViewProjectionMatrix: boolean;
  115421. needAlphaBlending: boolean;
  115422. needAlphaTesting: boolean;
  115423. };
  115424. /**
  115425. * List of compilation checks
  115426. */
  115427. checks: {
  115428. emitVertex: boolean;
  115429. emitFragment: boolean;
  115430. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  115431. };
  115432. /** Creates a new shared data */
  115433. constructor();
  115434. /**
  115435. * Emits console errors and exceptions if there is a failing check
  115436. */
  115437. emitErrors(): void;
  115438. }
  115439. }
  115440. declare module BABYLON {
  115441. /**
  115442. * Class used to store node based material build state
  115443. */
  115444. export class NodeMaterialBuildState {
  115445. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  115446. supportUniformBuffers: boolean;
  115447. /**
  115448. * Gets the list of emitted attributes
  115449. */
  115450. attributes: string[];
  115451. /**
  115452. * Gets the list of emitted uniforms
  115453. */
  115454. uniforms: string[];
  115455. /**
  115456. * Gets the list of emitted uniform buffers
  115457. */
  115458. uniformBuffers: string[];
  115459. /**
  115460. * Gets the list of emitted samplers
  115461. */
  115462. samplers: string[];
  115463. /**
  115464. * Gets the list of emitted functions
  115465. */
  115466. functions: {
  115467. [key: string]: string;
  115468. };
  115469. /**
  115470. * Gets the target of the compilation state
  115471. */
  115472. target: NodeMaterialBlockTargets;
  115473. /**
  115474. * Gets the list of emitted counters
  115475. */
  115476. counters: {
  115477. [key: string]: number;
  115478. };
  115479. /**
  115480. * Shared data between multiple NodeMaterialBuildState instances
  115481. */
  115482. sharedData: NodeMaterialBuildStateSharedData;
  115483. /** @hidden */
  115484. _vertexState: NodeMaterialBuildState;
  115485. /** @hidden */
  115486. _attributeDeclaration: string;
  115487. /** @hidden */
  115488. _uniformDeclaration: string;
  115489. /** @hidden */
  115490. _samplerDeclaration: string;
  115491. /** @hidden */
  115492. _varyingTransfer: string;
  115493. private _repeatableContentAnchorIndex;
  115494. /** @hidden */
  115495. _builtCompilationString: string;
  115496. /**
  115497. * Gets the emitted compilation strings
  115498. */
  115499. compilationString: string;
  115500. /**
  115501. * Finalize the compilation strings
  115502. * @param state defines the current compilation state
  115503. */
  115504. finalize(state: NodeMaterialBuildState): void;
  115505. /** @hidden */
  115506. readonly _repeatableContentAnchor: string;
  115507. /** @hidden */
  115508. _getFreeVariableName(prefix: string): string;
  115509. /** @hidden */
  115510. _getFreeDefineName(prefix: string): string;
  115511. /** @hidden */
  115512. _excludeVariableName(name: string): void;
  115513. /** @hidden */
  115514. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  115515. /** @hidden */
  115516. _emitFunction(name: string, code: string, comments: string): void;
  115517. /** @hidden */
  115518. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  115519. replaceStrings?: {
  115520. search: RegExp;
  115521. replace: string;
  115522. }[];
  115523. repeatKey?: string;
  115524. }): string;
  115525. /** @hidden */
  115526. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  115527. repeatKey?: string;
  115528. removeAttributes?: boolean;
  115529. removeUniforms?: boolean;
  115530. removeVaryings?: boolean;
  115531. removeIfDef?: boolean;
  115532. replaceStrings?: {
  115533. search: RegExp;
  115534. replace: string;
  115535. }[];
  115536. }, storeKey?: string): void;
  115537. /** @hidden */
  115538. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115539. /** @hidden */
  115540. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  115541. }
  115542. }
  115543. declare module BABYLON {
  115544. /**
  115545. * Defines a block that can be used inside a node based material
  115546. */
  115547. export class NodeMaterialBlock {
  115548. private _buildId;
  115549. private _buildTarget;
  115550. private _target;
  115551. private _isFinalMerger;
  115552. private _isInput;
  115553. /** @hidden */
  115554. _inputs: NodeMaterialConnectionPoint[];
  115555. /** @hidden */
  115556. _outputs: NodeMaterialConnectionPoint[];
  115557. /**
  115558. * Gets or sets the name of the block
  115559. */
  115560. name: string;
  115561. /**
  115562. * Gets or sets the unique id of the node
  115563. */
  115564. uniqueId: number;
  115565. /**
  115566. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  115567. */
  115568. readonly isFinalMerger: boolean;
  115569. /**
  115570. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  115571. */
  115572. readonly isInput: boolean;
  115573. /**
  115574. * Gets or sets the build Id
  115575. */
  115576. buildId: number;
  115577. /**
  115578. * Gets or sets the target of the block
  115579. */
  115580. target: NodeMaterialBlockTargets;
  115581. /**
  115582. * Gets the list of input points
  115583. */
  115584. readonly inputs: NodeMaterialConnectionPoint[];
  115585. /** Gets the list of output points */
  115586. readonly outputs: NodeMaterialConnectionPoint[];
  115587. /**
  115588. * Find an input by its name
  115589. * @param name defines the name of the input to look for
  115590. * @returns the input or null if not found
  115591. */
  115592. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115593. /**
  115594. * Find an output by its name
  115595. * @param name defines the name of the outputto look for
  115596. * @returns the output or null if not found
  115597. */
  115598. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  115599. /**
  115600. * Creates a new NodeMaterialBlock
  115601. * @param name defines the block name
  115602. * @param target defines the target of that block (Vertex by default)
  115603. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  115604. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  115605. */
  115606. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  115607. /**
  115608. * Initialize the block and prepare the context for build
  115609. * @param state defines the state that will be used for the build
  115610. */
  115611. initialize(state: NodeMaterialBuildState): void;
  115612. /**
  115613. * Bind data to effect. Will only be called for blocks with isBindable === true
  115614. * @param effect defines the effect to bind data to
  115615. * @param nodeMaterial defines the hosting NodeMaterial
  115616. * @param mesh defines the mesh that will be rendered
  115617. */
  115618. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  115619. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  115620. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  115621. protected _writeFloat(value: number): string;
  115622. /**
  115623. * Gets the current class name e.g. "NodeMaterialBlock"
  115624. * @returns the class name
  115625. */
  115626. getClassName(): string;
  115627. /**
  115628. * Register a new input. Must be called inside a block constructor
  115629. * @param name defines the connection point name
  115630. * @param type defines the connection point type
  115631. * @param isOptional defines a boolean indicating that this input can be omitted
  115632. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115633. * @returns the current block
  115634. */
  115635. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  115636. /**
  115637. * Register a new output. Must be called inside a block constructor
  115638. * @param name defines the connection point name
  115639. * @param type defines the connection point type
  115640. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  115641. * @returns the current block
  115642. */
  115643. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  115644. /**
  115645. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  115646. * @param forOutput defines an optional connection point to check compatibility with
  115647. * @returns the first available input or null
  115648. */
  115649. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  115650. /**
  115651. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  115652. * @param forBlock defines an optional block to check compatibility with
  115653. * @returns the first available input or null
  115654. */
  115655. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  115656. /**
  115657. * Connect current block with another block
  115658. * @param other defines the block to connect with
  115659. * @param options define the various options to help pick the right connections
  115660. * @returns the current block
  115661. */
  115662. connectTo(other: NodeMaterialBlock, options?: {
  115663. input?: string;
  115664. output?: string;
  115665. outputSwizzle?: string;
  115666. }): this | undefined;
  115667. protected _buildBlock(state: NodeMaterialBuildState): void;
  115668. /**
  115669. * Add uniforms, samplers and uniform buffers at compilation time
  115670. * @param state defines the state to update
  115671. * @param nodeMaterial defines the node material requesting the update
  115672. * @param defines defines the material defines to update
  115673. */
  115674. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  115675. /**
  115676. * Add potential fallbacks if shader compilation fails
  115677. * @param mesh defines the mesh to be rendered
  115678. * @param fallbacks defines the current prioritized list of fallbacks
  115679. */
  115680. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  115681. /**
  115682. * Update defines for shader compilation
  115683. * @param mesh defines the mesh to be rendered
  115684. * @param nodeMaterial defines the node material requesting the update
  115685. * @param defines defines the material defines to update
  115686. * @param useInstances specifies that instances should be used
  115687. */
  115688. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115689. /**
  115690. * Initialize defines for shader compilation
  115691. * @param mesh defines the mesh to be rendered
  115692. * @param nodeMaterial defines the node material requesting the update
  115693. * @param defines defines the material defines to be prepared
  115694. * @param useInstances specifies that instances should be used
  115695. */
  115696. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  115697. /**
  115698. * Lets the block try to connect some inputs automatically
  115699. */
  115700. autoConfigure(): void;
  115701. /**
  115702. * Function called when a block is declared as repeatable content generator
  115703. * @param vertexShaderState defines the current compilation state for the vertex shader
  115704. * @param fragmentShaderState defines the current compilation state for the fragment shader
  115705. * @param mesh defines the mesh to be rendered
  115706. * @param defines defines the material defines to update
  115707. */
  115708. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  115709. /**
  115710. * Checks if the block is ready
  115711. * @param mesh defines the mesh to be rendered
  115712. * @param nodeMaterial defines the node material requesting the update
  115713. * @param defines defines the material defines to update
  115714. * @param useInstances specifies that instances should be used
  115715. * @returns true if the block is ready
  115716. */
  115717. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  115718. private _processBuild;
  115719. /**
  115720. * Compile the current node and generate the shader code
  115721. * @param state defines the current compilation state (uniforms, samplers, current string)
  115722. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  115723. * @returns true if already built
  115724. */
  115725. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  115726. /**
  115727. * Serializes this block in a JSON representation
  115728. * @returns the serialized block object
  115729. */
  115730. serialize(): any;
  115731. /** @hidden */
  115732. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115733. }
  115734. }
  115735. declare module BABYLON {
  115736. /**
  115737. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  115738. */
  115739. export enum NodeMaterialBlockConnectionPointMode {
  115740. /** Value is an uniform */
  115741. Uniform = 0,
  115742. /** Value is a mesh attribute */
  115743. Attribute = 1,
  115744. /** Value is a varying between vertex and fragment shaders */
  115745. Varying = 2,
  115746. /** Mode is undefined */
  115747. Undefined = 3
  115748. }
  115749. }
  115750. declare module BABYLON {
  115751. /**
  115752. * Enum used to define well known values e.g. values automatically provided by the system
  115753. */
  115754. export enum NodeMaterialWellKnownValues {
  115755. /** World */
  115756. World = 1,
  115757. /** View */
  115758. View = 2,
  115759. /** Projection */
  115760. Projection = 3,
  115761. /** ViewProjection */
  115762. ViewProjection = 4,
  115763. /** WorldView */
  115764. WorldView = 5,
  115765. /** WorldViewProjection */
  115766. WorldViewProjection = 6,
  115767. /** CameraPosition */
  115768. CameraPosition = 7,
  115769. /** Fog Color */
  115770. FogColor = 8
  115771. }
  115772. }
  115773. declare module BABYLON {
  115774. /**
  115775. * Contains position and normal vectors for a vertex
  115776. */
  115777. export class PositionNormalVertex {
  115778. /** the position of the vertex (defaut: 0,0,0) */
  115779. position: Vector3;
  115780. /** the normal of the vertex (defaut: 0,1,0) */
  115781. normal: Vector3;
  115782. /**
  115783. * Creates a PositionNormalVertex
  115784. * @param position the position of the vertex (defaut: 0,0,0)
  115785. * @param normal the normal of the vertex (defaut: 0,1,0)
  115786. */
  115787. constructor(
  115788. /** the position of the vertex (defaut: 0,0,0) */
  115789. position?: Vector3,
  115790. /** the normal of the vertex (defaut: 0,1,0) */
  115791. normal?: Vector3);
  115792. /**
  115793. * Clones the PositionNormalVertex
  115794. * @returns the cloned PositionNormalVertex
  115795. */
  115796. clone(): PositionNormalVertex;
  115797. }
  115798. /**
  115799. * Contains position, normal and uv vectors for a vertex
  115800. */
  115801. export class PositionNormalTextureVertex {
  115802. /** the position of the vertex (defaut: 0,0,0) */
  115803. position: Vector3;
  115804. /** the normal of the vertex (defaut: 0,1,0) */
  115805. normal: Vector3;
  115806. /** the uv of the vertex (default: 0,0) */
  115807. uv: Vector2;
  115808. /**
  115809. * Creates a PositionNormalTextureVertex
  115810. * @param position the position of the vertex (defaut: 0,0,0)
  115811. * @param normal the normal of the vertex (defaut: 0,1,0)
  115812. * @param uv the uv of the vertex (default: 0,0)
  115813. */
  115814. constructor(
  115815. /** the position of the vertex (defaut: 0,0,0) */
  115816. position?: Vector3,
  115817. /** the normal of the vertex (defaut: 0,1,0) */
  115818. normal?: Vector3,
  115819. /** the uv of the vertex (default: 0,0) */
  115820. uv?: Vector2);
  115821. /**
  115822. * Clones the PositionNormalTextureVertex
  115823. * @returns the cloned PositionNormalTextureVertex
  115824. */
  115825. clone(): PositionNormalTextureVertex;
  115826. }
  115827. }
  115828. declare module BABYLON {
  115829. /**
  115830. * Block used to expose an input value
  115831. */
  115832. export class InputBlock extends NodeMaterialBlock {
  115833. private _mode;
  115834. private _associatedVariableName;
  115835. private _storedValue;
  115836. private _valueCallback;
  115837. private _type;
  115838. /** @hidden */
  115839. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115840. /**
  115841. * Gets or sets the connection point type (default is float)
  115842. */
  115843. readonly type: NodeMaterialBlockConnectionPointTypes;
  115844. /**
  115845. * Creates a new InputBlock
  115846. * @param name defines the block name
  115847. * @param target defines the target of that block (Vertex by default)
  115848. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  115849. */
  115850. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  115851. /**
  115852. * Gets the output component
  115853. */
  115854. readonly output: NodeMaterialConnectionPoint;
  115855. /**
  115856. * Set the source of this connection point to a vertex attribute
  115857. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  115858. * @returns the current connection point
  115859. */
  115860. setAsAttribute(attributeName?: string): InputBlock;
  115861. /**
  115862. * Set the source of this connection point to a well known value
  115863. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  115864. * @returns the current connection point
  115865. */
  115866. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  115867. /**
  115868. * Gets or sets the value of that point.
  115869. * Please note that this value will be ignored if valueCallback is defined
  115870. */
  115871. value: any;
  115872. /**
  115873. * Gets or sets a callback used to get the value of that point.
  115874. * Please note that setting this value will force the connection point to ignore the value property
  115875. */
  115876. valueCallback: () => any;
  115877. /**
  115878. * Gets or sets the associated variable name in the shader
  115879. */
  115880. associatedVariableName: string;
  115881. /**
  115882. * Gets a boolean indicating that this connection point not defined yet
  115883. */
  115884. readonly isUndefined: boolean;
  115885. /**
  115886. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  115887. * In this case the connection point name must be the name of the uniform to use.
  115888. * Can only be set on inputs
  115889. */
  115890. isUniform: boolean;
  115891. /**
  115892. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  115893. * In this case the connection point name must be the name of the attribute to use
  115894. * Can only be set on inputs
  115895. */
  115896. isAttribute: boolean;
  115897. /**
  115898. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  115899. * Can only be set on exit points
  115900. */
  115901. isVarying: boolean;
  115902. /**
  115903. * Gets a boolean indicating that the current connection point is a well known value
  115904. */
  115905. readonly isWellKnownValue: boolean;
  115906. /**
  115907. * Gets or sets the current well known value or null if not defined as well know value
  115908. */
  115909. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  115910. /**
  115911. * Gets the current class name
  115912. * @returns the class name
  115913. */
  115914. getClassName(): string;
  115915. private _emitDefine;
  115916. /**
  115917. * Set the input block to its default value (based on its type)
  115918. */
  115919. setDefaultValue(): void;
  115920. private _emit;
  115921. /** @hidden */
  115922. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  115923. /** @hidden */
  115924. _transmit(effect: Effect, scene: Scene): void;
  115925. protected _buildBlock(state: NodeMaterialBuildState): void;
  115926. serialize(): any;
  115927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  115928. }
  115929. }
  115930. declare module BABYLON {
  115931. /**
  115932. * Defines a connection point for a block
  115933. */
  115934. export class NodeMaterialConnectionPoint {
  115935. /** @hidden */
  115936. _ownerBlock: NodeMaterialBlock;
  115937. /** @hidden */
  115938. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115939. private _endpoints;
  115940. private _associatedVariableName;
  115941. /** @hidden */
  115942. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  115943. private _type;
  115944. /** @hidden */
  115945. _enforceAssociatedVariableName: boolean;
  115946. /**
  115947. * Gets or sets the associated variable name in the shader
  115948. */
  115949. associatedVariableName: string;
  115950. /**
  115951. * Gets or sets the connection point type (default is float)
  115952. */
  115953. type: NodeMaterialBlockConnectionPointTypes;
  115954. /**
  115955. * Gets or sets the connection point name
  115956. */
  115957. name: string;
  115958. /**
  115959. * Gets or sets the swizzle to apply to this connection point when reading or writing
  115960. */
  115961. swizzle: string;
  115962. /**
  115963. * Gets or sets a boolean indicating that this connection point can be omitted
  115964. */
  115965. isOptional: boolean;
  115966. /**
  115967. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  115968. */
  115969. define: string;
  115970. /** Gets or sets the target of that connection point */
  115971. target: NodeMaterialBlockTargets;
  115972. /**
  115973. * Gets a boolean indicating that the current point is connected
  115974. */
  115975. readonly isConnected: boolean;
  115976. /**
  115977. * Gets a boolean indicating that the current point is connected to an input block
  115978. */
  115979. readonly isConnectedToInput: boolean;
  115980. /**
  115981. * Gets a the connected input block (if any)
  115982. */
  115983. readonly connectInputBlock: Nullable<InputBlock>;
  115984. /** Get the other side of the connection (if any) */
  115985. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  115986. /** Get the block that owns this connection point */
  115987. readonly ownerBlock: NodeMaterialBlock;
  115988. /** Get the block connected on the other side of this connection (if any) */
  115989. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  115990. /** Get the block connected on the endpoints of this connection (if any) */
  115991. readonly connectedBlocks: Array<NodeMaterialBlock>;
  115992. /** Gets the list of connected endpoints */
  115993. readonly endpoints: NodeMaterialConnectionPoint[];
  115994. /**
  115995. * Creates a new connection point
  115996. * @param name defines the connection point name
  115997. * @param ownerBlock defines the block hosting this connection point
  115998. */
  115999. constructor(name: string, ownerBlock: NodeMaterialBlock);
  116000. /**
  116001. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  116002. * @returns the class name
  116003. */
  116004. getClassName(): string;
  116005. /**
  116006. * Gets an boolean indicating if the current point can be connected to another point
  116007. * @param connectionPoint defines the other connection point
  116008. * @returns true if the connection is possible
  116009. */
  116010. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  116011. /**
  116012. * Connect this point to another connection point
  116013. * @param connectionPoint defines the other connection point
  116014. * @returns the current connection point
  116015. */
  116016. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116017. /**
  116018. * Disconnect this point from one of his endpoint
  116019. * @param endpoint defines the other connection point
  116020. * @returns the current connection point
  116021. */
  116022. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  116023. /**
  116024. * Serializes this point in a JSON representation
  116025. * @returns the serialized point object
  116026. */
  116027. serialize(): any;
  116028. private static _GetTypeLength;
  116029. }
  116030. }
  116031. declare module BABYLON {
  116032. /**
  116033. * Block used to add support for vertex skinning (bones)
  116034. */
  116035. export class BonesBlock extends NodeMaterialBlock {
  116036. /**
  116037. * Creates a new BonesBlock
  116038. * @param name defines the block name
  116039. */
  116040. constructor(name: string);
  116041. /**
  116042. * Initialize the block and prepare the context for build
  116043. * @param state defines the state that will be used for the build
  116044. */
  116045. initialize(state: NodeMaterialBuildState): void;
  116046. /**
  116047. * Gets the current class name
  116048. * @returns the class name
  116049. */
  116050. getClassName(): string;
  116051. /**
  116052. * Gets the matrix indices input component
  116053. */
  116054. readonly matricesIndices: NodeMaterialConnectionPoint;
  116055. /**
  116056. * Gets the matrix weights input component
  116057. */
  116058. readonly matricesWeights: NodeMaterialConnectionPoint;
  116059. /**
  116060. * Gets the extra matrix indices input component
  116061. */
  116062. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  116063. /**
  116064. * Gets the extra matrix weights input component
  116065. */
  116066. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  116067. /**
  116068. * Gets the world input component
  116069. */
  116070. readonly world: NodeMaterialConnectionPoint;
  116071. /**
  116072. * Gets the output component
  116073. */
  116074. readonly output: NodeMaterialConnectionPoint;
  116075. autoConfigure(): void;
  116076. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  116077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116079. protected _buildBlock(state: NodeMaterialBuildState): this;
  116080. }
  116081. }
  116082. declare module BABYLON {
  116083. /**
  116084. * Block used to add support for instances
  116085. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  116086. */
  116087. export class InstancesBlock extends NodeMaterialBlock {
  116088. /**
  116089. * Creates a new InstancesBlock
  116090. * @param name defines the block name
  116091. */
  116092. constructor(name: string);
  116093. /**
  116094. * Gets the current class name
  116095. * @returns the class name
  116096. */
  116097. getClassName(): string;
  116098. /**
  116099. * Gets the first world row input component
  116100. */
  116101. readonly world0: NodeMaterialConnectionPoint;
  116102. /**
  116103. * Gets the second world row input component
  116104. */
  116105. readonly world1: NodeMaterialConnectionPoint;
  116106. /**
  116107. * Gets the third world row input component
  116108. */
  116109. readonly world2: NodeMaterialConnectionPoint;
  116110. /**
  116111. * Gets the forth world row input component
  116112. */
  116113. readonly world3: NodeMaterialConnectionPoint;
  116114. /**
  116115. * Gets the world input component
  116116. */
  116117. readonly world: NodeMaterialConnectionPoint;
  116118. /**
  116119. * Gets the output component
  116120. */
  116121. readonly output: NodeMaterialConnectionPoint;
  116122. autoConfigure(): void;
  116123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  116124. protected _buildBlock(state: NodeMaterialBuildState): this;
  116125. }
  116126. }
  116127. declare module BABYLON {
  116128. /**
  116129. * Block used to add morph targets support to vertex shader
  116130. */
  116131. export class MorphTargetsBlock extends NodeMaterialBlock {
  116132. private _repeatableContentAnchor;
  116133. private _repeatebleContentGenerated;
  116134. /**
  116135. * Create a new MorphTargetsBlock
  116136. * @param name defines the block name
  116137. */
  116138. constructor(name: string);
  116139. /**
  116140. * Gets the current class name
  116141. * @returns the class name
  116142. */
  116143. getClassName(): string;
  116144. /**
  116145. * Gets the position input component
  116146. */
  116147. readonly position: NodeMaterialConnectionPoint;
  116148. /**
  116149. * Gets the normal input component
  116150. */
  116151. readonly normal: NodeMaterialConnectionPoint;
  116152. /**
  116153. * Gets the tangent input component
  116154. */
  116155. readonly tangent: NodeMaterialConnectionPoint;
  116156. /**
  116157. * Gets the tangent input component
  116158. */
  116159. readonly uv: NodeMaterialConnectionPoint;
  116160. /**
  116161. * Gets the position output component
  116162. */
  116163. readonly positionOutput: NodeMaterialConnectionPoint;
  116164. /**
  116165. * Gets the normal output component
  116166. */
  116167. readonly normalOutput: NodeMaterialConnectionPoint;
  116168. /**
  116169. * Gets the tangent output component
  116170. */
  116171. readonly tangentOutput: NodeMaterialConnectionPoint;
  116172. /**
  116173. * Gets the tangent output component
  116174. */
  116175. readonly uvOutput: NodeMaterialConnectionPoint;
  116176. initialize(state: NodeMaterialBuildState): void;
  116177. autoConfigure(): void;
  116178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116179. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116180. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  116181. protected _buildBlock(state: NodeMaterialBuildState): this;
  116182. }
  116183. }
  116184. declare module BABYLON {
  116185. /**
  116186. * Block used to add an alpha test in the fragment shader
  116187. */
  116188. export class AlphaTestBlock extends NodeMaterialBlock {
  116189. /**
  116190. * Gets or sets the alpha value where alpha testing happens
  116191. */
  116192. alphaCutOff: number;
  116193. /**
  116194. * Create a new AlphaTestBlock
  116195. * @param name defines the block name
  116196. */
  116197. constructor(name: string);
  116198. /**
  116199. * Gets the current class name
  116200. * @returns the class name
  116201. */
  116202. getClassName(): string;
  116203. /**
  116204. * Gets the color input component
  116205. */
  116206. readonly color: NodeMaterialConnectionPoint;
  116207. protected _buildBlock(state: NodeMaterialBuildState): this;
  116208. }
  116209. }
  116210. declare module BABYLON {
  116211. /**
  116212. * Block used to create a Color4 out of 4 inputs (one for each component)
  116213. */
  116214. export class RGBAMergerBlock extends NodeMaterialBlock {
  116215. /**
  116216. * Create a new RGBAMergerBlock
  116217. * @param name defines the block name
  116218. */
  116219. constructor(name: string);
  116220. /**
  116221. * Gets the current class name
  116222. * @returns the class name
  116223. */
  116224. getClassName(): string;
  116225. /**
  116226. * Gets the R input component
  116227. */
  116228. readonly r: NodeMaterialConnectionPoint;
  116229. /**
  116230. * Gets the G input component
  116231. */
  116232. readonly g: NodeMaterialConnectionPoint;
  116233. /**
  116234. * Gets the B input component
  116235. */
  116236. readonly b: NodeMaterialConnectionPoint;
  116237. /**
  116238. * Gets the RGB input component
  116239. */
  116240. readonly rgb: NodeMaterialConnectionPoint;
  116241. /**
  116242. * Gets the R input component
  116243. */
  116244. readonly a: NodeMaterialConnectionPoint;
  116245. /**
  116246. * Gets the output component
  116247. */
  116248. readonly output: NodeMaterialConnectionPoint;
  116249. protected _buildBlock(state: NodeMaterialBuildState): this;
  116250. }
  116251. }
  116252. declare module BABYLON {
  116253. /**
  116254. * Block used to create a Color3 out of 3 inputs (one for each component)
  116255. */
  116256. export class RGBMergerBlock extends NodeMaterialBlock {
  116257. /**
  116258. * Create a new RGBMergerBlock
  116259. * @param name defines the block name
  116260. */
  116261. constructor(name: string);
  116262. /**
  116263. * Gets the current class name
  116264. * @returns the class name
  116265. */
  116266. getClassName(): string;
  116267. /**
  116268. * Gets the R component input
  116269. */
  116270. readonly r: NodeMaterialConnectionPoint;
  116271. /**
  116272. * Gets the G component input
  116273. */
  116274. readonly g: NodeMaterialConnectionPoint;
  116275. /**
  116276. * Gets the B component input
  116277. */
  116278. readonly b: NodeMaterialConnectionPoint;
  116279. /**
  116280. * Gets the output component
  116281. */
  116282. readonly output: NodeMaterialConnectionPoint;
  116283. protected _buildBlock(state: NodeMaterialBuildState): this;
  116284. }
  116285. }
  116286. declare module BABYLON {
  116287. /**
  116288. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  116289. */
  116290. export class RGBASplitterBlock extends NodeMaterialBlock {
  116291. /**
  116292. * Create a new RGBASplitterBlock
  116293. * @param name defines the block name
  116294. */
  116295. constructor(name: string);
  116296. /**
  116297. * Gets the current class name
  116298. * @returns the class name
  116299. */
  116300. getClassName(): string;
  116301. /**
  116302. * Gets the input component
  116303. */
  116304. readonly input: NodeMaterialConnectionPoint;
  116305. protected _buildBlock(state: NodeMaterialBuildState): this;
  116306. }
  116307. }
  116308. declare module BABYLON {
  116309. /**
  116310. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  116311. */
  116312. export class RGBSplitterBlock extends NodeMaterialBlock {
  116313. /**
  116314. * Create a new RGBSplitterBlock
  116315. * @param name defines the block name
  116316. */
  116317. constructor(name: string);
  116318. /**
  116319. * Gets the current class name
  116320. * @returns the class name
  116321. */
  116322. getClassName(): string;
  116323. /**
  116324. * Gets the input component
  116325. */
  116326. readonly input: NodeMaterialConnectionPoint;
  116327. protected _buildBlock(state: NodeMaterialBuildState): this;
  116328. }
  116329. }
  116330. declare module BABYLON {
  116331. /**
  116332. * Block used to add image processing support to fragment shader
  116333. */
  116334. export class ImageProcessingBlock extends NodeMaterialBlock {
  116335. /**
  116336. * Create a new ImageProcessingBlock
  116337. * @param name defines the block name
  116338. */
  116339. constructor(name: string);
  116340. /**
  116341. * Gets the current class name
  116342. * @returns the class name
  116343. */
  116344. getClassName(): string;
  116345. /**
  116346. * Gets the color input component
  116347. */
  116348. readonly color: NodeMaterialConnectionPoint;
  116349. /**
  116350. * Gets the output component
  116351. */
  116352. readonly output: NodeMaterialConnectionPoint;
  116353. /**
  116354. * Initialize the block and prepare the context for build
  116355. * @param state defines the state that will be used for the build
  116356. */
  116357. initialize(state: NodeMaterialBuildState): void;
  116358. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  116359. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116360. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116361. protected _buildBlock(state: NodeMaterialBuildState): this;
  116362. }
  116363. }
  116364. declare module BABYLON {
  116365. /**
  116366. * Block used to add support for scene fog
  116367. */
  116368. export class FogBlock extends NodeMaterialBlock {
  116369. private _fogDistanceName;
  116370. private _fogParameters;
  116371. /**
  116372. * Create a new FogBlock
  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 world position input component
  116383. */
  116384. readonly worldPosition: NodeMaterialConnectionPoint;
  116385. /**
  116386. * Gets the view input component
  116387. */
  116388. readonly view: NodeMaterialConnectionPoint;
  116389. /**
  116390. * Gets the color input component
  116391. */
  116392. readonly color: NodeMaterialConnectionPoint;
  116393. /**
  116394. * Gets the fog color input component
  116395. */
  116396. readonly fogColor: NodeMaterialConnectionPoint;
  116397. /**
  116398. * Gets the output component
  116399. */
  116400. readonly output: NodeMaterialConnectionPoint;
  116401. autoConfigure(): void;
  116402. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116404. protected _buildBlock(state: NodeMaterialBuildState): this;
  116405. }
  116406. }
  116407. declare module BABYLON {
  116408. /**
  116409. * Block used to add light in the fragment shader
  116410. */
  116411. export class LightBlock extends NodeMaterialBlock {
  116412. private _lightId;
  116413. /**
  116414. * Gets or sets the light associated with this block
  116415. */
  116416. light: Nullable<Light>;
  116417. /**
  116418. * Create a new LightBlock
  116419. * @param name defines the block name
  116420. */
  116421. constructor(name: string);
  116422. /**
  116423. * Gets the current class name
  116424. * @returns the class name
  116425. */
  116426. getClassName(): string;
  116427. /**
  116428. * Gets the world position input component
  116429. */
  116430. readonly worldPosition: NodeMaterialConnectionPoint;
  116431. /**
  116432. * Gets the world normal input component
  116433. */
  116434. readonly worldNormal: NodeMaterialConnectionPoint;
  116435. /**
  116436. * Gets the camera (or eye) position component
  116437. */
  116438. readonly cameraPosition: NodeMaterialConnectionPoint;
  116439. /**
  116440. * Gets the diffuse output component
  116441. */
  116442. readonly diffuseOutput: NodeMaterialConnectionPoint;
  116443. /**
  116444. * Gets the specular output component
  116445. */
  116446. readonly specularOutput: NodeMaterialConnectionPoint;
  116447. autoConfigure(): void;
  116448. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116449. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  116450. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  116451. private _injectVertexCode;
  116452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  116453. serialize(): any;
  116454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  116455. }
  116456. }
  116457. declare module BABYLON {
  116458. /**
  116459. * Block used to multiply 2 values
  116460. */
  116461. export class MultiplyBlock extends NodeMaterialBlock {
  116462. /**
  116463. * Creates a new MultiplyBlock
  116464. * @param name defines the block name
  116465. */
  116466. constructor(name: string);
  116467. /**
  116468. * Gets the current class name
  116469. * @returns the class name
  116470. */
  116471. getClassName(): string;
  116472. /**
  116473. * Gets the left operand input component
  116474. */
  116475. readonly left: NodeMaterialConnectionPoint;
  116476. /**
  116477. * Gets the right operand input component
  116478. */
  116479. readonly right: NodeMaterialConnectionPoint;
  116480. /**
  116481. * Gets the output component
  116482. */
  116483. readonly output: NodeMaterialConnectionPoint;
  116484. protected _buildBlock(state: NodeMaterialBuildState): this;
  116485. }
  116486. }
  116487. declare module BABYLON {
  116488. /**
  116489. * Block used to add 2 vectors
  116490. */
  116491. export class AddBlock extends NodeMaterialBlock {
  116492. /**
  116493. * Creates a new AddBlock
  116494. * @param name defines the block name
  116495. */
  116496. constructor(name: string);
  116497. /**
  116498. * Gets the current class name
  116499. * @returns the class name
  116500. */
  116501. getClassName(): string;
  116502. /**
  116503. * Gets the left operand input component
  116504. */
  116505. readonly left: NodeMaterialConnectionPoint;
  116506. /**
  116507. * Gets the right operand input component
  116508. */
  116509. readonly right: NodeMaterialConnectionPoint;
  116510. /**
  116511. * Gets the output component
  116512. */
  116513. readonly output: NodeMaterialConnectionPoint;
  116514. protected _buildBlock(state: NodeMaterialBuildState): this;
  116515. }
  116516. }
  116517. declare module BABYLON {
  116518. /**
  116519. * Block used to clamp a float
  116520. */
  116521. export class ClampBlock extends NodeMaterialBlock {
  116522. /** Gets or sets the minimum range */
  116523. minimum: number;
  116524. /** Gets or sets the maximum range */
  116525. maximum: number;
  116526. /**
  116527. * Creates a new ClampBlock
  116528. * @param name defines the block name
  116529. */
  116530. constructor(name: string);
  116531. /**
  116532. * Gets the current class name
  116533. * @returns the class name
  116534. */
  116535. getClassName(): string;
  116536. /**
  116537. * Gets the value input component
  116538. */
  116539. readonly value: NodeMaterialConnectionPoint;
  116540. /**
  116541. * Gets the output component
  116542. */
  116543. readonly output: NodeMaterialConnectionPoint;
  116544. protected _buildBlock(state: NodeMaterialBuildState): this;
  116545. }
  116546. }
  116547. declare module BABYLON {
  116548. /**
  116549. * Block used to apply a cross product between 2 vectors
  116550. */
  116551. export class CrossBlock extends NodeMaterialBlock {
  116552. /**
  116553. * Creates a new CrossBlock
  116554. * @param name defines the block name
  116555. */
  116556. constructor(name: string);
  116557. /**
  116558. * Gets the current class name
  116559. * @returns the class name
  116560. */
  116561. getClassName(): string;
  116562. /**
  116563. * Gets the left operand input component
  116564. */
  116565. readonly left: NodeMaterialConnectionPoint;
  116566. /**
  116567. * Gets the right operand input component
  116568. */
  116569. readonly right: NodeMaterialConnectionPoint;
  116570. /**
  116571. * Gets the output component
  116572. */
  116573. readonly output: NodeMaterialConnectionPoint;
  116574. protected _buildBlock(state: NodeMaterialBuildState): this;
  116575. }
  116576. }
  116577. declare module BABYLON {
  116578. /**
  116579. * Block used to apply a dot product between 2 vectors
  116580. */
  116581. export class DotBlock extends NodeMaterialBlock {
  116582. /**
  116583. * Creates a new DotBlock
  116584. * @param name defines the block name
  116585. */
  116586. constructor(name: string);
  116587. /**
  116588. * Gets the current class name
  116589. * @returns the class name
  116590. */
  116591. getClassName(): string;
  116592. /**
  116593. * Gets the left operand input component
  116594. */
  116595. readonly left: NodeMaterialConnectionPoint;
  116596. /**
  116597. * Gets the right operand input component
  116598. */
  116599. readonly right: NodeMaterialConnectionPoint;
  116600. /**
  116601. * Gets the output component
  116602. */
  116603. readonly output: NodeMaterialConnectionPoint;
  116604. protected _buildBlock(state: NodeMaterialBuildState): this;
  116605. }
  116606. }
  116607. declare module BABYLON {
  116608. /**
  116609. * Effect Render Options
  116610. */
  116611. export interface IEffectRendererOptions {
  116612. /**
  116613. * Defines the vertices positions.
  116614. */
  116615. positions?: number[];
  116616. /**
  116617. * Defines the indices.
  116618. */
  116619. indices?: number[];
  116620. }
  116621. /**
  116622. * Helper class to render one or more effects
  116623. */
  116624. export class EffectRenderer {
  116625. private engine;
  116626. private static _DefaultOptions;
  116627. private _vertexBuffers;
  116628. private _indexBuffer;
  116629. private _ringBufferIndex;
  116630. private _ringScreenBuffer;
  116631. private _fullscreenViewport;
  116632. private _getNextFrameBuffer;
  116633. /**
  116634. * Creates an effect renderer
  116635. * @param engine the engine to use for rendering
  116636. * @param options defines the options of the effect renderer
  116637. */
  116638. constructor(engine: Engine, options?: IEffectRendererOptions);
  116639. /**
  116640. * Sets the current viewport in normalized coordinates 0-1
  116641. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  116642. */
  116643. setViewport(viewport?: Viewport): void;
  116644. /**
  116645. * Sets the current effect wrapper to use during draw.
  116646. * The effect needs to be ready before calling this api.
  116647. * This also sets the default full screen position attribute.
  116648. * @param effectWrapper Defines the effect to draw with
  116649. */
  116650. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  116651. /**
  116652. * Draws a full screen quad.
  116653. */
  116654. draw(): void;
  116655. /**
  116656. * renders one or more effects to a specified texture
  116657. * @param effectWrappers list of effects to renderer
  116658. * @param outputTexture texture to draw to, if null it will render to the screen
  116659. */
  116660. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  116661. /**
  116662. * Disposes of the effect renderer
  116663. */
  116664. dispose(): void;
  116665. }
  116666. /**
  116667. * Options to create an EffectWrapper
  116668. */
  116669. interface EffectWrapperCreationOptions {
  116670. /**
  116671. * Engine to use to create the effect
  116672. */
  116673. engine: Engine;
  116674. /**
  116675. * Fragment shader for the effect
  116676. */
  116677. fragmentShader: string;
  116678. /**
  116679. * Vertex shader for the effect
  116680. */
  116681. vertexShader: string;
  116682. /**
  116683. * Attributes to use in the shader
  116684. */
  116685. attributeNames?: Array<string>;
  116686. /**
  116687. * Uniforms to use in the shader
  116688. */
  116689. uniformNames?: Array<string>;
  116690. /**
  116691. * Texture sampler names to use in the shader
  116692. */
  116693. samplerNames?: Array<string>;
  116694. /**
  116695. * The friendly name of the effect displayed in Spector.
  116696. */
  116697. name?: string;
  116698. }
  116699. /**
  116700. * Wraps an effect to be used for rendering
  116701. */
  116702. export class EffectWrapper {
  116703. /**
  116704. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  116705. */
  116706. onApplyObservable: Observable<{}>;
  116707. /**
  116708. * The underlying effect
  116709. */
  116710. effect: Effect;
  116711. /**
  116712. * Creates an effect to be renderer
  116713. * @param creationOptions options to create the effect
  116714. */
  116715. constructor(creationOptions: EffectWrapperCreationOptions);
  116716. /**
  116717. * Disposes of the effect wrapper
  116718. */
  116719. dispose(): void;
  116720. }
  116721. }
  116722. declare module BABYLON {
  116723. /**
  116724. * Helper class to push actions to a pool of workers.
  116725. */
  116726. export class WorkerPool implements IDisposable {
  116727. private _workerInfos;
  116728. private _pendingActions;
  116729. /**
  116730. * Constructor
  116731. * @param workers Array of workers to use for actions
  116732. */
  116733. constructor(workers: Array<Worker>);
  116734. /**
  116735. * Terminates all workers and clears any pending actions.
  116736. */
  116737. dispose(): void;
  116738. /**
  116739. * Pushes an action to the worker pool. If all the workers are active, the action will be
  116740. * pended until a worker has completed its action.
  116741. * @param action The action to perform. Call onComplete when the action is complete.
  116742. */
  116743. push(action: (worker: Worker, onComplete: () => void) => void): void;
  116744. private _execute;
  116745. }
  116746. }
  116747. declare module BABYLON {
  116748. /**
  116749. * Configuration for Draco compression
  116750. */
  116751. export interface IDracoCompressionConfiguration {
  116752. /**
  116753. * Configuration for the decoder.
  116754. */
  116755. decoder: {
  116756. /**
  116757. * The url to the WebAssembly module.
  116758. */
  116759. wasmUrl?: string;
  116760. /**
  116761. * The url to the WebAssembly binary.
  116762. */
  116763. wasmBinaryUrl?: string;
  116764. /**
  116765. * The url to the fallback JavaScript module.
  116766. */
  116767. fallbackUrl?: string;
  116768. };
  116769. }
  116770. /**
  116771. * Draco compression (https://google.github.io/draco/)
  116772. *
  116773. * This class wraps the Draco module.
  116774. *
  116775. * **Encoder**
  116776. *
  116777. * The encoder is not currently implemented.
  116778. *
  116779. * **Decoder**
  116780. *
  116781. * 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.
  116782. *
  116783. * To update the configuration, use the following code:
  116784. * ```javascript
  116785. * DracoCompression.Configuration = {
  116786. * decoder: {
  116787. * wasmUrl: "<url to the WebAssembly library>",
  116788. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  116789. * fallbackUrl: "<url to the fallback JavaScript library>",
  116790. * }
  116791. * };
  116792. * ```
  116793. *
  116794. * 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.
  116795. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  116796. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  116797. *
  116798. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  116799. * ```javascript
  116800. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  116801. * ```
  116802. *
  116803. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  116804. */
  116805. export class DracoCompression implements IDisposable {
  116806. private _workerPoolPromise?;
  116807. private _decoderModulePromise?;
  116808. /**
  116809. * The configuration. Defaults to the following urls:
  116810. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  116811. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  116812. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  116813. */
  116814. static Configuration: IDracoCompressionConfiguration;
  116815. /**
  116816. * Returns true if the decoder configuration is available.
  116817. */
  116818. static readonly DecoderAvailable: boolean;
  116819. /**
  116820. * Default number of workers to create when creating the draco compression object.
  116821. */
  116822. static DefaultNumWorkers: number;
  116823. private static GetDefaultNumWorkers;
  116824. private static _Default;
  116825. /**
  116826. * Default instance for the draco compression object.
  116827. */
  116828. static readonly Default: DracoCompression;
  116829. /**
  116830. * Constructor
  116831. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  116832. */
  116833. constructor(numWorkers?: number);
  116834. /**
  116835. * Stop all async operations and release resources.
  116836. */
  116837. dispose(): void;
  116838. /**
  116839. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  116840. * @returns a promise that resolves when ready
  116841. */
  116842. whenReadyAsync(): Promise<void>;
  116843. /**
  116844. * Decode Draco compressed mesh data to vertex data.
  116845. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  116846. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  116847. * @returns A promise that resolves with the decoded vertex data
  116848. */
  116849. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  116850. [kind: string]: number;
  116851. }): Promise<VertexData>;
  116852. }
  116853. }
  116854. declare module BABYLON {
  116855. /**
  116856. * Class for building Constructive Solid Geometry
  116857. */
  116858. export class CSG {
  116859. private polygons;
  116860. /**
  116861. * The world matrix
  116862. */
  116863. matrix: Matrix;
  116864. /**
  116865. * Stores the position
  116866. */
  116867. position: Vector3;
  116868. /**
  116869. * Stores the rotation
  116870. */
  116871. rotation: Vector3;
  116872. /**
  116873. * Stores the rotation quaternion
  116874. */
  116875. rotationQuaternion: Nullable<Quaternion>;
  116876. /**
  116877. * Stores the scaling vector
  116878. */
  116879. scaling: Vector3;
  116880. /**
  116881. * Convert the Mesh to CSG
  116882. * @param mesh The Mesh to convert to CSG
  116883. * @returns A new CSG from the Mesh
  116884. */
  116885. static FromMesh(mesh: Mesh): CSG;
  116886. /**
  116887. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  116888. * @param polygons Polygons used to construct a CSG solid
  116889. */
  116890. private static FromPolygons;
  116891. /**
  116892. * Clones, or makes a deep copy, of the CSG
  116893. * @returns A new CSG
  116894. */
  116895. clone(): CSG;
  116896. /**
  116897. * Unions this CSG with another CSG
  116898. * @param csg The CSG to union against this CSG
  116899. * @returns The unioned CSG
  116900. */
  116901. union(csg: CSG): CSG;
  116902. /**
  116903. * Unions this CSG with another CSG in place
  116904. * @param csg The CSG to union against this CSG
  116905. */
  116906. unionInPlace(csg: CSG): void;
  116907. /**
  116908. * Subtracts this CSG with another CSG
  116909. * @param csg The CSG to subtract against this CSG
  116910. * @returns A new CSG
  116911. */
  116912. subtract(csg: CSG): CSG;
  116913. /**
  116914. * Subtracts this CSG with another CSG in place
  116915. * @param csg The CSG to subtact against this CSG
  116916. */
  116917. subtractInPlace(csg: CSG): void;
  116918. /**
  116919. * Intersect this CSG with another CSG
  116920. * @param csg The CSG to intersect against this CSG
  116921. * @returns A new CSG
  116922. */
  116923. intersect(csg: CSG): CSG;
  116924. /**
  116925. * Intersects this CSG with another CSG in place
  116926. * @param csg The CSG to intersect against this CSG
  116927. */
  116928. intersectInPlace(csg: CSG): void;
  116929. /**
  116930. * Return a new CSG solid with solid and empty space switched. This solid is
  116931. * not modified.
  116932. * @returns A new CSG solid with solid and empty space switched
  116933. */
  116934. inverse(): CSG;
  116935. /**
  116936. * Inverses the CSG in place
  116937. */
  116938. inverseInPlace(): void;
  116939. /**
  116940. * This is used to keep meshes transformations so they can be restored
  116941. * when we build back a Babylon Mesh
  116942. * NB : All CSG operations are performed in world coordinates
  116943. * @param csg The CSG to copy the transform attributes from
  116944. * @returns This CSG
  116945. */
  116946. copyTransformAttributes(csg: CSG): CSG;
  116947. /**
  116948. * Build Raw mesh from CSG
  116949. * Coordinates here are in world space
  116950. * @param name The name of the mesh geometry
  116951. * @param scene The Scene
  116952. * @param keepSubMeshes Specifies if the submeshes should be kept
  116953. * @returns A new Mesh
  116954. */
  116955. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  116956. /**
  116957. * Build Mesh from CSG taking material and transforms into account
  116958. * @param name The name of the Mesh
  116959. * @param material The material of the Mesh
  116960. * @param scene The Scene
  116961. * @param keepSubMeshes Specifies if submeshes should be kept
  116962. * @returns The new Mesh
  116963. */
  116964. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  116965. }
  116966. }
  116967. declare module BABYLON {
  116968. /**
  116969. * Class used to create a trail following a mesh
  116970. */
  116971. export class TrailMesh extends Mesh {
  116972. private _generator;
  116973. private _autoStart;
  116974. private _running;
  116975. private _diameter;
  116976. private _length;
  116977. private _sectionPolygonPointsCount;
  116978. private _sectionVectors;
  116979. private _sectionNormalVectors;
  116980. private _beforeRenderObserver;
  116981. /**
  116982. * @constructor
  116983. * @param name The value used by scene.getMeshByName() to do a lookup.
  116984. * @param generator The mesh to generate a trail.
  116985. * @param scene The scene to add this mesh to.
  116986. * @param diameter Diameter of trailing mesh. Default is 1.
  116987. * @param length Length of trailing mesh. Default is 60.
  116988. * @param autoStart Automatically start trailing mesh. Default true.
  116989. */
  116990. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  116991. /**
  116992. * "TrailMesh"
  116993. * @returns "TrailMesh"
  116994. */
  116995. getClassName(): string;
  116996. private _createMesh;
  116997. /**
  116998. * Start trailing mesh.
  116999. */
  117000. start(): void;
  117001. /**
  117002. * Stop trailing mesh.
  117003. */
  117004. stop(): void;
  117005. /**
  117006. * Update trailing mesh geometry.
  117007. */
  117008. update(): void;
  117009. /**
  117010. * Returns a new TrailMesh object.
  117011. * @param name is a string, the name given to the new mesh
  117012. * @param newGenerator use new generator object for cloned trail mesh
  117013. * @returns a new mesh
  117014. */
  117015. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  117016. /**
  117017. * Serializes this trail mesh
  117018. * @param serializationObject object to write serialization to
  117019. */
  117020. serialize(serializationObject: any): void;
  117021. /**
  117022. * Parses a serialized trail mesh
  117023. * @param parsedMesh the serialized mesh
  117024. * @param scene the scene to create the trail mesh in
  117025. * @returns the created trail mesh
  117026. */
  117027. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  117028. }
  117029. }
  117030. declare module BABYLON {
  117031. /**
  117032. * Class containing static functions to help procedurally build meshes
  117033. */
  117034. export class TiledBoxBuilder {
  117035. /**
  117036. * Creates a box mesh
  117037. * 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)
  117038. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117042. * @param name defines the name of the mesh
  117043. * @param options defines the options used to create the mesh
  117044. * @param scene defines the hosting scene
  117045. * @returns the box mesh
  117046. */
  117047. static CreateTiledBox(name: string, options: {
  117048. pattern?: number;
  117049. width?: number;
  117050. height?: number;
  117051. depth?: number;
  117052. tileSize?: number;
  117053. tileWidth?: number;
  117054. tileHeight?: number;
  117055. alignHorizontal?: number;
  117056. alignVertical?: number;
  117057. faceUV?: Vector4[];
  117058. faceColors?: Color4[];
  117059. sideOrientation?: number;
  117060. updatable?: boolean;
  117061. }, scene?: Nullable<Scene>): Mesh;
  117062. }
  117063. }
  117064. declare module BABYLON {
  117065. /**
  117066. * Class containing static functions to help procedurally build meshes
  117067. */
  117068. export class TorusKnotBuilder {
  117069. /**
  117070. * Creates a torus knot mesh
  117071. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117072. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117073. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117074. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117078. * @param name defines the name of the mesh
  117079. * @param options defines the options used to create the mesh
  117080. * @param scene defines the hosting scene
  117081. * @returns the torus knot mesh
  117082. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117083. */
  117084. static CreateTorusKnot(name: string, options: {
  117085. radius?: number;
  117086. tube?: number;
  117087. radialSegments?: number;
  117088. tubularSegments?: number;
  117089. p?: number;
  117090. q?: number;
  117091. updatable?: boolean;
  117092. sideOrientation?: number;
  117093. frontUVs?: Vector4;
  117094. backUVs?: Vector4;
  117095. }, scene: any): Mesh;
  117096. }
  117097. }
  117098. declare module BABYLON {
  117099. /**
  117100. * Polygon
  117101. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  117102. */
  117103. export class Polygon {
  117104. /**
  117105. * Creates a rectangle
  117106. * @param xmin bottom X coord
  117107. * @param ymin bottom Y coord
  117108. * @param xmax top X coord
  117109. * @param ymax top Y coord
  117110. * @returns points that make the resulting rectation
  117111. */
  117112. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  117113. /**
  117114. * Creates a circle
  117115. * @param radius radius of circle
  117116. * @param cx scale in x
  117117. * @param cy scale in y
  117118. * @param numberOfSides number of sides that make up the circle
  117119. * @returns points that make the resulting circle
  117120. */
  117121. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  117122. /**
  117123. * Creates a polygon from input string
  117124. * @param input Input polygon data
  117125. * @returns the parsed points
  117126. */
  117127. static Parse(input: string): Vector2[];
  117128. /**
  117129. * Starts building a polygon from x and y coordinates
  117130. * @param x x coordinate
  117131. * @param y y coordinate
  117132. * @returns the started path2
  117133. */
  117134. static StartingAt(x: number, y: number): Path2;
  117135. }
  117136. /**
  117137. * Builds a polygon
  117138. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  117139. */
  117140. export class PolygonMeshBuilder {
  117141. private _points;
  117142. private _outlinepoints;
  117143. private _holes;
  117144. private _name;
  117145. private _scene;
  117146. private _epoints;
  117147. private _eholes;
  117148. private _addToepoint;
  117149. /**
  117150. * Babylon reference to the earcut plugin.
  117151. */
  117152. bjsEarcut: any;
  117153. /**
  117154. * Creates a PolygonMeshBuilder
  117155. * @param name name of the builder
  117156. * @param contours Path of the polygon
  117157. * @param scene scene to add to when creating the mesh
  117158. * @param earcutInjection can be used to inject your own earcut reference
  117159. */
  117160. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  117161. /**
  117162. * Adds a whole within the polygon
  117163. * @param hole Array of points defining the hole
  117164. * @returns this
  117165. */
  117166. addHole(hole: Vector2[]): PolygonMeshBuilder;
  117167. /**
  117168. * Creates the polygon
  117169. * @param updatable If the mesh should be updatable
  117170. * @param depth The depth of the mesh created
  117171. * @returns the created mesh
  117172. */
  117173. build(updatable?: boolean, depth?: number): Mesh;
  117174. /**
  117175. * Creates the polygon
  117176. * @param depth The depth of the mesh created
  117177. * @returns the created VertexData
  117178. */
  117179. buildVertexData(depth?: number): VertexData;
  117180. /**
  117181. * Adds a side to the polygon
  117182. * @param positions points that make the polygon
  117183. * @param normals normals of the polygon
  117184. * @param uvs uvs of the polygon
  117185. * @param indices indices of the polygon
  117186. * @param bounds bounds of the polygon
  117187. * @param points points of the polygon
  117188. * @param depth depth of the polygon
  117189. * @param flip flip of the polygon
  117190. */
  117191. private addSide;
  117192. }
  117193. }
  117194. declare module BABYLON {
  117195. /**
  117196. * Class containing static functions to help procedurally build meshes
  117197. */
  117198. export class PolygonBuilder {
  117199. /**
  117200. * Creates a polygon mesh
  117201. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  117202. * * 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
  117203. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117205. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  117206. * * Remember you can only change the shape positions, not their number when updating a polygon
  117207. * @param name defines the name of the mesh
  117208. * @param options defines the options used to create the mesh
  117209. * @param scene defines the hosting scene
  117210. * @param earcutInjection can be used to inject your own earcut reference
  117211. * @returns the polygon mesh
  117212. */
  117213. static CreatePolygon(name: string, options: {
  117214. shape: Vector3[];
  117215. holes?: Vector3[][];
  117216. depth?: number;
  117217. faceUV?: Vector4[];
  117218. faceColors?: Color4[];
  117219. updatable?: boolean;
  117220. sideOrientation?: number;
  117221. frontUVs?: Vector4;
  117222. backUVs?: Vector4;
  117223. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117224. /**
  117225. * Creates an extruded polygon mesh, with depth in the Y direction.
  117226. * * 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)
  117227. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117228. * @param name defines the name of the mesh
  117229. * @param options defines the options used to create the mesh
  117230. * @param scene defines the hosting scene
  117231. * @param earcutInjection can be used to inject your own earcut reference
  117232. * @returns the polygon mesh
  117233. */
  117234. static ExtrudePolygon(name: string, options: {
  117235. shape: Vector3[];
  117236. holes?: Vector3[][];
  117237. depth?: number;
  117238. faceUV?: Vector4[];
  117239. faceColors?: Color4[];
  117240. updatable?: boolean;
  117241. sideOrientation?: number;
  117242. frontUVs?: Vector4;
  117243. backUVs?: Vector4;
  117244. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  117245. }
  117246. }
  117247. declare module BABYLON {
  117248. /**
  117249. * Class containing static functions to help procedurally build meshes
  117250. */
  117251. export class LatheBuilder {
  117252. /**
  117253. * Creates lathe mesh.
  117254. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117255. * * 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
  117256. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117257. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117258. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117259. * * 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
  117260. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117261. * * 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
  117262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117264. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117266. * @param name defines the name of the mesh
  117267. * @param options defines the options used to create the mesh
  117268. * @param scene defines the hosting scene
  117269. * @returns the lathe mesh
  117270. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117271. */
  117272. static CreateLathe(name: string, options: {
  117273. shape: Vector3[];
  117274. radius?: number;
  117275. tessellation?: number;
  117276. clip?: number;
  117277. arc?: number;
  117278. closed?: boolean;
  117279. updatable?: boolean;
  117280. sideOrientation?: number;
  117281. frontUVs?: Vector4;
  117282. backUVs?: Vector4;
  117283. cap?: number;
  117284. invertUV?: boolean;
  117285. }, scene?: Nullable<Scene>): Mesh;
  117286. }
  117287. }
  117288. declare module BABYLON {
  117289. /**
  117290. * Class containing static functions to help procedurally build meshes
  117291. */
  117292. export class TiledPlaneBuilder {
  117293. /**
  117294. * Creates a tiled plane mesh
  117295. * * The parameter `pattern` will, depending on value, do nothing or
  117296. * * * flip (reflect about central vertical) alternate tiles across and up
  117297. * * * flip every tile on alternate rows
  117298. * * * rotate (180 degs) alternate tiles across and up
  117299. * * * rotate every tile on alternate rows
  117300. * * * flip and rotate alternate tiles across and up
  117301. * * * flip and rotate every tile on alternate rows
  117302. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  117303. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  117304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  117306. * * 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)
  117307. * * 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)
  117308. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117309. * @param name defines the name of the mesh
  117310. * @param options defines the options used to create the mesh
  117311. * @param scene defines the hosting scene
  117312. * @returns the box mesh
  117313. */
  117314. static CreateTiledPlane(name: string, options: {
  117315. pattern?: number;
  117316. tileSize?: number;
  117317. tileWidth?: number;
  117318. tileHeight?: number;
  117319. size?: number;
  117320. width?: number;
  117321. height?: number;
  117322. alignHorizontal?: number;
  117323. alignVertical?: number;
  117324. sideOrientation?: number;
  117325. frontUVs?: Vector4;
  117326. backUVs?: Vector4;
  117327. updatable?: boolean;
  117328. }, scene?: Nullable<Scene>): Mesh;
  117329. }
  117330. }
  117331. declare module BABYLON {
  117332. /**
  117333. * Class containing static functions to help procedurally build meshes
  117334. */
  117335. export class TubeBuilder {
  117336. /**
  117337. * Creates a tube mesh.
  117338. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117339. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  117340. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  117341. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  117342. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  117343. * * 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)
  117344. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  117345. * * 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
  117346. * * 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
  117347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117349. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117351. * @param name defines the name of the mesh
  117352. * @param options defines the options used to create the mesh
  117353. * @param scene defines the hosting scene
  117354. * @returns the tube mesh
  117355. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117356. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  117357. */
  117358. static CreateTube(name: string, options: {
  117359. path: Vector3[];
  117360. radius?: number;
  117361. tessellation?: number;
  117362. radiusFunction?: {
  117363. (i: number, distance: number): number;
  117364. };
  117365. cap?: number;
  117366. arc?: number;
  117367. updatable?: boolean;
  117368. sideOrientation?: number;
  117369. frontUVs?: Vector4;
  117370. backUVs?: Vector4;
  117371. instance?: Mesh;
  117372. invertUV?: boolean;
  117373. }, scene?: Nullable<Scene>): Mesh;
  117374. }
  117375. }
  117376. declare module BABYLON {
  117377. /**
  117378. * Class containing static functions to help procedurally build meshes
  117379. */
  117380. export class IcoSphereBuilder {
  117381. /**
  117382. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117383. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117384. * * 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`)
  117385. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117386. * * 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
  117387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117390. * @param name defines the name of the mesh
  117391. * @param options defines the options used to create the mesh
  117392. * @param scene defines the hosting scene
  117393. * @returns the icosahedron mesh
  117394. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117395. */
  117396. static CreateIcoSphere(name: string, options: {
  117397. radius?: number;
  117398. radiusX?: number;
  117399. radiusY?: number;
  117400. radiusZ?: number;
  117401. flat?: boolean;
  117402. subdivisions?: number;
  117403. sideOrientation?: number;
  117404. frontUVs?: Vector4;
  117405. backUVs?: Vector4;
  117406. updatable?: boolean;
  117407. }, scene?: Nullable<Scene>): Mesh;
  117408. }
  117409. }
  117410. declare module BABYLON {
  117411. /**
  117412. * Class containing static functions to help procedurally build meshes
  117413. */
  117414. export class DecalBuilder {
  117415. /**
  117416. * Creates a decal mesh.
  117417. * 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
  117418. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  117419. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  117420. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  117421. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  117422. * @param name defines the name of the mesh
  117423. * @param sourceMesh defines the mesh where the decal must be applied
  117424. * @param options defines the options used to create the mesh
  117425. * @param scene defines the hosting scene
  117426. * @returns the decal mesh
  117427. * @see https://doc.babylonjs.com/how_to/decals
  117428. */
  117429. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  117430. position?: Vector3;
  117431. normal?: Vector3;
  117432. size?: Vector3;
  117433. angle?: number;
  117434. }): Mesh;
  117435. }
  117436. }
  117437. declare module BABYLON {
  117438. /**
  117439. * Class containing static functions to help procedurally build meshes
  117440. */
  117441. export class MeshBuilder {
  117442. /**
  117443. * Creates a box mesh
  117444. * * The parameter `size` sets the size (float) of each box side (default 1)
  117445. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  117446. * * 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)
  117447. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  117448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117451. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  117452. * @param name defines the name of the mesh
  117453. * @param options defines the options used to create the mesh
  117454. * @param scene defines the hosting scene
  117455. * @returns the box mesh
  117456. */
  117457. static CreateBox(name: string, options: {
  117458. size?: number;
  117459. width?: number;
  117460. height?: number;
  117461. depth?: number;
  117462. faceUV?: Vector4[];
  117463. faceColors?: Color4[];
  117464. sideOrientation?: number;
  117465. frontUVs?: Vector4;
  117466. backUVs?: Vector4;
  117467. updatable?: boolean;
  117468. }, scene?: Nullable<Scene>): Mesh;
  117469. /**
  117470. * Creates a tiled box mesh
  117471. * * faceTiles sets the pattern, tile size and number of tiles for a face
  117472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117473. * @param name defines the name of the mesh
  117474. * @param options defines the options used to create the mesh
  117475. * @param scene defines the hosting scene
  117476. * @returns the tiled box mesh
  117477. */
  117478. static CreateTiledBox(name: string, options: {
  117479. pattern?: number;
  117480. size?: number;
  117481. width?: number;
  117482. height?: number;
  117483. depth: number;
  117484. tileSize?: number;
  117485. tileWidth?: number;
  117486. tileHeight?: number;
  117487. faceUV?: Vector4[];
  117488. faceColors?: Color4[];
  117489. alignHorizontal?: number;
  117490. alignVertical?: number;
  117491. sideOrientation?: number;
  117492. updatable?: boolean;
  117493. }, scene?: Nullable<Scene>): Mesh;
  117494. /**
  117495. * Creates a sphere mesh
  117496. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117497. * * 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`)
  117498. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117499. * * 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
  117500. * * 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)
  117501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117504. * @param name defines the name of the mesh
  117505. * @param options defines the options used to create the mesh
  117506. * @param scene defines the hosting scene
  117507. * @returns the sphere mesh
  117508. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117509. */
  117510. static CreateSphere(name: string, options: {
  117511. segments?: number;
  117512. diameter?: number;
  117513. diameterX?: number;
  117514. diameterY?: number;
  117515. diameterZ?: number;
  117516. arc?: number;
  117517. slice?: number;
  117518. sideOrientation?: number;
  117519. frontUVs?: Vector4;
  117520. backUVs?: Vector4;
  117521. updatable?: boolean;
  117522. }, scene?: Nullable<Scene>): Mesh;
  117523. /**
  117524. * Creates a plane polygonal mesh. By default, this is a disc
  117525. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  117526. * * 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
  117527. * * 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
  117528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117530. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117531. * @param name defines the name of the mesh
  117532. * @param options defines the options used to create the mesh
  117533. * @param scene defines the hosting scene
  117534. * @returns the plane polygonal mesh
  117535. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  117536. */
  117537. static CreateDisc(name: string, options: {
  117538. radius?: number;
  117539. tessellation?: number;
  117540. arc?: number;
  117541. updatable?: boolean;
  117542. sideOrientation?: number;
  117543. frontUVs?: Vector4;
  117544. backUVs?: Vector4;
  117545. }, scene?: Nullable<Scene>): Mesh;
  117546. /**
  117547. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  117548. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  117549. * * 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`)
  117550. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  117551. * * 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
  117552. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117553. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117555. * @param name defines the name of the mesh
  117556. * @param options defines the options used to create the mesh
  117557. * @param scene defines the hosting scene
  117558. * @returns the icosahedron mesh
  117559. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  117560. */
  117561. static CreateIcoSphere(name: string, options: {
  117562. radius?: number;
  117563. radiusX?: number;
  117564. radiusY?: number;
  117565. radiusZ?: number;
  117566. flat?: boolean;
  117567. subdivisions?: number;
  117568. sideOrientation?: number;
  117569. frontUVs?: Vector4;
  117570. backUVs?: Vector4;
  117571. updatable?: boolean;
  117572. }, scene?: Nullable<Scene>): Mesh;
  117573. /**
  117574. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117575. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117576. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117577. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117578. * * 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
  117579. * * 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
  117580. * * 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
  117581. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117582. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117583. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117584. * * 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
  117585. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117586. * * 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
  117587. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117589. * @param name defines the name of the mesh
  117590. * @param options defines the options used to create the mesh
  117591. * @param scene defines the hosting scene
  117592. * @returns the ribbon mesh
  117593. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117594. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117595. */
  117596. static CreateRibbon(name: string, options: {
  117597. pathArray: Vector3[][];
  117598. closeArray?: boolean;
  117599. closePath?: boolean;
  117600. offset?: number;
  117601. updatable?: boolean;
  117602. sideOrientation?: number;
  117603. frontUVs?: Vector4;
  117604. backUVs?: Vector4;
  117605. instance?: Mesh;
  117606. invertUV?: boolean;
  117607. uvs?: Vector2[];
  117608. colors?: Color4[];
  117609. }, scene?: Nullable<Scene>): Mesh;
  117610. /**
  117611. * Creates a cylinder or a cone mesh
  117612. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117613. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117614. * * 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.
  117615. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117616. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117617. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117618. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117619. * * 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).
  117620. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117621. * * 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).
  117622. * * 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
  117623. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117624. * * 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
  117625. * * 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.
  117626. * * If `enclose` is false, a ring surface is one element.
  117627. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117628. * * 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
  117629. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117630. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117632. * @param name defines the name of the mesh
  117633. * @param options defines the options used to create the mesh
  117634. * @param scene defines the hosting scene
  117635. * @returns the cylinder mesh
  117636. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117637. */
  117638. static CreateCylinder(name: string, options: {
  117639. height?: number;
  117640. diameterTop?: number;
  117641. diameterBottom?: number;
  117642. diameter?: number;
  117643. tessellation?: number;
  117644. subdivisions?: number;
  117645. arc?: number;
  117646. faceColors?: Color4[];
  117647. faceUV?: Vector4[];
  117648. updatable?: boolean;
  117649. hasRings?: boolean;
  117650. enclose?: boolean;
  117651. cap?: number;
  117652. sideOrientation?: number;
  117653. frontUVs?: Vector4;
  117654. backUVs?: Vector4;
  117655. }, scene?: Nullable<Scene>): Mesh;
  117656. /**
  117657. * Creates a torus mesh
  117658. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117659. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117660. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117664. * @param name defines the name of the mesh
  117665. * @param options defines the options used to create the mesh
  117666. * @param scene defines the hosting scene
  117667. * @returns the torus mesh
  117668. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117669. */
  117670. static CreateTorus(name: string, options: {
  117671. diameter?: number;
  117672. thickness?: number;
  117673. tessellation?: number;
  117674. updatable?: boolean;
  117675. sideOrientation?: number;
  117676. frontUVs?: Vector4;
  117677. backUVs?: Vector4;
  117678. }, scene?: Nullable<Scene>): Mesh;
  117679. /**
  117680. * Creates a torus knot mesh
  117681. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  117682. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  117683. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  117684. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  117685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117688. * @param name defines the name of the mesh
  117689. * @param options defines the options used to create the mesh
  117690. * @param scene defines the hosting scene
  117691. * @returns the torus knot mesh
  117692. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  117693. */
  117694. static CreateTorusKnot(name: string, options: {
  117695. radius?: number;
  117696. tube?: number;
  117697. radialSegments?: number;
  117698. tubularSegments?: number;
  117699. p?: number;
  117700. q?: number;
  117701. updatable?: boolean;
  117702. sideOrientation?: number;
  117703. frontUVs?: Vector4;
  117704. backUVs?: Vector4;
  117705. }, scene?: Nullable<Scene>): Mesh;
  117706. /**
  117707. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117708. * * 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
  117709. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117710. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117711. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117712. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117713. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117714. * * 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
  117715. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117718. * @param name defines the name of the new line system
  117719. * @param options defines the options used to create the line system
  117720. * @param scene defines the hosting scene
  117721. * @returns a new line system mesh
  117722. */
  117723. static CreateLineSystem(name: string, options: {
  117724. lines: Vector3[][];
  117725. updatable?: boolean;
  117726. instance?: Nullable<LinesMesh>;
  117727. colors?: Nullable<Color4[][]>;
  117728. useVertexAlpha?: boolean;
  117729. }, scene: Nullable<Scene>): LinesMesh;
  117730. /**
  117731. * Creates a line mesh
  117732. * 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
  117733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117734. * * The parameter `points` is an array successive Vector3
  117735. * * 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
  117736. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117737. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117738. * * When updating an instance, remember that only point positions can change, not the number of points
  117739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117740. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117741. * @param name defines the name of the new line system
  117742. * @param options defines the options used to create the line system
  117743. * @param scene defines the hosting scene
  117744. * @returns a new line mesh
  117745. */
  117746. static CreateLines(name: string, options: {
  117747. points: Vector3[];
  117748. updatable?: boolean;
  117749. instance?: Nullable<LinesMesh>;
  117750. colors?: Color4[];
  117751. useVertexAlpha?: boolean;
  117752. }, scene?: Nullable<Scene>): LinesMesh;
  117753. /**
  117754. * Creates a dashed line mesh
  117755. * * 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
  117756. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117757. * * The parameter `points` is an array successive Vector3
  117758. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117759. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117760. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117761. * * 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
  117762. * * When updating an instance, remember that only point positions can change, not the number of points
  117763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117764. * @param name defines the name of the mesh
  117765. * @param options defines the options used to create the mesh
  117766. * @param scene defines the hosting scene
  117767. * @returns the dashed line mesh
  117768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117769. */
  117770. static CreateDashedLines(name: string, options: {
  117771. points: Vector3[];
  117772. dashSize?: number;
  117773. gapSize?: number;
  117774. dashNb?: number;
  117775. updatable?: boolean;
  117776. instance?: LinesMesh;
  117777. }, scene?: Nullable<Scene>): LinesMesh;
  117778. /**
  117779. * 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.
  117780. * * 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.
  117781. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117782. * * 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.
  117783. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117784. * * 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
  117785. * * 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
  117786. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117788. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117789. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117791. * @param name defines the name of the mesh
  117792. * @param options defines the options used to create the mesh
  117793. * @param scene defines the hosting scene
  117794. * @returns the extruded shape mesh
  117795. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117796. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117797. */
  117798. static ExtrudeShape(name: string, options: {
  117799. shape: Vector3[];
  117800. path: Vector3[];
  117801. scale?: number;
  117802. rotation?: number;
  117803. cap?: number;
  117804. updatable?: boolean;
  117805. sideOrientation?: number;
  117806. frontUVs?: Vector4;
  117807. backUVs?: Vector4;
  117808. instance?: Mesh;
  117809. invertUV?: boolean;
  117810. }, scene?: Nullable<Scene>): Mesh;
  117811. /**
  117812. * Creates an custom extruded shape mesh.
  117813. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117814. * * 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.
  117815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117816. * * 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
  117817. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117818. * * 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
  117819. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117820. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117821. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117822. * * 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
  117823. * * 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
  117824. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117825. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117826. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117827. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117828. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117829. * @param name defines the name of the mesh
  117830. * @param options defines the options used to create the mesh
  117831. * @param scene defines the hosting scene
  117832. * @returns the custom extruded shape mesh
  117833. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117834. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117835. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117836. */
  117837. static ExtrudeShapeCustom(name: string, options: {
  117838. shape: Vector3[];
  117839. path: Vector3[];
  117840. scaleFunction?: any;
  117841. rotationFunction?: any;
  117842. ribbonCloseArray?: boolean;
  117843. ribbonClosePath?: boolean;
  117844. cap?: number;
  117845. updatable?: boolean;
  117846. sideOrientation?: number;
  117847. frontUVs?: Vector4;
  117848. backUVs?: Vector4;
  117849. instance?: Mesh;
  117850. invertUV?: boolean;
  117851. }, scene?: Nullable<Scene>): Mesh;
  117852. /**
  117853. * Creates lathe mesh.
  117854. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  117855. * * 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
  117856. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  117857. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  117858. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  117859. * * 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
  117860. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  117861. * * 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
  117862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117863. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117864. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117865. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117866. * @param name defines the name of the mesh
  117867. * @param options defines the options used to create the mesh
  117868. * @param scene defines the hosting scene
  117869. * @returns the lathe mesh
  117870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  117871. */
  117872. static CreateLathe(name: string, options: {
  117873. shape: Vector3[];
  117874. radius?: number;
  117875. tessellation?: number;
  117876. clip?: number;
  117877. arc?: number;
  117878. closed?: boolean;
  117879. updatable?: boolean;
  117880. sideOrientation?: number;
  117881. frontUVs?: Vector4;
  117882. backUVs?: Vector4;
  117883. cap?: number;
  117884. invertUV?: boolean;
  117885. }, scene?: Nullable<Scene>): Mesh;
  117886. /**
  117887. * Creates a tiled plane mesh
  117888. * * You can set a limited pattern arrangement with the tiles
  117889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117892. * @param name defines the name of the mesh
  117893. * @param options defines the options used to create the mesh
  117894. * @param scene defines the hosting scene
  117895. * @returns the plane mesh
  117896. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117897. */
  117898. static CreateTiledPlane(name: string, options: {
  117899. pattern?: number;
  117900. tileSize?: number;
  117901. tileWidth?: number;
  117902. tileHeight?: number;
  117903. size?: number;
  117904. width?: number;
  117905. height?: number;
  117906. alignHorizontal?: number;
  117907. alignVertical?: number;
  117908. sideOrientation?: number;
  117909. frontUVs?: Vector4;
  117910. backUVs?: Vector4;
  117911. updatable?: boolean;
  117912. }, scene?: Nullable<Scene>): Mesh;
  117913. /**
  117914. * Creates a plane mesh
  117915. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  117916. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  117917. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  117918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117919. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117921. * @param name defines the name of the mesh
  117922. * @param options defines the options used to create the mesh
  117923. * @param scene defines the hosting scene
  117924. * @returns the plane mesh
  117925. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  117926. */
  117927. static CreatePlane(name: string, options: {
  117928. size?: number;
  117929. width?: number;
  117930. height?: number;
  117931. sideOrientation?: number;
  117932. frontUVs?: Vector4;
  117933. backUVs?: Vector4;
  117934. updatable?: boolean;
  117935. sourcePlane?: Plane;
  117936. }, scene?: Nullable<Scene>): Mesh;
  117937. /**
  117938. * Creates a ground mesh
  117939. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117940. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117942. * @param name defines the name of the mesh
  117943. * @param options defines the options used to create the mesh
  117944. * @param scene defines the hosting scene
  117945. * @returns the ground mesh
  117946. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117947. */
  117948. static CreateGround(name: string, options: {
  117949. width?: number;
  117950. height?: number;
  117951. subdivisions?: number;
  117952. subdivisionsX?: number;
  117953. subdivisionsY?: number;
  117954. updatable?: boolean;
  117955. }, scene?: Nullable<Scene>): Mesh;
  117956. /**
  117957. * Creates a tiled ground mesh
  117958. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117959. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117960. * * 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
  117961. * * 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
  117962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117963. * @param name defines the name of the mesh
  117964. * @param options defines the options used to create the mesh
  117965. * @param scene defines the hosting scene
  117966. * @returns the tiled ground mesh
  117967. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117968. */
  117969. static CreateTiledGround(name: string, options: {
  117970. xmin: number;
  117971. zmin: number;
  117972. xmax: number;
  117973. zmax: number;
  117974. subdivisions?: {
  117975. w: number;
  117976. h: number;
  117977. };
  117978. precision?: {
  117979. w: number;
  117980. h: number;
  117981. };
  117982. updatable?: boolean;
  117983. }, scene?: Nullable<Scene>): Mesh;
  117984. /**
  117985. * Creates a ground mesh from a height map
  117986. * * The parameter `url` sets the URL of the height map image resource.
  117987. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117988. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117989. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117990. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117991. * * 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.
  117992. * * 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).
  117993. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117995. * @param name defines the name of the mesh
  117996. * @param url defines the url to the height map
  117997. * @param options defines the options used to create the mesh
  117998. * @param scene defines the hosting scene
  117999. * @returns the ground mesh
  118000. * @see https://doc.babylonjs.com/babylon101/height_map
  118001. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  118002. */
  118003. static CreateGroundFromHeightMap(name: string, url: string, options: {
  118004. width?: number;
  118005. height?: number;
  118006. subdivisions?: number;
  118007. minHeight?: number;
  118008. maxHeight?: number;
  118009. colorFilter?: Color3;
  118010. alphaFilter?: number;
  118011. updatable?: boolean;
  118012. onReady?: (mesh: GroundMesh) => void;
  118013. }, scene?: Nullable<Scene>): GroundMesh;
  118014. /**
  118015. * Creates a polygon mesh
  118016. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  118017. * * 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
  118018. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  118019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118020. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  118021. * * Remember you can only change the shape positions, not their number when updating a polygon
  118022. * @param name defines the name of the mesh
  118023. * @param options defines the options used to create the mesh
  118024. * @param scene defines the hosting scene
  118025. * @param earcutInjection can be used to inject your own earcut reference
  118026. * @returns the polygon mesh
  118027. */
  118028. static CreatePolygon(name: string, options: {
  118029. shape: Vector3[];
  118030. holes?: Vector3[][];
  118031. depth?: number;
  118032. faceUV?: Vector4[];
  118033. faceColors?: Color4[];
  118034. updatable?: boolean;
  118035. sideOrientation?: number;
  118036. frontUVs?: Vector4;
  118037. backUVs?: Vector4;
  118038. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118039. /**
  118040. * Creates an extruded polygon mesh, with depth in the Y direction.
  118041. * * 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)
  118042. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  118043. * @param name defines the name of the mesh
  118044. * @param options defines the options used to create the mesh
  118045. * @param scene defines the hosting scene
  118046. * @param earcutInjection can be used to inject your own earcut reference
  118047. * @returns the polygon mesh
  118048. */
  118049. static ExtrudePolygon(name: string, options: {
  118050. shape: Vector3[];
  118051. holes?: Vector3[][];
  118052. depth?: number;
  118053. faceUV?: Vector4[];
  118054. faceColors?: Color4[];
  118055. updatable?: boolean;
  118056. sideOrientation?: number;
  118057. frontUVs?: Vector4;
  118058. backUVs?: Vector4;
  118059. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  118060. /**
  118061. * Creates a tube mesh.
  118062. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  118063. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  118064. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  118065. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  118066. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  118067. * * 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)
  118068. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  118069. * * 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
  118070. * * 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
  118071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118075. * @param name defines the name of the mesh
  118076. * @param options defines the options used to create the mesh
  118077. * @param scene defines the hosting scene
  118078. * @returns the tube mesh
  118079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118080. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  118081. */
  118082. static CreateTube(name: string, options: {
  118083. path: Vector3[];
  118084. radius?: number;
  118085. tessellation?: number;
  118086. radiusFunction?: {
  118087. (i: number, distance: number): number;
  118088. };
  118089. cap?: number;
  118090. arc?: number;
  118091. updatable?: boolean;
  118092. sideOrientation?: number;
  118093. frontUVs?: Vector4;
  118094. backUVs?: Vector4;
  118095. instance?: Mesh;
  118096. invertUV?: boolean;
  118097. }, scene?: Nullable<Scene>): Mesh;
  118098. /**
  118099. * Creates a polyhedron mesh
  118100. * * 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
  118101. * * The parameter `size` (positive float, default 1) sets the polygon size
  118102. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  118103. * * 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`
  118104. * * 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
  118105. * * 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)`)
  118106. * * 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
  118107. * * 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
  118108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118111. * @param name defines the name of the mesh
  118112. * @param options defines the options used to create the mesh
  118113. * @param scene defines the hosting scene
  118114. * @returns the polyhedron mesh
  118115. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  118116. */
  118117. static CreatePolyhedron(name: string, options: {
  118118. type?: number;
  118119. size?: number;
  118120. sizeX?: number;
  118121. sizeY?: number;
  118122. sizeZ?: number;
  118123. custom?: any;
  118124. faceUV?: Vector4[];
  118125. faceColors?: Color4[];
  118126. flat?: boolean;
  118127. updatable?: boolean;
  118128. sideOrientation?: number;
  118129. frontUVs?: Vector4;
  118130. backUVs?: Vector4;
  118131. }, scene?: Nullable<Scene>): Mesh;
  118132. /**
  118133. * Creates a decal mesh.
  118134. * 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
  118135. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  118136. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  118137. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  118138. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  118139. * @param name defines the name of the mesh
  118140. * @param sourceMesh defines the mesh where the decal must be applied
  118141. * @param options defines the options used to create the mesh
  118142. * @param scene defines the hosting scene
  118143. * @returns the decal mesh
  118144. * @see https://doc.babylonjs.com/how_to/decals
  118145. */
  118146. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  118147. position?: Vector3;
  118148. normal?: Vector3;
  118149. size?: Vector3;
  118150. angle?: number;
  118151. }): Mesh;
  118152. }
  118153. }
  118154. declare module BABYLON {
  118155. /**
  118156. * A simplifier interface for future simplification implementations
  118157. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118158. */
  118159. export interface ISimplifier {
  118160. /**
  118161. * Simplification of a given mesh according to the given settings.
  118162. * Since this requires computation, it is assumed that the function runs async.
  118163. * @param settings The settings of the simplification, including quality and distance
  118164. * @param successCallback A callback that will be called after the mesh was simplified.
  118165. * @param errorCallback in case of an error, this callback will be called. optional.
  118166. */
  118167. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  118168. }
  118169. /**
  118170. * Expected simplification settings.
  118171. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  118172. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118173. */
  118174. export interface ISimplificationSettings {
  118175. /**
  118176. * Gets or sets the expected quality
  118177. */
  118178. quality: number;
  118179. /**
  118180. * Gets or sets the distance when this optimized version should be used
  118181. */
  118182. distance: number;
  118183. /**
  118184. * Gets an already optimized mesh
  118185. */
  118186. optimizeMesh?: boolean;
  118187. }
  118188. /**
  118189. * Class used to specify simplification options
  118190. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118191. */
  118192. export class SimplificationSettings implements ISimplificationSettings {
  118193. /** expected quality */
  118194. quality: number;
  118195. /** distance when this optimized version should be used */
  118196. distance: number;
  118197. /** already optimized mesh */
  118198. optimizeMesh?: boolean | undefined;
  118199. /**
  118200. * Creates a SimplificationSettings
  118201. * @param quality expected quality
  118202. * @param distance distance when this optimized version should be used
  118203. * @param optimizeMesh already optimized mesh
  118204. */
  118205. constructor(
  118206. /** expected quality */
  118207. quality: number,
  118208. /** distance when this optimized version should be used */
  118209. distance: number,
  118210. /** already optimized mesh */
  118211. optimizeMesh?: boolean | undefined);
  118212. }
  118213. /**
  118214. * Interface used to define a simplification task
  118215. */
  118216. export interface ISimplificationTask {
  118217. /**
  118218. * Array of settings
  118219. */
  118220. settings: Array<ISimplificationSettings>;
  118221. /**
  118222. * Simplification type
  118223. */
  118224. simplificationType: SimplificationType;
  118225. /**
  118226. * Mesh to simplify
  118227. */
  118228. mesh: Mesh;
  118229. /**
  118230. * Callback called on success
  118231. */
  118232. successCallback?: () => void;
  118233. /**
  118234. * Defines if parallel processing can be used
  118235. */
  118236. parallelProcessing: boolean;
  118237. }
  118238. /**
  118239. * Queue used to order the simplification tasks
  118240. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118241. */
  118242. export class SimplificationQueue {
  118243. private _simplificationArray;
  118244. /**
  118245. * Gets a boolean indicating that the process is still running
  118246. */
  118247. running: boolean;
  118248. /**
  118249. * Creates a new queue
  118250. */
  118251. constructor();
  118252. /**
  118253. * Adds a new simplification task
  118254. * @param task defines a task to add
  118255. */
  118256. addTask(task: ISimplificationTask): void;
  118257. /**
  118258. * Execute next task
  118259. */
  118260. executeNext(): void;
  118261. /**
  118262. * Execute a simplification task
  118263. * @param task defines the task to run
  118264. */
  118265. runSimplification(task: ISimplificationTask): void;
  118266. private getSimplifier;
  118267. }
  118268. /**
  118269. * The implemented types of simplification
  118270. * At the moment only Quadratic Error Decimation is implemented
  118271. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118272. */
  118273. export enum SimplificationType {
  118274. /** Quadratic error decimation */
  118275. QUADRATIC = 0
  118276. }
  118277. }
  118278. declare module BABYLON {
  118279. interface Scene {
  118280. /** @hidden (Backing field) */
  118281. _simplificationQueue: SimplificationQueue;
  118282. /**
  118283. * Gets or sets the simplification queue attached to the scene
  118284. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  118285. */
  118286. simplificationQueue: SimplificationQueue;
  118287. }
  118288. interface Mesh {
  118289. /**
  118290. * Simplify the mesh according to the given array of settings.
  118291. * Function will return immediately and will simplify async
  118292. * @param settings a collection of simplification settings
  118293. * @param parallelProcessing should all levels calculate parallel or one after the other
  118294. * @param simplificationType the type of simplification to run
  118295. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  118296. * @returns the current mesh
  118297. */
  118298. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  118299. }
  118300. /**
  118301. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  118302. * created in a scene
  118303. */
  118304. export class SimplicationQueueSceneComponent implements ISceneComponent {
  118305. /**
  118306. * The component name helpfull to identify the component in the list of scene components.
  118307. */
  118308. readonly name: string;
  118309. /**
  118310. * The scene the component belongs to.
  118311. */
  118312. scene: Scene;
  118313. /**
  118314. * Creates a new instance of the component for the given scene
  118315. * @param scene Defines the scene to register the component in
  118316. */
  118317. constructor(scene: Scene);
  118318. /**
  118319. * Registers the component in a given scene
  118320. */
  118321. register(): void;
  118322. /**
  118323. * Rebuilds the elements related to this component in case of
  118324. * context lost for instance.
  118325. */
  118326. rebuild(): void;
  118327. /**
  118328. * Disposes the component and the associated ressources
  118329. */
  118330. dispose(): void;
  118331. private _beforeCameraUpdate;
  118332. }
  118333. }
  118334. declare module BABYLON {
  118335. /**
  118336. * Navigation plugin interface to add navigation constrained by a navigation mesh
  118337. */
  118338. export interface INavigationEnginePlugin {
  118339. /**
  118340. * plugin name
  118341. */
  118342. name: string;
  118343. /**
  118344. * Creates a navigation mesh
  118345. * @param meshes array of all the geometry used to compute the navigatio mesh
  118346. * @param parameters bunch of parameters used to filter geometry
  118347. */
  118348. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118349. /**
  118350. * Create a navigation mesh debug mesh
  118351. * @param scene is where the mesh will be added
  118352. * @returns debug display mesh
  118353. */
  118354. createDebugNavMesh(scene: Scene): Mesh;
  118355. /**
  118356. * Get a navigation mesh constrained position, closest to the parameter position
  118357. * @param position world position
  118358. * @returns the closest point to position constrained by the navigation mesh
  118359. */
  118360. getClosestPoint(position: Vector3): Vector3;
  118361. /**
  118362. * Get a navigation mesh constrained position, within a particular radius
  118363. * @param position world position
  118364. * @param maxRadius the maximum distance to the constrained world position
  118365. * @returns the closest point to position constrained by the navigation mesh
  118366. */
  118367. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118368. /**
  118369. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118370. * @param start world position
  118371. * @param end world position
  118372. * @returns array containing world position composing the path
  118373. */
  118374. computePath(start: Vector3, end: Vector3): Vector3[];
  118375. /**
  118376. * If this plugin is supported
  118377. * @returns true if plugin is supported
  118378. */
  118379. isSupported(): boolean;
  118380. /**
  118381. * Create a new Crowd so you can add agents
  118382. * @param maxAgents the maximum agent count in the crowd
  118383. * @param maxAgentRadius the maximum radius an agent can have
  118384. * @param scene to attach the crowd to
  118385. * @returns the crowd you can add agents to
  118386. */
  118387. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118388. /**
  118389. * Release all resources
  118390. */
  118391. dispose(): void;
  118392. }
  118393. /**
  118394. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  118395. */
  118396. export interface ICrowd {
  118397. /**
  118398. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118399. * You can attach anything to that node. The node position is updated in the scene update tick.
  118400. * @param pos world position that will be constrained by the navigation mesh
  118401. * @param parameters agent parameters
  118402. * @param transform hooked to the agent that will be update by the scene
  118403. * @returns agent index
  118404. */
  118405. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118406. /**
  118407. * Returns the agent position in world space
  118408. * @param index agent index returned by addAgent
  118409. * @returns world space position
  118410. */
  118411. getAgentPosition(index: number): Vector3;
  118412. /**
  118413. * Gets the agent velocity in world space
  118414. * @param index agent index returned by addAgent
  118415. * @returns world space velocity
  118416. */
  118417. getAgentVelocity(index: number): Vector3;
  118418. /**
  118419. * remove a particular agent previously created
  118420. * @param index agent index returned by addAgent
  118421. */
  118422. removeAgent(index: number): void;
  118423. /**
  118424. * get the list of all agents attached to this crowd
  118425. * @returns list of agent indices
  118426. */
  118427. getAgents(): number[];
  118428. /**
  118429. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118430. * @param deltaTime in seconds
  118431. */
  118432. update(deltaTime: number): void;
  118433. /**
  118434. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118435. * @param index agent index returned by addAgent
  118436. * @param destination targeted world position
  118437. */
  118438. agentGoto(index: number, destination: Vector3): void;
  118439. /**
  118440. * Release all resources
  118441. */
  118442. dispose(): void;
  118443. }
  118444. /**
  118445. * Configures an agent
  118446. */
  118447. export interface IAgentParameters {
  118448. /**
  118449. * Agent radius. [Limit: >= 0]
  118450. */
  118451. radius: number;
  118452. /**
  118453. * Agent height. [Limit: > 0]
  118454. */
  118455. height: number;
  118456. /**
  118457. * Maximum allowed acceleration. [Limit: >= 0]
  118458. */
  118459. maxAcceleration: number;
  118460. /**
  118461. * Maximum allowed speed. [Limit: >= 0]
  118462. */
  118463. maxSpeed: number;
  118464. /**
  118465. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  118466. */
  118467. collisionQueryRange: number;
  118468. /**
  118469. * The path visibility optimization range. [Limit: > 0]
  118470. */
  118471. pathOptimizationRange: number;
  118472. /**
  118473. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  118474. */
  118475. separationWeight: number;
  118476. }
  118477. /**
  118478. * Configures the navigation mesh creation
  118479. */
  118480. export interface INavMeshParameters {
  118481. /**
  118482. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  118483. */
  118484. cs: number;
  118485. /**
  118486. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  118487. */
  118488. ch: number;
  118489. /**
  118490. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  118491. */
  118492. walkableSlopeAngle: number;
  118493. /**
  118494. * Minimum floor to 'ceiling' height that will still allow the floor area to
  118495. * be considered walkable. [Limit: >= 3] [Units: vx]
  118496. */
  118497. walkableHeight: number;
  118498. /**
  118499. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  118500. */
  118501. walkableClimb: number;
  118502. /**
  118503. * The distance to erode/shrink the walkable area of the heightfield away from
  118504. * obstructions. [Limit: >=0] [Units: vx]
  118505. */
  118506. walkableRadius: number;
  118507. /**
  118508. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  118509. */
  118510. maxEdgeLen: number;
  118511. /**
  118512. * The maximum distance a simplfied contour's border edges should deviate
  118513. * the original raw contour. [Limit: >=0] [Units: vx]
  118514. */
  118515. maxSimplificationError: number;
  118516. /**
  118517. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  118518. */
  118519. minRegionArea: number;
  118520. /**
  118521. * Any regions with a span count smaller than this value will, if possible,
  118522. * be merged with larger regions. [Limit: >=0] [Units: vx]
  118523. */
  118524. mergeRegionArea: number;
  118525. /**
  118526. * The maximum number of vertices allowed for polygons generated during the
  118527. * contour to polygon conversion process. [Limit: >= 3]
  118528. */
  118529. maxVertsPerPoly: number;
  118530. /**
  118531. * Sets the sampling distance to use when generating the detail mesh.
  118532. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  118533. */
  118534. detailSampleDist: number;
  118535. /**
  118536. * The maximum distance the detail mesh surface should deviate from heightfield
  118537. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  118538. */
  118539. detailSampleMaxError: number;
  118540. }
  118541. }
  118542. declare module BABYLON {
  118543. /**
  118544. * RecastJS navigation plugin
  118545. */
  118546. export class RecastJSPlugin implements INavigationEnginePlugin {
  118547. /**
  118548. * Reference to the Recast library
  118549. */
  118550. bjsRECAST: any;
  118551. /**
  118552. * plugin name
  118553. */
  118554. name: string;
  118555. /**
  118556. * the first navmesh created. We might extend this to support multiple navmeshes
  118557. */
  118558. navMesh: any;
  118559. /**
  118560. * Initializes the recastJS plugin
  118561. * @param recastInjection can be used to inject your own recast reference
  118562. */
  118563. constructor(recastInjection?: any);
  118564. /**
  118565. * Creates a navigation mesh
  118566. * @param meshes array of all the geometry used to compute the navigatio mesh
  118567. * @param parameters bunch of parameters used to filter geometry
  118568. */
  118569. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  118570. /**
  118571. * Create a navigation mesh debug mesh
  118572. * @param scene is where the mesh will be added
  118573. * @returns debug display mesh
  118574. */
  118575. createDebugNavMesh(scene: Scene): Mesh;
  118576. /**
  118577. * Get a navigation mesh constrained position, closest to the parameter position
  118578. * @param position world position
  118579. * @returns the closest point to position constrained by the navigation mesh
  118580. */
  118581. getClosestPoint(position: Vector3): Vector3;
  118582. /**
  118583. * Get a navigation mesh constrained position, within a particular radius
  118584. * @param position world position
  118585. * @param maxRadius the maximum distance to the constrained world position
  118586. * @returns the closest point to position constrained by the navigation mesh
  118587. */
  118588. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  118589. /**
  118590. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  118591. * @param start world position
  118592. * @param end world position
  118593. * @returns array containing world position composing the path
  118594. */
  118595. computePath(start: Vector3, end: Vector3): Vector3[];
  118596. /**
  118597. * Create a new Crowd so you can add agents
  118598. * @param maxAgents the maximum agent count in the crowd
  118599. * @param maxAgentRadius the maximum radius an agent can have
  118600. * @param scene to attach the crowd to
  118601. * @returns the crowd you can add agents to
  118602. */
  118603. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  118604. /**
  118605. * Disposes
  118606. */
  118607. dispose(): void;
  118608. /**
  118609. * If this plugin is supported
  118610. * @returns true if plugin is supported
  118611. */
  118612. isSupported(): boolean;
  118613. }
  118614. /**
  118615. * Recast detour crowd implementation
  118616. */
  118617. export class RecastJSCrowd implements ICrowd {
  118618. /**
  118619. * Recast/detour plugin
  118620. */
  118621. bjsRECASTPlugin: RecastJSPlugin;
  118622. /**
  118623. * Link to the detour crowd
  118624. */
  118625. recastCrowd: any;
  118626. /**
  118627. * One transform per agent
  118628. */
  118629. transforms: TransformNode[];
  118630. /**
  118631. * All agents created
  118632. */
  118633. agents: number[];
  118634. /**
  118635. * Link to the scene is kept to unregister the crowd from the scene
  118636. */
  118637. private _scene;
  118638. /**
  118639. * Observer for crowd updates
  118640. */
  118641. private _onBeforeAnimationsObserver;
  118642. /**
  118643. * Constructor
  118644. * @param plugin recastJS plugin
  118645. * @param maxAgents the maximum agent count in the crowd
  118646. * @param maxAgentRadius the maximum radius an agent can have
  118647. * @param scene to attach the crowd to
  118648. * @returns the crowd you can add agents to
  118649. */
  118650. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  118651. /**
  118652. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  118653. * You can attach anything to that node. The node position is updated in the scene update tick.
  118654. * @param pos world position that will be constrained by the navigation mesh
  118655. * @param parameters agent parameters
  118656. * @param transform hooked to the agent that will be update by the scene
  118657. * @returns agent index
  118658. */
  118659. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  118660. /**
  118661. * Returns the agent position in world space
  118662. * @param index agent index returned by addAgent
  118663. * @returns world space position
  118664. */
  118665. getAgentPosition(index: number): Vector3;
  118666. /**
  118667. * Returns the agent velocity in world space
  118668. * @param index agent index returned by addAgent
  118669. * @returns world space velocity
  118670. */
  118671. getAgentVelocity(index: number): Vector3;
  118672. /**
  118673. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  118674. * @param index agent index returned by addAgent
  118675. * @param destination targeted world position
  118676. */
  118677. agentGoto(index: number, destination: Vector3): void;
  118678. /**
  118679. * remove a particular agent previously created
  118680. * @param index agent index returned by addAgent
  118681. */
  118682. removeAgent(index: number): void;
  118683. /**
  118684. * get the list of all agents attached to this crowd
  118685. * @returns list of agent indices
  118686. */
  118687. getAgents(): number[];
  118688. /**
  118689. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  118690. * @param deltaTime in seconds
  118691. */
  118692. update(deltaTime: number): void;
  118693. /**
  118694. * Release all resources
  118695. */
  118696. dispose(): void;
  118697. }
  118698. }
  118699. declare module BABYLON {
  118700. /**
  118701. * Class used to enable access to IndexedDB
  118702. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  118703. */
  118704. export class Database implements IOfflineProvider {
  118705. private _callbackManifestChecked;
  118706. private _currentSceneUrl;
  118707. private _db;
  118708. private _enableSceneOffline;
  118709. private _enableTexturesOffline;
  118710. private _manifestVersionFound;
  118711. private _mustUpdateRessources;
  118712. private _hasReachedQuota;
  118713. private _isSupported;
  118714. private _idbFactory;
  118715. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  118716. private static IsUASupportingBlobStorage;
  118717. /**
  118718. * Gets a boolean indicating if Database storate is enabled (off by default)
  118719. */
  118720. static IDBStorageEnabled: boolean;
  118721. /**
  118722. * Gets a boolean indicating if scene must be saved in the database
  118723. */
  118724. readonly enableSceneOffline: boolean;
  118725. /**
  118726. * Gets a boolean indicating if textures must be saved in the database
  118727. */
  118728. readonly enableTexturesOffline: boolean;
  118729. /**
  118730. * Creates a new Database
  118731. * @param urlToScene defines the url to load the scene
  118732. * @param callbackManifestChecked defines the callback to use when manifest is checked
  118733. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  118734. */
  118735. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  118736. private static _ParseURL;
  118737. private static _ReturnFullUrlLocation;
  118738. private _checkManifestFile;
  118739. /**
  118740. * Open the database and make it available
  118741. * @param successCallback defines the callback to call on success
  118742. * @param errorCallback defines the callback to call on error
  118743. */
  118744. open(successCallback: () => void, errorCallback: () => void): void;
  118745. /**
  118746. * Loads an image from the database
  118747. * @param url defines the url to load from
  118748. * @param image defines the target DOM image
  118749. */
  118750. loadImage(url: string, image: HTMLImageElement): void;
  118751. private _loadImageFromDBAsync;
  118752. private _saveImageIntoDBAsync;
  118753. private _checkVersionFromDB;
  118754. private _loadVersionFromDBAsync;
  118755. private _saveVersionIntoDBAsync;
  118756. /**
  118757. * Loads a file from database
  118758. * @param url defines the URL to load from
  118759. * @param sceneLoaded defines a callback to call on success
  118760. * @param progressCallBack defines a callback to call when progress changed
  118761. * @param errorCallback defines a callback to call on error
  118762. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  118763. */
  118764. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  118765. private _loadFileAsync;
  118766. private _saveFileAsync;
  118767. /**
  118768. * Validates if xhr data is correct
  118769. * @param xhr defines the request to validate
  118770. * @param dataType defines the expected data type
  118771. * @returns true if data is correct
  118772. */
  118773. private static _ValidateXHRData;
  118774. }
  118775. }
  118776. declare module BABYLON {
  118777. /** @hidden */
  118778. export var gpuUpdateParticlesPixelShader: {
  118779. name: string;
  118780. shader: string;
  118781. };
  118782. }
  118783. declare module BABYLON {
  118784. /** @hidden */
  118785. export var gpuUpdateParticlesVertexShader: {
  118786. name: string;
  118787. shader: string;
  118788. };
  118789. }
  118790. declare module BABYLON {
  118791. /** @hidden */
  118792. export var clipPlaneFragmentDeclaration2: {
  118793. name: string;
  118794. shader: string;
  118795. };
  118796. }
  118797. declare module BABYLON {
  118798. /** @hidden */
  118799. export var gpuRenderParticlesPixelShader: {
  118800. name: string;
  118801. shader: string;
  118802. };
  118803. }
  118804. declare module BABYLON {
  118805. /** @hidden */
  118806. export var clipPlaneVertexDeclaration2: {
  118807. name: string;
  118808. shader: string;
  118809. };
  118810. }
  118811. declare module BABYLON {
  118812. /** @hidden */
  118813. export var gpuRenderParticlesVertexShader: {
  118814. name: string;
  118815. shader: string;
  118816. };
  118817. }
  118818. declare module BABYLON {
  118819. /**
  118820. * This represents a GPU particle system in Babylon
  118821. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  118822. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  118823. */
  118824. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  118825. /**
  118826. * The layer mask we are rendering the particles through.
  118827. */
  118828. layerMask: number;
  118829. private _capacity;
  118830. private _activeCount;
  118831. private _currentActiveCount;
  118832. private _accumulatedCount;
  118833. private _renderEffect;
  118834. private _updateEffect;
  118835. private _buffer0;
  118836. private _buffer1;
  118837. private _spriteBuffer;
  118838. private _updateVAO;
  118839. private _renderVAO;
  118840. private _targetIndex;
  118841. private _sourceBuffer;
  118842. private _targetBuffer;
  118843. private _engine;
  118844. private _currentRenderId;
  118845. private _started;
  118846. private _stopped;
  118847. private _timeDelta;
  118848. private _randomTexture;
  118849. private _randomTexture2;
  118850. private _attributesStrideSize;
  118851. private _updateEffectOptions;
  118852. private _randomTextureSize;
  118853. private _actualFrame;
  118854. private readonly _rawTextureWidth;
  118855. /**
  118856. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  118857. */
  118858. static readonly IsSupported: boolean;
  118859. /**
  118860. * An event triggered when the system is disposed.
  118861. */
  118862. onDisposeObservable: Observable<GPUParticleSystem>;
  118863. /**
  118864. * Gets the maximum number of particles active at the same time.
  118865. * @returns The max number of active particles.
  118866. */
  118867. getCapacity(): number;
  118868. /**
  118869. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  118870. * to override the particles.
  118871. */
  118872. forceDepthWrite: boolean;
  118873. /**
  118874. * Gets or set the number of active particles
  118875. */
  118876. activeParticleCount: number;
  118877. private _preWarmDone;
  118878. /**
  118879. * Is this system ready to be used/rendered
  118880. * @return true if the system is ready
  118881. */
  118882. isReady(): boolean;
  118883. /**
  118884. * Gets if the system has been started. (Note: this will still be true after stop is called)
  118885. * @returns True if it has been started, otherwise false.
  118886. */
  118887. isStarted(): boolean;
  118888. /**
  118889. * Starts the particle system and begins to emit
  118890. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  118891. */
  118892. start(delay?: number): void;
  118893. /**
  118894. * Stops the particle system.
  118895. */
  118896. stop(): void;
  118897. /**
  118898. * Remove all active particles
  118899. */
  118900. reset(): void;
  118901. /**
  118902. * Returns the string "GPUParticleSystem"
  118903. * @returns a string containing the class name
  118904. */
  118905. getClassName(): string;
  118906. private _colorGradientsTexture;
  118907. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  118908. /**
  118909. * Adds a new color gradient
  118910. * @param gradient defines the gradient to use (between 0 and 1)
  118911. * @param color1 defines the color to affect to the specified gradient
  118912. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  118913. * @returns the current particle system
  118914. */
  118915. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  118916. /**
  118917. * Remove a specific color gradient
  118918. * @param gradient defines the gradient to remove
  118919. * @returns the current particle system
  118920. */
  118921. removeColorGradient(gradient: number): GPUParticleSystem;
  118922. private _angularSpeedGradientsTexture;
  118923. private _sizeGradientsTexture;
  118924. private _velocityGradientsTexture;
  118925. private _limitVelocityGradientsTexture;
  118926. private _dragGradientsTexture;
  118927. private _addFactorGradient;
  118928. /**
  118929. * Adds a new size gradient
  118930. * @param gradient defines the gradient to use (between 0 and 1)
  118931. * @param factor defines the size factor to affect to the specified gradient
  118932. * @returns the current particle system
  118933. */
  118934. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  118935. /**
  118936. * Remove a specific size gradient
  118937. * @param gradient defines the gradient to remove
  118938. * @returns the current particle system
  118939. */
  118940. removeSizeGradient(gradient: number): GPUParticleSystem;
  118941. /**
  118942. * Adds a new angular speed gradient
  118943. * @param gradient defines the gradient to use (between 0 and 1)
  118944. * @param factor defines the angular speed to affect to the specified gradient
  118945. * @returns the current particle system
  118946. */
  118947. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  118948. /**
  118949. * Remove a specific angular speed gradient
  118950. * @param gradient defines the gradient to remove
  118951. * @returns the current particle system
  118952. */
  118953. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  118954. /**
  118955. * Adds a new velocity gradient
  118956. * @param gradient defines the gradient to use (between 0 and 1)
  118957. * @param factor defines the velocity to affect to the specified gradient
  118958. * @returns the current particle system
  118959. */
  118960. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  118961. /**
  118962. * Remove a specific velocity gradient
  118963. * @param gradient defines the gradient to remove
  118964. * @returns the current particle system
  118965. */
  118966. removeVelocityGradient(gradient: number): GPUParticleSystem;
  118967. /**
  118968. * Adds a new limit velocity gradient
  118969. * @param gradient defines the gradient to use (between 0 and 1)
  118970. * @param factor defines the limit velocity value to affect to the specified gradient
  118971. * @returns the current particle system
  118972. */
  118973. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  118974. /**
  118975. * Remove a specific limit velocity gradient
  118976. * @param gradient defines the gradient to remove
  118977. * @returns the current particle system
  118978. */
  118979. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  118980. /**
  118981. * Adds a new drag gradient
  118982. * @param gradient defines the gradient to use (between 0 and 1)
  118983. * @param factor defines the drag value to affect to the specified gradient
  118984. * @returns the current particle system
  118985. */
  118986. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  118987. /**
  118988. * Remove a specific drag gradient
  118989. * @param gradient defines the gradient to remove
  118990. * @returns the current particle system
  118991. */
  118992. removeDragGradient(gradient: number): GPUParticleSystem;
  118993. /**
  118994. * Not supported by GPUParticleSystem
  118995. * @param gradient defines the gradient to use (between 0 and 1)
  118996. * @param factor defines the emit rate value to affect to the specified gradient
  118997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  118998. * @returns the current particle system
  118999. */
  119000. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119001. /**
  119002. * Not supported by GPUParticleSystem
  119003. * @param gradient defines the gradient to remove
  119004. * @returns the current particle system
  119005. */
  119006. removeEmitRateGradient(gradient: number): IParticleSystem;
  119007. /**
  119008. * Not supported by GPUParticleSystem
  119009. * @param gradient defines the gradient to use (between 0 and 1)
  119010. * @param factor defines the start size value to affect to the specified gradient
  119011. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119012. * @returns the current particle system
  119013. */
  119014. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119015. /**
  119016. * Not supported by GPUParticleSystem
  119017. * @param gradient defines the gradient to remove
  119018. * @returns the current particle system
  119019. */
  119020. removeStartSizeGradient(gradient: number): IParticleSystem;
  119021. /**
  119022. * Not supported by GPUParticleSystem
  119023. * @param gradient defines the gradient to use (between 0 and 1)
  119024. * @param min defines the color remap minimal range
  119025. * @param max defines the color remap maximal range
  119026. * @returns the current particle system
  119027. */
  119028. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119029. /**
  119030. * Not supported by GPUParticleSystem
  119031. * @param gradient defines the gradient to remove
  119032. * @returns the current particle system
  119033. */
  119034. removeColorRemapGradient(): IParticleSystem;
  119035. /**
  119036. * Not supported by GPUParticleSystem
  119037. * @param gradient defines the gradient to use (between 0 and 1)
  119038. * @param min defines the alpha remap minimal range
  119039. * @param max defines the alpha remap maximal range
  119040. * @returns the current particle system
  119041. */
  119042. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  119043. /**
  119044. * Not supported by GPUParticleSystem
  119045. * @param gradient defines the gradient to remove
  119046. * @returns the current particle system
  119047. */
  119048. removeAlphaRemapGradient(): IParticleSystem;
  119049. /**
  119050. * Not supported by GPUParticleSystem
  119051. * @param gradient defines the gradient to use (between 0 and 1)
  119052. * @param color defines the color to affect to the specified gradient
  119053. * @returns the current particle system
  119054. */
  119055. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  119056. /**
  119057. * Not supported by GPUParticleSystem
  119058. * @param gradient defines the gradient to remove
  119059. * @returns the current particle system
  119060. */
  119061. removeRampGradient(): IParticleSystem;
  119062. /**
  119063. * Not supported by GPUParticleSystem
  119064. * @returns the list of ramp gradients
  119065. */
  119066. getRampGradients(): Nullable<Array<Color3Gradient>>;
  119067. /**
  119068. * Not supported by GPUParticleSystem
  119069. * Gets or sets a boolean indicating that ramp gradients must be used
  119070. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  119071. */
  119072. useRampGradients: boolean;
  119073. /**
  119074. * Not supported by GPUParticleSystem
  119075. * @param gradient defines the gradient to use (between 0 and 1)
  119076. * @param factor defines the life time factor to affect to the specified gradient
  119077. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  119078. * @returns the current particle system
  119079. */
  119080. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  119081. /**
  119082. * Not supported by GPUParticleSystem
  119083. * @param gradient defines the gradient to remove
  119084. * @returns the current particle system
  119085. */
  119086. removeLifeTimeGradient(gradient: number): IParticleSystem;
  119087. /**
  119088. * Instantiates a GPU particle system.
  119089. * 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.
  119090. * @param name The name of the particle system
  119091. * @param options The options used to create the system
  119092. * @param scene The scene the particle system belongs to
  119093. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  119094. */
  119095. constructor(name: string, options: Partial<{
  119096. capacity: number;
  119097. randomTextureSize: number;
  119098. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  119099. protected _reset(): void;
  119100. private _createUpdateVAO;
  119101. private _createRenderVAO;
  119102. private _initialize;
  119103. /** @hidden */
  119104. _recreateUpdateEffect(): void;
  119105. /** @hidden */
  119106. _recreateRenderEffect(): void;
  119107. /**
  119108. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  119109. * @param preWarm defines if we are in the pre-warmimg phase
  119110. */
  119111. animate(preWarm?: boolean): void;
  119112. private _createFactorGradientTexture;
  119113. private _createSizeGradientTexture;
  119114. private _createAngularSpeedGradientTexture;
  119115. private _createVelocityGradientTexture;
  119116. private _createLimitVelocityGradientTexture;
  119117. private _createDragGradientTexture;
  119118. private _createColorGradientTexture;
  119119. /**
  119120. * Renders the particle system in its current state
  119121. * @param preWarm defines if the system should only update the particles but not render them
  119122. * @returns the current number of particles
  119123. */
  119124. render(preWarm?: boolean): number;
  119125. /**
  119126. * Rebuilds the particle system
  119127. */
  119128. rebuild(): void;
  119129. private _releaseBuffers;
  119130. private _releaseVAOs;
  119131. /**
  119132. * Disposes the particle system and free the associated resources
  119133. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  119134. */
  119135. dispose(disposeTexture?: boolean): void;
  119136. /**
  119137. * Clones the particle system.
  119138. * @param name The name of the cloned object
  119139. * @param newEmitter The new emitter to use
  119140. * @returns the cloned particle system
  119141. */
  119142. clone(name: string, newEmitter: any): GPUParticleSystem;
  119143. /**
  119144. * Serializes the particle system to a JSON object.
  119145. * @returns the JSON object
  119146. */
  119147. serialize(): any;
  119148. /**
  119149. * Parses a JSON object to create a GPU particle system.
  119150. * @param parsedParticleSystem The JSON object to parse
  119151. * @param scene The scene to create the particle system in
  119152. * @param rootUrl The root url to use to load external dependencies like texture
  119153. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  119154. * @returns the parsed GPU particle system
  119155. */
  119156. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  119157. }
  119158. }
  119159. declare module BABYLON {
  119160. /**
  119161. * Represents a set of particle systems working together to create a specific effect
  119162. */
  119163. export class ParticleSystemSet implements IDisposable {
  119164. private _emitterCreationOptions;
  119165. private _emitterNode;
  119166. /**
  119167. * Gets the particle system list
  119168. */
  119169. systems: IParticleSystem[];
  119170. /**
  119171. * Gets the emitter node used with this set
  119172. */
  119173. readonly emitterNode: Nullable<TransformNode>;
  119174. /**
  119175. * Creates a new emitter mesh as a sphere
  119176. * @param options defines the options used to create the sphere
  119177. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  119178. * @param scene defines the hosting scene
  119179. */
  119180. setEmitterAsSphere(options: {
  119181. diameter: number;
  119182. segments: number;
  119183. color: Color3;
  119184. }, renderingGroupId: number, scene: Scene): void;
  119185. /**
  119186. * Starts all particle systems of the set
  119187. * @param emitter defines an optional mesh to use as emitter for the particle systems
  119188. */
  119189. start(emitter?: AbstractMesh): void;
  119190. /**
  119191. * Release all associated resources
  119192. */
  119193. dispose(): void;
  119194. /**
  119195. * Serialize the set into a JSON compatible object
  119196. * @returns a JSON compatible representation of the set
  119197. */
  119198. serialize(): any;
  119199. /**
  119200. * Parse a new ParticleSystemSet from a serialized source
  119201. * @param data defines a JSON compatible representation of the set
  119202. * @param scene defines the hosting scene
  119203. * @param gpu defines if we want GPU particles or CPU particles
  119204. * @returns a new ParticleSystemSet
  119205. */
  119206. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  119207. }
  119208. }
  119209. declare module BABYLON {
  119210. /**
  119211. * This class is made for on one-liner static method to help creating particle system set.
  119212. */
  119213. export class ParticleHelper {
  119214. /**
  119215. * Gets or sets base Assets URL
  119216. */
  119217. static BaseAssetsUrl: string;
  119218. /**
  119219. * Create a default particle system that you can tweak
  119220. * @param emitter defines the emitter to use
  119221. * @param capacity defines the system capacity (default is 500 particles)
  119222. * @param scene defines the hosting scene
  119223. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  119224. * @returns the new Particle system
  119225. */
  119226. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  119227. /**
  119228. * This is the main static method (one-liner) of this helper to create different particle systems
  119229. * @param type This string represents the type to the particle system to create
  119230. * @param scene The scene where the particle system should live
  119231. * @param gpu If the system will use gpu
  119232. * @returns the ParticleSystemSet created
  119233. */
  119234. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  119235. /**
  119236. * Static function used to export a particle system to a ParticleSystemSet variable.
  119237. * Please note that the emitter shape is not exported
  119238. * @param systems defines the particle systems to export
  119239. * @returns the created particle system set
  119240. */
  119241. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  119242. }
  119243. }
  119244. declare module BABYLON {
  119245. interface Engine {
  119246. /**
  119247. * Create an effect to use with particle systems.
  119248. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  119249. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  119250. * @param uniformsNames defines a list of attribute names
  119251. * @param samplers defines an array of string used to represent textures
  119252. * @param defines defines the string containing the defines to use to compile the shaders
  119253. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  119254. * @param onCompiled defines a function to call when the effect creation is successful
  119255. * @param onError defines a function to call when the effect creation has failed
  119256. * @returns the new Effect
  119257. */
  119258. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  119259. }
  119260. interface Mesh {
  119261. /**
  119262. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  119263. * @returns an array of IParticleSystem
  119264. */
  119265. getEmittedParticleSystems(): IParticleSystem[];
  119266. /**
  119267. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  119268. * @returns an array of IParticleSystem
  119269. */
  119270. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  119271. }
  119272. /**
  119273. * @hidden
  119274. */
  119275. export var _IDoNeedToBeInTheBuild: number;
  119276. }
  119277. declare module BABYLON {
  119278. interface Scene {
  119279. /** @hidden (Backing field) */
  119280. _physicsEngine: Nullable<IPhysicsEngine>;
  119281. /**
  119282. * Gets the current physics engine
  119283. * @returns a IPhysicsEngine or null if none attached
  119284. */
  119285. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  119286. /**
  119287. * Enables physics to the current scene
  119288. * @param gravity defines the scene's gravity for the physics engine
  119289. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  119290. * @return a boolean indicating if the physics engine was initialized
  119291. */
  119292. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  119293. /**
  119294. * Disables and disposes the physics engine associated with the scene
  119295. */
  119296. disablePhysicsEngine(): void;
  119297. /**
  119298. * Gets a boolean indicating if there is an active physics engine
  119299. * @returns a boolean indicating if there is an active physics engine
  119300. */
  119301. isPhysicsEnabled(): boolean;
  119302. /**
  119303. * Deletes a physics compound impostor
  119304. * @param compound defines the compound to delete
  119305. */
  119306. deleteCompoundImpostor(compound: any): void;
  119307. /**
  119308. * An event triggered when physic simulation is about to be run
  119309. */
  119310. onBeforePhysicsObservable: Observable<Scene>;
  119311. /**
  119312. * An event triggered when physic simulation has been done
  119313. */
  119314. onAfterPhysicsObservable: Observable<Scene>;
  119315. }
  119316. interface AbstractMesh {
  119317. /** @hidden */
  119318. _physicsImpostor: Nullable<PhysicsImpostor>;
  119319. /**
  119320. * Gets or sets impostor used for physic simulation
  119321. * @see http://doc.babylonjs.com/features/physics_engine
  119322. */
  119323. physicsImpostor: Nullable<PhysicsImpostor>;
  119324. /**
  119325. * Gets the current physics impostor
  119326. * @see http://doc.babylonjs.com/features/physics_engine
  119327. * @returns a physics impostor or null
  119328. */
  119329. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  119330. /** Apply a physic impulse to the mesh
  119331. * @param force defines the force to apply
  119332. * @param contactPoint defines where to apply the force
  119333. * @returns the current mesh
  119334. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  119335. */
  119336. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  119337. /**
  119338. * Creates a physic joint between two meshes
  119339. * @param otherMesh defines the other mesh to use
  119340. * @param pivot1 defines the pivot to use on this mesh
  119341. * @param pivot2 defines the pivot to use on the other mesh
  119342. * @param options defines additional options (can be plugin dependent)
  119343. * @returns the current mesh
  119344. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  119345. */
  119346. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  119347. /** @hidden */
  119348. _disposePhysicsObserver: Nullable<Observer<Node>>;
  119349. }
  119350. /**
  119351. * Defines the physics engine scene component responsible to manage a physics engine
  119352. */
  119353. export class PhysicsEngineSceneComponent implements ISceneComponent {
  119354. /**
  119355. * The component name helpful to identify the component in the list of scene components.
  119356. */
  119357. readonly name: string;
  119358. /**
  119359. * The scene the component belongs to.
  119360. */
  119361. scene: Scene;
  119362. /**
  119363. * Creates a new instance of the component for the given scene
  119364. * @param scene Defines the scene to register the component in
  119365. */
  119366. constructor(scene: Scene);
  119367. /**
  119368. * Registers the component in a given scene
  119369. */
  119370. register(): void;
  119371. /**
  119372. * Rebuilds the elements related to this component in case of
  119373. * context lost for instance.
  119374. */
  119375. rebuild(): void;
  119376. /**
  119377. * Disposes the component and the associated ressources
  119378. */
  119379. dispose(): void;
  119380. }
  119381. }
  119382. declare module BABYLON {
  119383. /**
  119384. * A helper for physics simulations
  119385. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119386. */
  119387. export class PhysicsHelper {
  119388. private _scene;
  119389. private _physicsEngine;
  119390. /**
  119391. * Initializes the Physics helper
  119392. * @param scene Babylon.js scene
  119393. */
  119394. constructor(scene: Scene);
  119395. /**
  119396. * Applies a radial explosion impulse
  119397. * @param origin the origin of the explosion
  119398. * @param radiusOrEventOptions the radius or the options of radial explosion
  119399. * @param strength the explosion strength
  119400. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119401. * @returns A physics radial explosion event, or null
  119402. */
  119403. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119404. /**
  119405. * Applies a radial explosion force
  119406. * @param origin the origin of the explosion
  119407. * @param radiusOrEventOptions the radius or the options of radial explosion
  119408. * @param strength the explosion strength
  119409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119410. * @returns A physics radial explosion event, or null
  119411. */
  119412. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  119413. /**
  119414. * Creates a gravitational field
  119415. * @param origin the origin of the explosion
  119416. * @param radiusOrEventOptions the radius or the options of radial explosion
  119417. * @param strength the explosion strength
  119418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  119419. * @returns A physics gravitational field event, or null
  119420. */
  119421. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  119422. /**
  119423. * Creates a physics updraft event
  119424. * @param origin the origin of the updraft
  119425. * @param radiusOrEventOptions the radius or the options of the updraft
  119426. * @param strength the strength of the updraft
  119427. * @param height the height of the updraft
  119428. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  119429. * @returns A physics updraft event, or null
  119430. */
  119431. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  119432. /**
  119433. * Creates a physics vortex event
  119434. * @param origin the of the vortex
  119435. * @param radiusOrEventOptions the radius or the options of the vortex
  119436. * @param strength the strength of the vortex
  119437. * @param height the height of the vortex
  119438. * @returns a Physics vortex event, or null
  119439. * A physics vortex event or null
  119440. */
  119441. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  119442. }
  119443. /**
  119444. * Represents a physics radial explosion event
  119445. */
  119446. class PhysicsRadialExplosionEvent {
  119447. private _scene;
  119448. private _options;
  119449. private _sphere;
  119450. private _dataFetched;
  119451. /**
  119452. * Initializes a radial explosioin event
  119453. * @param _scene BabylonJS scene
  119454. * @param _options The options for the vortex event
  119455. */
  119456. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  119457. /**
  119458. * Returns the data related to the radial explosion event (sphere).
  119459. * @returns The radial explosion event data
  119460. */
  119461. getData(): PhysicsRadialExplosionEventData;
  119462. /**
  119463. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  119464. * @param impostor A physics imposter
  119465. * @param origin the origin of the explosion
  119466. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  119467. */
  119468. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  119469. /**
  119470. * Triggers affecterd impostors callbacks
  119471. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  119472. */
  119473. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  119474. /**
  119475. * Disposes the sphere.
  119476. * @param force Specifies if the sphere should be disposed by force
  119477. */
  119478. dispose(force?: boolean): void;
  119479. /*** Helpers ***/
  119480. private _prepareSphere;
  119481. private _intersectsWithSphere;
  119482. }
  119483. /**
  119484. * Represents a gravitational field event
  119485. */
  119486. class PhysicsGravitationalFieldEvent {
  119487. private _physicsHelper;
  119488. private _scene;
  119489. private _origin;
  119490. private _options;
  119491. private _tickCallback;
  119492. private _sphere;
  119493. private _dataFetched;
  119494. /**
  119495. * Initializes the physics gravitational field event
  119496. * @param _physicsHelper A physics helper
  119497. * @param _scene BabylonJS scene
  119498. * @param _origin The origin position of the gravitational field event
  119499. * @param _options The options for the vortex event
  119500. */
  119501. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  119502. /**
  119503. * Returns the data related to the gravitational field event (sphere).
  119504. * @returns A gravitational field event
  119505. */
  119506. getData(): PhysicsGravitationalFieldEventData;
  119507. /**
  119508. * Enables the gravitational field.
  119509. */
  119510. enable(): void;
  119511. /**
  119512. * Disables the gravitational field.
  119513. */
  119514. disable(): void;
  119515. /**
  119516. * Disposes the sphere.
  119517. * @param force The force to dispose from the gravitational field event
  119518. */
  119519. dispose(force?: boolean): void;
  119520. private _tick;
  119521. }
  119522. /**
  119523. * Represents a physics updraft event
  119524. */
  119525. class PhysicsUpdraftEvent {
  119526. private _scene;
  119527. private _origin;
  119528. private _options;
  119529. private _physicsEngine;
  119530. private _originTop;
  119531. private _originDirection;
  119532. private _tickCallback;
  119533. private _cylinder;
  119534. private _cylinderPosition;
  119535. private _dataFetched;
  119536. /**
  119537. * Initializes the physics updraft event
  119538. * @param _scene BabylonJS scene
  119539. * @param _origin The origin position of the updraft
  119540. * @param _options The options for the updraft event
  119541. */
  119542. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  119543. /**
  119544. * Returns the data related to the updraft event (cylinder).
  119545. * @returns A physics updraft event
  119546. */
  119547. getData(): PhysicsUpdraftEventData;
  119548. /**
  119549. * Enables the updraft.
  119550. */
  119551. enable(): void;
  119552. /**
  119553. * Disables the updraft.
  119554. */
  119555. disable(): void;
  119556. /**
  119557. * Disposes the cylinder.
  119558. * @param force Specifies if the updraft should be disposed by force
  119559. */
  119560. dispose(force?: boolean): void;
  119561. private getImpostorHitData;
  119562. private _tick;
  119563. /*** Helpers ***/
  119564. private _prepareCylinder;
  119565. private _intersectsWithCylinder;
  119566. }
  119567. /**
  119568. * Represents a physics vortex event
  119569. */
  119570. class PhysicsVortexEvent {
  119571. private _scene;
  119572. private _origin;
  119573. private _options;
  119574. private _physicsEngine;
  119575. private _originTop;
  119576. private _tickCallback;
  119577. private _cylinder;
  119578. private _cylinderPosition;
  119579. private _dataFetched;
  119580. /**
  119581. * Initializes the physics vortex event
  119582. * @param _scene The BabylonJS scene
  119583. * @param _origin The origin position of the vortex
  119584. * @param _options The options for the vortex event
  119585. */
  119586. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  119587. /**
  119588. * Returns the data related to the vortex event (cylinder).
  119589. * @returns The physics vortex event data
  119590. */
  119591. getData(): PhysicsVortexEventData;
  119592. /**
  119593. * Enables the vortex.
  119594. */
  119595. enable(): void;
  119596. /**
  119597. * Disables the cortex.
  119598. */
  119599. disable(): void;
  119600. /**
  119601. * Disposes the sphere.
  119602. * @param force
  119603. */
  119604. dispose(force?: boolean): void;
  119605. private getImpostorHitData;
  119606. private _tick;
  119607. /*** Helpers ***/
  119608. private _prepareCylinder;
  119609. private _intersectsWithCylinder;
  119610. }
  119611. /**
  119612. * Options fot the radial explosion event
  119613. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119614. */
  119615. export class PhysicsRadialExplosionEventOptions {
  119616. /**
  119617. * The radius of the sphere for the radial explosion.
  119618. */
  119619. radius: number;
  119620. /**
  119621. * The strenth of the explosion.
  119622. */
  119623. strength: number;
  119624. /**
  119625. * The strenght of the force in correspondence to the distance of the affected object
  119626. */
  119627. falloff: PhysicsRadialImpulseFalloff;
  119628. /**
  119629. * Sphere options for the radial explosion.
  119630. */
  119631. sphere: {
  119632. segments: number;
  119633. diameter: number;
  119634. };
  119635. /**
  119636. * Sphere options for the radial explosion.
  119637. */
  119638. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  119639. }
  119640. /**
  119641. * Options fot the updraft event
  119642. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119643. */
  119644. export class PhysicsUpdraftEventOptions {
  119645. /**
  119646. * The radius of the cylinder for the vortex
  119647. */
  119648. radius: number;
  119649. /**
  119650. * The strenth of the updraft.
  119651. */
  119652. strength: number;
  119653. /**
  119654. * The height of the cylinder for the updraft.
  119655. */
  119656. height: number;
  119657. /**
  119658. * The mode for the the updraft.
  119659. */
  119660. updraftMode: PhysicsUpdraftMode;
  119661. }
  119662. /**
  119663. * Options fot the vortex event
  119664. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119665. */
  119666. export class PhysicsVortexEventOptions {
  119667. /**
  119668. * The radius of the cylinder for the vortex
  119669. */
  119670. radius: number;
  119671. /**
  119672. * The strenth of the vortex.
  119673. */
  119674. strength: number;
  119675. /**
  119676. * The height of the cylinder for the vortex.
  119677. */
  119678. height: number;
  119679. /**
  119680. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  119681. */
  119682. centripetalForceThreshold: number;
  119683. /**
  119684. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  119685. */
  119686. centripetalForceMultiplier: number;
  119687. /**
  119688. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  119689. */
  119690. centrifugalForceMultiplier: number;
  119691. /**
  119692. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  119693. */
  119694. updraftForceMultiplier: number;
  119695. }
  119696. /**
  119697. * The strenght of the force in correspondence to the distance of the affected object
  119698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119699. */
  119700. export enum PhysicsRadialImpulseFalloff {
  119701. /** Defines that impulse is constant in strength across it's whole radius */
  119702. Constant = 0,
  119703. /** Defines that impulse gets weaker if it's further from the origin */
  119704. Linear = 1
  119705. }
  119706. /**
  119707. * The strength of the force in correspondence to the distance of the affected object
  119708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119709. */
  119710. export enum PhysicsUpdraftMode {
  119711. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  119712. Center = 0,
  119713. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  119714. Perpendicular = 1
  119715. }
  119716. /**
  119717. * Interface for a physics hit data
  119718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119719. */
  119720. export interface PhysicsHitData {
  119721. /**
  119722. * The force applied at the contact point
  119723. */
  119724. force: Vector3;
  119725. /**
  119726. * The contact point
  119727. */
  119728. contactPoint: Vector3;
  119729. /**
  119730. * The distance from the origin to the contact point
  119731. */
  119732. distanceFromOrigin: number;
  119733. }
  119734. /**
  119735. * Interface for radial explosion event data
  119736. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119737. */
  119738. export interface PhysicsRadialExplosionEventData {
  119739. /**
  119740. * A sphere used for the radial explosion event
  119741. */
  119742. sphere: Mesh;
  119743. }
  119744. /**
  119745. * Interface for gravitational field event data
  119746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119747. */
  119748. export interface PhysicsGravitationalFieldEventData {
  119749. /**
  119750. * A sphere mesh used for the gravitational field event
  119751. */
  119752. sphere: Mesh;
  119753. }
  119754. /**
  119755. * Interface for updraft event data
  119756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119757. */
  119758. export interface PhysicsUpdraftEventData {
  119759. /**
  119760. * A cylinder used for the updraft event
  119761. */
  119762. cylinder: Mesh;
  119763. }
  119764. /**
  119765. * Interface for vortex event data
  119766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119767. */
  119768. export interface PhysicsVortexEventData {
  119769. /**
  119770. * A cylinder used for the vortex event
  119771. */
  119772. cylinder: Mesh;
  119773. }
  119774. /**
  119775. * Interface for an affected physics impostor
  119776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  119777. */
  119778. export interface PhysicsAffectedImpostorWithData {
  119779. /**
  119780. * The impostor affected by the effect
  119781. */
  119782. impostor: PhysicsImpostor;
  119783. /**
  119784. * The data about the hit/horce from the explosion
  119785. */
  119786. hitData: PhysicsHitData;
  119787. }
  119788. }
  119789. declare module BABYLON {
  119790. /** @hidden */
  119791. export var blackAndWhitePixelShader: {
  119792. name: string;
  119793. shader: string;
  119794. };
  119795. }
  119796. declare module BABYLON {
  119797. /**
  119798. * Post process used to render in black and white
  119799. */
  119800. export class BlackAndWhitePostProcess extends PostProcess {
  119801. /**
  119802. * Linear about to convert he result to black and white (default: 1)
  119803. */
  119804. degree: number;
  119805. /**
  119806. * Creates a black and white post process
  119807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  119808. * @param name The name of the effect.
  119809. * @param options The required width/height ratio to downsize to before computing the render pass.
  119810. * @param camera The camera to apply the render pass to.
  119811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119812. * @param engine The engine which the post process will be applied. (default: current engine)
  119813. * @param reusable If the post process can be reused on the same frame. (default: false)
  119814. */
  119815. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  119816. }
  119817. }
  119818. declare module BABYLON {
  119819. /**
  119820. * This represents a set of one or more post processes in Babylon.
  119821. * A post process can be used to apply a shader to a texture after it is rendered.
  119822. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  119823. */
  119824. export class PostProcessRenderEffect {
  119825. private _postProcesses;
  119826. private _getPostProcesses;
  119827. private _singleInstance;
  119828. private _cameras;
  119829. private _indicesForCamera;
  119830. /**
  119831. * Name of the effect
  119832. * @hidden
  119833. */
  119834. _name: string;
  119835. /**
  119836. * Instantiates a post process render effect.
  119837. * A post process can be used to apply a shader to a texture after it is rendered.
  119838. * @param engine The engine the effect is tied to
  119839. * @param name The name of the effect
  119840. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  119841. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  119842. */
  119843. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  119844. /**
  119845. * Checks if all the post processes in the effect are supported.
  119846. */
  119847. readonly isSupported: boolean;
  119848. /**
  119849. * Updates the current state of the effect
  119850. * @hidden
  119851. */
  119852. _update(): void;
  119853. /**
  119854. * Attaches the effect on cameras
  119855. * @param cameras The camera to attach to.
  119856. * @hidden
  119857. */
  119858. _attachCameras(cameras: Camera): void;
  119859. /**
  119860. * Attaches the effect on cameras
  119861. * @param cameras The camera to attach to.
  119862. * @hidden
  119863. */
  119864. _attachCameras(cameras: Camera[]): void;
  119865. /**
  119866. * Detaches the effect on cameras
  119867. * @param cameras The camera to detatch from.
  119868. * @hidden
  119869. */
  119870. _detachCameras(cameras: Camera): void;
  119871. /**
  119872. * Detatches the effect on cameras
  119873. * @param cameras The camera to detatch from.
  119874. * @hidden
  119875. */
  119876. _detachCameras(cameras: Camera[]): void;
  119877. /**
  119878. * Enables the effect on given cameras
  119879. * @param cameras The camera to enable.
  119880. * @hidden
  119881. */
  119882. _enable(cameras: Camera): void;
  119883. /**
  119884. * Enables the effect on given cameras
  119885. * @param cameras The camera to enable.
  119886. * @hidden
  119887. */
  119888. _enable(cameras: Nullable<Camera[]>): void;
  119889. /**
  119890. * Disables the effect on the given cameras
  119891. * @param cameras The camera to disable.
  119892. * @hidden
  119893. */
  119894. _disable(cameras: Camera): void;
  119895. /**
  119896. * Disables the effect on the given cameras
  119897. * @param cameras The camera to disable.
  119898. * @hidden
  119899. */
  119900. _disable(cameras: Nullable<Camera[]>): void;
  119901. /**
  119902. * Gets a list of the post processes contained in the effect.
  119903. * @param camera The camera to get the post processes on.
  119904. * @returns The list of the post processes in the effect.
  119905. */
  119906. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  119907. }
  119908. }
  119909. declare module BABYLON {
  119910. /** @hidden */
  119911. export var extractHighlightsPixelShader: {
  119912. name: string;
  119913. shader: string;
  119914. };
  119915. }
  119916. declare module BABYLON {
  119917. /**
  119918. * 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.
  119919. */
  119920. export class ExtractHighlightsPostProcess extends PostProcess {
  119921. /**
  119922. * The luminance threshold, pixels below this value will be set to black.
  119923. */
  119924. threshold: number;
  119925. /** @hidden */
  119926. _exposure: number;
  119927. /**
  119928. * Post process which has the input texture to be used when performing highlight extraction
  119929. * @hidden
  119930. */
  119931. _inputPostProcess: Nullable<PostProcess>;
  119932. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119933. }
  119934. }
  119935. declare module BABYLON {
  119936. /** @hidden */
  119937. export var bloomMergePixelShader: {
  119938. name: string;
  119939. shader: string;
  119940. };
  119941. }
  119942. declare module BABYLON {
  119943. /**
  119944. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  119945. */
  119946. export class BloomMergePostProcess extends PostProcess {
  119947. /** Weight of the bloom to be added to the original input. */
  119948. weight: number;
  119949. /**
  119950. * Creates a new instance of @see BloomMergePostProcess
  119951. * @param name The name of the effect.
  119952. * @param originalFromInput Post process which's input will be used for the merge.
  119953. * @param blurred Blurred highlights post process which's output will be used.
  119954. * @param weight Weight of the bloom to be added to the original input.
  119955. * @param options The required width/height ratio to downsize to before computing the render pass.
  119956. * @param camera The camera to apply the render pass to.
  119957. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119958. * @param engine The engine which the post process will be applied. (default: current engine)
  119959. * @param reusable If the post process can be reused on the same frame. (default: false)
  119960. * @param textureType Type of textures used when performing the post process. (default: 0)
  119961. * @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)
  119962. */
  119963. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  119964. /** Weight of the bloom to be added to the original input. */
  119965. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  119966. }
  119967. }
  119968. declare module BABYLON {
  119969. /**
  119970. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  119971. */
  119972. export class BloomEffect extends PostProcessRenderEffect {
  119973. private bloomScale;
  119974. /**
  119975. * @hidden Internal
  119976. */
  119977. _effects: Array<PostProcess>;
  119978. /**
  119979. * @hidden Internal
  119980. */
  119981. _downscale: ExtractHighlightsPostProcess;
  119982. private _blurX;
  119983. private _blurY;
  119984. private _merge;
  119985. /**
  119986. * The luminance threshold to find bright areas of the image to bloom.
  119987. */
  119988. threshold: number;
  119989. /**
  119990. * The strength of the bloom.
  119991. */
  119992. weight: number;
  119993. /**
  119994. * Specifies the size of the bloom blur kernel, relative to the final output size
  119995. */
  119996. kernel: number;
  119997. /**
  119998. * Creates a new instance of @see BloomEffect
  119999. * @param scene The scene the effect belongs to.
  120000. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  120001. * @param bloomKernel The size of the kernel to be used when applying the blur.
  120002. * @param bloomWeight The the strength of bloom.
  120003. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120004. * @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)
  120005. */
  120006. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  120007. /**
  120008. * Disposes each of the internal effects for a given camera.
  120009. * @param camera The camera to dispose the effect on.
  120010. */
  120011. disposeEffects(camera: Camera): void;
  120012. /**
  120013. * @hidden Internal
  120014. */
  120015. _updateEffects(): void;
  120016. /**
  120017. * Internal
  120018. * @returns if all the contained post processes are ready.
  120019. * @hidden
  120020. */
  120021. _isReady(): boolean;
  120022. }
  120023. }
  120024. declare module BABYLON {
  120025. /** @hidden */
  120026. export var chromaticAberrationPixelShader: {
  120027. name: string;
  120028. shader: string;
  120029. };
  120030. }
  120031. declare module BABYLON {
  120032. /**
  120033. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  120034. */
  120035. export class ChromaticAberrationPostProcess extends PostProcess {
  120036. /**
  120037. * The amount of seperation of rgb channels (default: 30)
  120038. */
  120039. aberrationAmount: number;
  120040. /**
  120041. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  120042. */
  120043. radialIntensity: number;
  120044. /**
  120045. * 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))
  120046. */
  120047. direction: Vector2;
  120048. /**
  120049. * 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))
  120050. */
  120051. centerPosition: Vector2;
  120052. /**
  120053. * Creates a new instance ChromaticAberrationPostProcess
  120054. * @param name The name of the effect.
  120055. * @param screenWidth The width of the screen to apply the effect on.
  120056. * @param screenHeight The height of the screen to apply the effect on.
  120057. * @param options The required width/height ratio to downsize to before computing the render pass.
  120058. * @param camera The camera to apply the render pass to.
  120059. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120060. * @param engine The engine which the post process will be applied. (default: current engine)
  120061. * @param reusable If the post process can be reused on the same frame. (default: false)
  120062. * @param textureType Type of textures used when performing the post process. (default: 0)
  120063. * @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)
  120064. */
  120065. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120066. }
  120067. }
  120068. declare module BABYLON {
  120069. /** @hidden */
  120070. export var circleOfConfusionPixelShader: {
  120071. name: string;
  120072. shader: string;
  120073. };
  120074. }
  120075. declare module BABYLON {
  120076. /**
  120077. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  120078. */
  120079. export class CircleOfConfusionPostProcess extends PostProcess {
  120080. /**
  120081. * 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.
  120082. */
  120083. lensSize: number;
  120084. /**
  120085. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120086. */
  120087. fStop: number;
  120088. /**
  120089. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120090. */
  120091. focusDistance: number;
  120092. /**
  120093. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  120094. */
  120095. focalLength: number;
  120096. private _depthTexture;
  120097. /**
  120098. * Creates a new instance CircleOfConfusionPostProcess
  120099. * @param name The name of the effect.
  120100. * @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.
  120101. * @param options The required width/height ratio to downsize to before computing the render pass.
  120102. * @param camera The camera to apply the render pass to.
  120103. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120104. * @param engine The engine which the post process will be applied. (default: current engine)
  120105. * @param reusable If the post process can be reused on the same frame. (default: false)
  120106. * @param textureType Type of textures used when performing the post process. (default: 0)
  120107. * @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)
  120108. */
  120109. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120110. /**
  120111. * 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.
  120112. */
  120113. depthTexture: RenderTargetTexture;
  120114. }
  120115. }
  120116. declare module BABYLON {
  120117. /** @hidden */
  120118. export var colorCorrectionPixelShader: {
  120119. name: string;
  120120. shader: string;
  120121. };
  120122. }
  120123. declare module BABYLON {
  120124. /**
  120125. *
  120126. * This post-process allows the modification of rendered colors by using
  120127. * a 'look-up table' (LUT). This effect is also called Color Grading.
  120128. *
  120129. * The object needs to be provided an url to a texture containing the color
  120130. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  120131. * Use an image editing software to tweak the LUT to match your needs.
  120132. *
  120133. * For an example of a color LUT, see here:
  120134. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  120135. * For explanations on color grading, see here:
  120136. * @see http://udn.epicgames.com/Three/ColorGrading.html
  120137. *
  120138. */
  120139. export class ColorCorrectionPostProcess extends PostProcess {
  120140. private _colorTableTexture;
  120141. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120142. }
  120143. }
  120144. declare module BABYLON {
  120145. /** @hidden */
  120146. export var convolutionPixelShader: {
  120147. name: string;
  120148. shader: string;
  120149. };
  120150. }
  120151. declare module BABYLON {
  120152. /**
  120153. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  120154. * input texture to perform effects such as edge detection or sharpening
  120155. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120156. */
  120157. export class ConvolutionPostProcess extends PostProcess {
  120158. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120159. kernel: number[];
  120160. /**
  120161. * Creates a new instance ConvolutionPostProcess
  120162. * @param name The name of the effect.
  120163. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  120164. * @param options The required width/height ratio to downsize to before computing the render pass.
  120165. * @param camera The camera to apply the render pass to.
  120166. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120167. * @param engine The engine which the post process will be applied. (default: current engine)
  120168. * @param reusable If the post process can be reused on the same frame. (default: false)
  120169. * @param textureType Type of textures used when performing the post process. (default: 0)
  120170. */
  120171. constructor(name: string,
  120172. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  120173. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120174. /**
  120175. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120176. */
  120177. static EdgeDetect0Kernel: number[];
  120178. /**
  120179. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120180. */
  120181. static EdgeDetect1Kernel: number[];
  120182. /**
  120183. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120184. */
  120185. static EdgeDetect2Kernel: number[];
  120186. /**
  120187. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120188. */
  120189. static SharpenKernel: number[];
  120190. /**
  120191. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120192. */
  120193. static EmbossKernel: number[];
  120194. /**
  120195. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  120196. */
  120197. static GaussianKernel: number[];
  120198. }
  120199. }
  120200. declare module BABYLON {
  120201. /**
  120202. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  120203. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  120204. * based on samples that have a large difference in distance than the center pixel.
  120205. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  120206. */
  120207. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  120208. direction: Vector2;
  120209. /**
  120210. * Creates a new instance CircleOfConfusionPostProcess
  120211. * @param name The name of the effect.
  120212. * @param scene The scene the effect belongs to.
  120213. * @param direction The direction the blur should be applied.
  120214. * @param kernel The size of the kernel used to blur.
  120215. * @param options The required width/height ratio to downsize to before computing the render pass.
  120216. * @param camera The camera to apply the render pass to.
  120217. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  120218. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  120219. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120220. * @param engine The engine which the post process will be applied. (default: current engine)
  120221. * @param reusable If the post process can be reused on the same frame. (default: false)
  120222. * @param textureType Type of textures used when performing the post process. (default: 0)
  120223. * @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)
  120224. */
  120225. 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);
  120226. }
  120227. }
  120228. declare module BABYLON {
  120229. /** @hidden */
  120230. export var depthOfFieldMergePixelShader: {
  120231. name: string;
  120232. shader: string;
  120233. };
  120234. }
  120235. declare module BABYLON {
  120236. /**
  120237. * Options to be set when merging outputs from the default pipeline.
  120238. */
  120239. export class DepthOfFieldMergePostProcessOptions {
  120240. /**
  120241. * The original image to merge on top of
  120242. */
  120243. originalFromInput: PostProcess;
  120244. /**
  120245. * Parameters to perform the merge of the depth of field effect
  120246. */
  120247. depthOfField?: {
  120248. circleOfConfusion: PostProcess;
  120249. blurSteps: Array<PostProcess>;
  120250. };
  120251. /**
  120252. * Parameters to perform the merge of bloom effect
  120253. */
  120254. bloom?: {
  120255. blurred: PostProcess;
  120256. weight: number;
  120257. };
  120258. }
  120259. /**
  120260. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  120261. */
  120262. export class DepthOfFieldMergePostProcess extends PostProcess {
  120263. private blurSteps;
  120264. /**
  120265. * Creates a new instance of DepthOfFieldMergePostProcess
  120266. * @param name The name of the effect.
  120267. * @param originalFromInput Post process which's input will be used for the merge.
  120268. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  120269. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  120270. * @param options The required width/height ratio to downsize to before computing the render pass.
  120271. * @param camera The camera to apply the render pass to.
  120272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120273. * @param engine The engine which the post process will be applied. (default: current engine)
  120274. * @param reusable If the post process can be reused on the same frame. (default: false)
  120275. * @param textureType Type of textures used when performing the post process. (default: 0)
  120276. * @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)
  120277. */
  120278. 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);
  120279. /**
  120280. * Updates the effect with the current post process compile time values and recompiles the shader.
  120281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  120282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  120283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  120284. * @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
  120285. * @param onCompiled Called when the shader has been compiled.
  120286. * @param onError Called if there is an error when compiling a shader.
  120287. */
  120288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  120289. }
  120290. }
  120291. declare module BABYLON {
  120292. /**
  120293. * Specifies the level of max blur that should be applied when using the depth of field effect
  120294. */
  120295. export enum DepthOfFieldEffectBlurLevel {
  120296. /**
  120297. * Subtle blur
  120298. */
  120299. Low = 0,
  120300. /**
  120301. * Medium blur
  120302. */
  120303. Medium = 1,
  120304. /**
  120305. * Large blur
  120306. */
  120307. High = 2
  120308. }
  120309. /**
  120310. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  120311. */
  120312. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  120313. private _circleOfConfusion;
  120314. /**
  120315. * @hidden Internal, blurs from high to low
  120316. */
  120317. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  120318. private _depthOfFieldBlurY;
  120319. private _dofMerge;
  120320. /**
  120321. * @hidden Internal post processes in depth of field effect
  120322. */
  120323. _effects: Array<PostProcess>;
  120324. /**
  120325. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  120326. */
  120327. focalLength: number;
  120328. /**
  120329. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  120330. */
  120331. fStop: number;
  120332. /**
  120333. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  120334. */
  120335. focusDistance: number;
  120336. /**
  120337. * 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.
  120338. */
  120339. lensSize: number;
  120340. /**
  120341. * Creates a new instance DepthOfFieldEffect
  120342. * @param scene The scene the effect belongs to.
  120343. * @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.
  120344. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  120345. * @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)
  120346. */
  120347. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  120348. /**
  120349. * Get the current class name of the current effet
  120350. * @returns "DepthOfFieldEffect"
  120351. */
  120352. getClassName(): string;
  120353. /**
  120354. * 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.
  120355. */
  120356. depthTexture: RenderTargetTexture;
  120357. /**
  120358. * Disposes each of the internal effects for a given camera.
  120359. * @param camera The camera to dispose the effect on.
  120360. */
  120361. disposeEffects(camera: Camera): void;
  120362. /**
  120363. * @hidden Internal
  120364. */
  120365. _updateEffects(): void;
  120366. /**
  120367. * Internal
  120368. * @returns if all the contained post processes are ready.
  120369. * @hidden
  120370. */
  120371. _isReady(): boolean;
  120372. }
  120373. }
  120374. declare module BABYLON {
  120375. /** @hidden */
  120376. export var displayPassPixelShader: {
  120377. name: string;
  120378. shader: string;
  120379. };
  120380. }
  120381. declare module BABYLON {
  120382. /**
  120383. * DisplayPassPostProcess which produces an output the same as it's input
  120384. */
  120385. export class DisplayPassPostProcess extends PostProcess {
  120386. /**
  120387. * Creates the DisplayPassPostProcess
  120388. * @param name The name of the effect.
  120389. * @param options The required width/height ratio to downsize to before computing the render pass.
  120390. * @param camera The camera to apply the render pass to.
  120391. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120392. * @param engine The engine which the post process will be applied. (default: current engine)
  120393. * @param reusable If the post process can be reused on the same frame. (default: false)
  120394. */
  120395. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120396. }
  120397. }
  120398. declare module BABYLON {
  120399. /** @hidden */
  120400. export var filterPixelShader: {
  120401. name: string;
  120402. shader: string;
  120403. };
  120404. }
  120405. declare module BABYLON {
  120406. /**
  120407. * Applies a kernel filter to the image
  120408. */
  120409. export class FilterPostProcess extends PostProcess {
  120410. /** The matrix to be applied to the image */
  120411. kernelMatrix: Matrix;
  120412. /**
  120413. *
  120414. * @param name The name of the effect.
  120415. * @param kernelMatrix The matrix to be applied to the image
  120416. * @param options The required width/height ratio to downsize to before computing the render pass.
  120417. * @param camera The camera to apply the render pass to.
  120418. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120419. * @param engine The engine which the post process will be applied. (default: current engine)
  120420. * @param reusable If the post process can be reused on the same frame. (default: false)
  120421. */
  120422. constructor(name: string,
  120423. /** The matrix to be applied to the image */
  120424. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120425. }
  120426. }
  120427. declare module BABYLON {
  120428. /** @hidden */
  120429. export var fxaaPixelShader: {
  120430. name: string;
  120431. shader: string;
  120432. };
  120433. }
  120434. declare module BABYLON {
  120435. /** @hidden */
  120436. export var fxaaVertexShader: {
  120437. name: string;
  120438. shader: string;
  120439. };
  120440. }
  120441. declare module BABYLON {
  120442. /**
  120443. * Fxaa post process
  120444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  120445. */
  120446. export class FxaaPostProcess extends PostProcess {
  120447. /** @hidden */
  120448. texelWidth: number;
  120449. /** @hidden */
  120450. texelHeight: number;
  120451. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120452. private _getDefines;
  120453. }
  120454. }
  120455. declare module BABYLON {
  120456. /** @hidden */
  120457. export var grainPixelShader: {
  120458. name: string;
  120459. shader: string;
  120460. };
  120461. }
  120462. declare module BABYLON {
  120463. /**
  120464. * The GrainPostProcess adds noise to the image at mid luminance levels
  120465. */
  120466. export class GrainPostProcess extends PostProcess {
  120467. /**
  120468. * The intensity of the grain added (default: 30)
  120469. */
  120470. intensity: number;
  120471. /**
  120472. * If the grain should be randomized on every frame
  120473. */
  120474. animated: boolean;
  120475. /**
  120476. * Creates a new instance of @see GrainPostProcess
  120477. * @param name The name of the effect.
  120478. * @param options The required width/height ratio to downsize to before computing the render pass.
  120479. * @param camera The camera to apply the render pass to.
  120480. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120481. * @param engine The engine which the post process will be applied. (default: current engine)
  120482. * @param reusable If the post process can be reused on the same frame. (default: false)
  120483. * @param textureType Type of textures used when performing the post process. (default: 0)
  120484. * @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)
  120485. */
  120486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120487. }
  120488. }
  120489. declare module BABYLON {
  120490. /** @hidden */
  120491. export var highlightsPixelShader: {
  120492. name: string;
  120493. shader: string;
  120494. };
  120495. }
  120496. declare module BABYLON {
  120497. /**
  120498. * Extracts highlights from the image
  120499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120500. */
  120501. export class HighlightsPostProcess extends PostProcess {
  120502. /**
  120503. * Extracts highlights from the image
  120504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  120505. * @param name The name of the effect.
  120506. * @param options The required width/height ratio to downsize to before computing the render pass.
  120507. * @param camera The camera to apply the render pass to.
  120508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120509. * @param engine The engine which the post process will be applied. (default: current engine)
  120510. * @param reusable If the post process can be reused on the same frame. (default: false)
  120511. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  120512. */
  120513. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  120514. }
  120515. }
  120516. declare module BABYLON {
  120517. /** @hidden */
  120518. export var mrtFragmentDeclaration: {
  120519. name: string;
  120520. shader: string;
  120521. };
  120522. }
  120523. declare module BABYLON {
  120524. /** @hidden */
  120525. export var geometryPixelShader: {
  120526. name: string;
  120527. shader: string;
  120528. };
  120529. }
  120530. declare module BABYLON {
  120531. /** @hidden */
  120532. export var geometryVertexShader: {
  120533. name: string;
  120534. shader: string;
  120535. };
  120536. }
  120537. declare module BABYLON {
  120538. /** @hidden */
  120539. interface ISavedTransformationMatrix {
  120540. world: Matrix;
  120541. viewProjection: Matrix;
  120542. }
  120543. /**
  120544. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  120545. */
  120546. export class GeometryBufferRenderer {
  120547. /**
  120548. * Constant used to retrieve the position texture index in the G-Buffer textures array
  120549. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  120550. */
  120551. static readonly POSITION_TEXTURE_TYPE: number;
  120552. /**
  120553. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  120554. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  120555. */
  120556. static readonly VELOCITY_TEXTURE_TYPE: number;
  120557. /**
  120558. * Dictionary used to store the previous transformation matrices of each rendered mesh
  120559. * in order to compute objects velocities when enableVelocity is set to "true"
  120560. * @hidden
  120561. */
  120562. _previousTransformationMatrices: {
  120563. [index: number]: ISavedTransformationMatrix;
  120564. };
  120565. /**
  120566. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  120567. * in order to compute objects velocities when enableVelocity is set to "true"
  120568. * @hidden
  120569. */
  120570. _previousBonesTransformationMatrices: {
  120571. [index: number]: Float32Array;
  120572. };
  120573. /**
  120574. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  120575. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  120576. */
  120577. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  120578. private _scene;
  120579. private _multiRenderTarget;
  120580. private _ratio;
  120581. private _enablePosition;
  120582. private _enableVelocity;
  120583. private _positionIndex;
  120584. private _velocityIndex;
  120585. protected _effect: Effect;
  120586. protected _cachedDefines: string;
  120587. /**
  120588. * Set the render list (meshes to be rendered) used in the G buffer.
  120589. */
  120590. renderList: Mesh[];
  120591. /**
  120592. * Gets wether or not G buffer are supported by the running hardware.
  120593. * This requires draw buffer supports
  120594. */
  120595. readonly isSupported: boolean;
  120596. /**
  120597. * Returns the index of the given texture type in the G-Buffer textures array
  120598. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  120599. * @returns the index of the given texture type in the G-Buffer textures array
  120600. */
  120601. getTextureIndex(textureType: number): number;
  120602. /**
  120603. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  120604. */
  120605. /**
  120606. * Sets whether or not objects positions are enabled for the G buffer.
  120607. */
  120608. enablePosition: boolean;
  120609. /**
  120610. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  120611. */
  120612. /**
  120613. * Sets wether or not objects velocities are enabled for the G buffer.
  120614. */
  120615. enableVelocity: boolean;
  120616. /**
  120617. * Gets the scene associated with the buffer.
  120618. */
  120619. readonly scene: Scene;
  120620. /**
  120621. * Gets the ratio used by the buffer during its creation.
  120622. * How big is the buffer related to the main canvas.
  120623. */
  120624. readonly ratio: number;
  120625. /** @hidden */
  120626. static _SceneComponentInitialization: (scene: Scene) => void;
  120627. /**
  120628. * Creates a new G Buffer for the scene
  120629. * @param scene The scene the buffer belongs to
  120630. * @param ratio How big is the buffer related to the main canvas.
  120631. */
  120632. constructor(scene: Scene, ratio?: number);
  120633. /**
  120634. * Checks wether everything is ready to render a submesh to the G buffer.
  120635. * @param subMesh the submesh to check readiness for
  120636. * @param useInstances is the mesh drawn using instance or not
  120637. * @returns true if ready otherwise false
  120638. */
  120639. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120640. /**
  120641. * Gets the current underlying G Buffer.
  120642. * @returns the buffer
  120643. */
  120644. getGBuffer(): MultiRenderTarget;
  120645. /**
  120646. * Gets the number of samples used to render the buffer (anti aliasing).
  120647. */
  120648. /**
  120649. * Sets the number of samples used to render the buffer (anti aliasing).
  120650. */
  120651. samples: number;
  120652. /**
  120653. * Disposes the renderer and frees up associated resources.
  120654. */
  120655. dispose(): void;
  120656. protected _createRenderTargets(): void;
  120657. private _copyBonesTransformationMatrices;
  120658. }
  120659. }
  120660. declare module BABYLON {
  120661. interface Scene {
  120662. /** @hidden (Backing field) */
  120663. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120664. /**
  120665. * Gets or Sets the current geometry buffer associated to the scene.
  120666. */
  120667. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  120668. /**
  120669. * Enables a GeometryBufferRender and associates it with the scene
  120670. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  120671. * @returns the GeometryBufferRenderer
  120672. */
  120673. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  120674. /**
  120675. * Disables the GeometryBufferRender associated with the scene
  120676. */
  120677. disableGeometryBufferRenderer(): void;
  120678. }
  120679. /**
  120680. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  120681. * in several rendering techniques.
  120682. */
  120683. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  120684. /**
  120685. * The component name helpful to identify the component in the list of scene components.
  120686. */
  120687. readonly name: string;
  120688. /**
  120689. * The scene the component belongs to.
  120690. */
  120691. scene: Scene;
  120692. /**
  120693. * Creates a new instance of the component for the given scene
  120694. * @param scene Defines the scene to register the component in
  120695. */
  120696. constructor(scene: Scene);
  120697. /**
  120698. * Registers the component in a given scene
  120699. */
  120700. register(): void;
  120701. /**
  120702. * Rebuilds the elements related to this component in case of
  120703. * context lost for instance.
  120704. */
  120705. rebuild(): void;
  120706. /**
  120707. * Disposes the component and the associated ressources
  120708. */
  120709. dispose(): void;
  120710. private _gatherRenderTargets;
  120711. }
  120712. }
  120713. declare module BABYLON {
  120714. /** @hidden */
  120715. export var motionBlurPixelShader: {
  120716. name: string;
  120717. shader: string;
  120718. };
  120719. }
  120720. declare module BABYLON {
  120721. /**
  120722. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  120723. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  120724. * As an example, all you have to do is to create the post-process:
  120725. * var mb = new BABYLON.MotionBlurPostProcess(
  120726. * 'mb', // The name of the effect.
  120727. * scene, // The scene containing the objects to blur according to their velocity.
  120728. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  120729. * camera // The camera to apply the render pass to.
  120730. * );
  120731. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  120732. */
  120733. export class MotionBlurPostProcess extends PostProcess {
  120734. /**
  120735. * Defines how much the image is blurred by the movement. Default value is equal to 1
  120736. */
  120737. motionStrength: number;
  120738. /**
  120739. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  120740. */
  120741. /**
  120742. * Sets the number of iterations to be used for motion blur quality
  120743. */
  120744. motionBlurSamples: number;
  120745. private _motionBlurSamples;
  120746. private _geometryBufferRenderer;
  120747. /**
  120748. * Creates a new instance MotionBlurPostProcess
  120749. * @param name The name of the effect.
  120750. * @param scene The scene containing the objects to blur according to their velocity.
  120751. * @param options The required width/height ratio to downsize to before computing the render pass.
  120752. * @param camera The camera to apply the render pass to.
  120753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120754. * @param engine The engine which the post process will be applied. (default: current engine)
  120755. * @param reusable If the post process can be reused on the same frame. (default: false)
  120756. * @param textureType Type of textures used when performing the post process. (default: 0)
  120757. * @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)
  120758. */
  120759. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120760. /**
  120761. * Excludes the given skinned mesh from computing bones velocities.
  120762. * 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.
  120763. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  120764. */
  120765. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120766. /**
  120767. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  120768. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  120769. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  120770. */
  120771. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  120772. /**
  120773. * Disposes the post process.
  120774. * @param camera The camera to dispose the post process on.
  120775. */
  120776. dispose(camera?: Camera): void;
  120777. }
  120778. }
  120779. declare module BABYLON {
  120780. /** @hidden */
  120781. export var refractionPixelShader: {
  120782. name: string;
  120783. shader: string;
  120784. };
  120785. }
  120786. declare module BABYLON {
  120787. /**
  120788. * Post process which applies a refractin texture
  120789. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120790. */
  120791. export class RefractionPostProcess extends PostProcess {
  120792. /** the base color of the refraction (used to taint the rendering) */
  120793. color: Color3;
  120794. /** simulated refraction depth */
  120795. depth: number;
  120796. /** the coefficient of the base color (0 to remove base color tainting) */
  120797. colorLevel: number;
  120798. private _refTexture;
  120799. private _ownRefractionTexture;
  120800. /**
  120801. * Gets or sets the refraction texture
  120802. * Please note that you are responsible for disposing the texture if you set it manually
  120803. */
  120804. refractionTexture: Texture;
  120805. /**
  120806. * Initializes the RefractionPostProcess
  120807. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  120808. * @param name The name of the effect.
  120809. * @param refractionTextureUrl Url of the refraction texture to use
  120810. * @param color the base color of the refraction (used to taint the rendering)
  120811. * @param depth simulated refraction depth
  120812. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  120813. * @param camera The camera to apply the render pass to.
  120814. * @param options The required width/height ratio to downsize to before computing the render pass.
  120815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120816. * @param engine The engine which the post process will be applied. (default: current engine)
  120817. * @param reusable If the post process can be reused on the same frame. (default: false)
  120818. */
  120819. constructor(name: string, refractionTextureUrl: string,
  120820. /** the base color of the refraction (used to taint the rendering) */
  120821. color: Color3,
  120822. /** simulated refraction depth */
  120823. depth: number,
  120824. /** the coefficient of the base color (0 to remove base color tainting) */
  120825. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  120826. /**
  120827. * Disposes of the post process
  120828. * @param camera Camera to dispose post process on
  120829. */
  120830. dispose(camera: Camera): void;
  120831. }
  120832. }
  120833. declare module BABYLON {
  120834. /** @hidden */
  120835. export var sharpenPixelShader: {
  120836. name: string;
  120837. shader: string;
  120838. };
  120839. }
  120840. declare module BABYLON {
  120841. /**
  120842. * The SharpenPostProcess applies a sharpen kernel to every pixel
  120843. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  120844. */
  120845. export class SharpenPostProcess extends PostProcess {
  120846. /**
  120847. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  120848. */
  120849. colorAmount: number;
  120850. /**
  120851. * How much sharpness should be applied (default: 0.3)
  120852. */
  120853. edgeAmount: number;
  120854. /**
  120855. * Creates a new instance ConvolutionPostProcess
  120856. * @param name The name of the effect.
  120857. * @param options The required width/height ratio to downsize to before computing the render pass.
  120858. * @param camera The camera to apply the render pass to.
  120859. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120860. * @param engine The engine which the post process will be applied. (default: current engine)
  120861. * @param reusable If the post process can be reused on the same frame. (default: false)
  120862. * @param textureType Type of textures used when performing the post process. (default: 0)
  120863. * @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)
  120864. */
  120865. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  120866. }
  120867. }
  120868. declare module BABYLON {
  120869. /**
  120870. * PostProcessRenderPipeline
  120871. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120872. */
  120873. export class PostProcessRenderPipeline {
  120874. private engine;
  120875. private _renderEffects;
  120876. private _renderEffectsForIsolatedPass;
  120877. /**
  120878. * List of inspectable custom properties (used by the Inspector)
  120879. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  120880. */
  120881. inspectableCustomProperties: IInspectable[];
  120882. /**
  120883. * @hidden
  120884. */
  120885. protected _cameras: Camera[];
  120886. /** @hidden */
  120887. _name: string;
  120888. /**
  120889. * Gets pipeline name
  120890. */
  120891. readonly name: string;
  120892. /**
  120893. * Initializes a PostProcessRenderPipeline
  120894. * @param engine engine to add the pipeline to
  120895. * @param name name of the pipeline
  120896. */
  120897. constructor(engine: Engine, name: string);
  120898. /**
  120899. * Gets the class name
  120900. * @returns "PostProcessRenderPipeline"
  120901. */
  120902. getClassName(): string;
  120903. /**
  120904. * If all the render effects in the pipeline are supported
  120905. */
  120906. readonly isSupported: boolean;
  120907. /**
  120908. * Adds an effect to the pipeline
  120909. * @param renderEffect the effect to add
  120910. */
  120911. addEffect(renderEffect: PostProcessRenderEffect): void;
  120912. /** @hidden */
  120913. _rebuild(): void;
  120914. /** @hidden */
  120915. _enableEffect(renderEffectName: string, cameras: Camera): void;
  120916. /** @hidden */
  120917. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  120918. /** @hidden */
  120919. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120920. /** @hidden */
  120921. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  120922. /** @hidden */
  120923. _attachCameras(cameras: Camera, unique: boolean): void;
  120924. /** @hidden */
  120925. _attachCameras(cameras: Camera[], unique: boolean): void;
  120926. /** @hidden */
  120927. _detachCameras(cameras: Camera): void;
  120928. /** @hidden */
  120929. _detachCameras(cameras: Nullable<Camera[]>): void;
  120930. /** @hidden */
  120931. _update(): void;
  120932. /** @hidden */
  120933. _reset(): void;
  120934. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  120935. /**
  120936. * Disposes of the pipeline
  120937. */
  120938. dispose(): void;
  120939. }
  120940. }
  120941. declare module BABYLON {
  120942. /**
  120943. * PostProcessRenderPipelineManager class
  120944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120945. */
  120946. export class PostProcessRenderPipelineManager {
  120947. private _renderPipelines;
  120948. /**
  120949. * Initializes a PostProcessRenderPipelineManager
  120950. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  120951. */
  120952. constructor();
  120953. /**
  120954. * Gets the list of supported render pipelines
  120955. */
  120956. readonly supportedPipelines: PostProcessRenderPipeline[];
  120957. /**
  120958. * Adds a pipeline to the manager
  120959. * @param renderPipeline The pipeline to add
  120960. */
  120961. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  120962. /**
  120963. * Attaches a camera to the pipeline
  120964. * @param renderPipelineName The name of the pipeline to attach to
  120965. * @param cameras the camera to attach
  120966. * @param unique if the camera can be attached multiple times to the pipeline
  120967. */
  120968. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  120969. /**
  120970. * Detaches a camera from the pipeline
  120971. * @param renderPipelineName The name of the pipeline to detach from
  120972. * @param cameras the camera to detach
  120973. */
  120974. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  120975. /**
  120976. * Enables an effect by name on a pipeline
  120977. * @param renderPipelineName the name of the pipeline to enable the effect in
  120978. * @param renderEffectName the name of the effect to enable
  120979. * @param cameras the cameras that the effect should be enabled on
  120980. */
  120981. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  120982. /**
  120983. * Disables an effect by name on a pipeline
  120984. * @param renderPipelineName the name of the pipeline to disable the effect in
  120985. * @param renderEffectName the name of the effect to disable
  120986. * @param cameras the cameras that the effect should be disabled on
  120987. */
  120988. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  120989. /**
  120990. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  120991. */
  120992. update(): void;
  120993. /** @hidden */
  120994. _rebuild(): void;
  120995. /**
  120996. * Disposes of the manager and pipelines
  120997. */
  120998. dispose(): void;
  120999. }
  121000. }
  121001. declare module BABYLON {
  121002. interface Scene {
  121003. /** @hidden (Backing field) */
  121004. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121005. /**
  121006. * Gets the postprocess render pipeline manager
  121007. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  121008. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121009. */
  121010. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  121011. }
  121012. /**
  121013. * Defines the Render Pipeline scene component responsible to rendering pipelines
  121014. */
  121015. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  121016. /**
  121017. * The component name helpfull to identify the component in the list of scene components.
  121018. */
  121019. readonly name: string;
  121020. /**
  121021. * The scene the component belongs to.
  121022. */
  121023. scene: Scene;
  121024. /**
  121025. * Creates a new instance of the component for the given scene
  121026. * @param scene Defines the scene to register the component in
  121027. */
  121028. constructor(scene: Scene);
  121029. /**
  121030. * Registers the component in a given scene
  121031. */
  121032. register(): void;
  121033. /**
  121034. * Rebuilds the elements related to this component in case of
  121035. * context lost for instance.
  121036. */
  121037. rebuild(): void;
  121038. /**
  121039. * Disposes the component and the associated ressources
  121040. */
  121041. dispose(): void;
  121042. private _gatherRenderTargets;
  121043. }
  121044. }
  121045. declare module BABYLON {
  121046. /**
  121047. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  121048. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  121049. */
  121050. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121051. private _scene;
  121052. private _camerasToBeAttached;
  121053. /**
  121054. * ID of the sharpen post process,
  121055. */
  121056. private readonly SharpenPostProcessId;
  121057. /**
  121058. * @ignore
  121059. * ID of the image processing post process;
  121060. */
  121061. readonly ImageProcessingPostProcessId: string;
  121062. /**
  121063. * @ignore
  121064. * ID of the Fast Approximate Anti-Aliasing post process;
  121065. */
  121066. readonly FxaaPostProcessId: string;
  121067. /**
  121068. * ID of the chromatic aberration post process,
  121069. */
  121070. private readonly ChromaticAberrationPostProcessId;
  121071. /**
  121072. * ID of the grain post process
  121073. */
  121074. private readonly GrainPostProcessId;
  121075. /**
  121076. * Sharpen post process which will apply a sharpen convolution to enhance edges
  121077. */
  121078. sharpen: SharpenPostProcess;
  121079. private _sharpenEffect;
  121080. private bloom;
  121081. /**
  121082. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  121083. */
  121084. depthOfField: DepthOfFieldEffect;
  121085. /**
  121086. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121087. */
  121088. fxaa: FxaaPostProcess;
  121089. /**
  121090. * Image post processing pass used to perform operations such as tone mapping or color grading.
  121091. */
  121092. imageProcessing: ImageProcessingPostProcess;
  121093. /**
  121094. * Chromatic aberration post process which will shift rgb colors in the image
  121095. */
  121096. chromaticAberration: ChromaticAberrationPostProcess;
  121097. private _chromaticAberrationEffect;
  121098. /**
  121099. * Grain post process which add noise to the image
  121100. */
  121101. grain: GrainPostProcess;
  121102. private _grainEffect;
  121103. /**
  121104. * Glow post process which adds a glow to emissive areas of the image
  121105. */
  121106. private _glowLayer;
  121107. /**
  121108. * Animations which can be used to tweak settings over a period of time
  121109. */
  121110. animations: Animation[];
  121111. private _imageProcessingConfigurationObserver;
  121112. private _sharpenEnabled;
  121113. private _bloomEnabled;
  121114. private _depthOfFieldEnabled;
  121115. private _depthOfFieldBlurLevel;
  121116. private _fxaaEnabled;
  121117. private _imageProcessingEnabled;
  121118. private _defaultPipelineTextureType;
  121119. private _bloomScale;
  121120. private _chromaticAberrationEnabled;
  121121. private _grainEnabled;
  121122. private _buildAllowed;
  121123. /**
  121124. * Gets active scene
  121125. */
  121126. readonly scene: Scene;
  121127. /**
  121128. * Enable or disable the sharpen process from the pipeline
  121129. */
  121130. sharpenEnabled: boolean;
  121131. private _resizeObserver;
  121132. private _hardwareScaleLevel;
  121133. private _bloomKernel;
  121134. /**
  121135. * Specifies the size of the bloom blur kernel, relative to the final output size
  121136. */
  121137. bloomKernel: number;
  121138. /**
  121139. * Specifies the weight of the bloom in the final rendering
  121140. */
  121141. private _bloomWeight;
  121142. /**
  121143. * Specifies the luma threshold for the area that will be blurred by the bloom
  121144. */
  121145. private _bloomThreshold;
  121146. private _hdr;
  121147. /**
  121148. * The strength of the bloom.
  121149. */
  121150. bloomWeight: number;
  121151. /**
  121152. * The strength of the bloom.
  121153. */
  121154. bloomThreshold: number;
  121155. /**
  121156. * The scale of the bloom, lower value will provide better performance.
  121157. */
  121158. bloomScale: number;
  121159. /**
  121160. * Enable or disable the bloom from the pipeline
  121161. */
  121162. bloomEnabled: boolean;
  121163. private _rebuildBloom;
  121164. /**
  121165. * If the depth of field is enabled.
  121166. */
  121167. depthOfFieldEnabled: boolean;
  121168. /**
  121169. * Blur level of the depth of field effect. (Higher blur will effect performance)
  121170. */
  121171. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  121172. /**
  121173. * If the anti aliasing is enabled.
  121174. */
  121175. fxaaEnabled: boolean;
  121176. private _samples;
  121177. /**
  121178. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  121179. */
  121180. samples: number;
  121181. /**
  121182. * If image processing is enabled.
  121183. */
  121184. imageProcessingEnabled: boolean;
  121185. /**
  121186. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  121187. */
  121188. glowLayerEnabled: boolean;
  121189. /**
  121190. * Gets the glow layer (or null if not defined)
  121191. */
  121192. readonly glowLayer: Nullable<GlowLayer>;
  121193. /**
  121194. * Enable or disable the chromaticAberration process from the pipeline
  121195. */
  121196. chromaticAberrationEnabled: boolean;
  121197. /**
  121198. * Enable or disable the grain process from the pipeline
  121199. */
  121200. grainEnabled: boolean;
  121201. /**
  121202. * @constructor
  121203. * @param name - The rendering pipeline name (default: "")
  121204. * @param hdr - If high dynamic range textures should be used (default: true)
  121205. * @param scene - The scene linked to this pipeline (default: the last created scene)
  121206. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  121207. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  121208. */
  121209. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  121210. /**
  121211. * Get the class name
  121212. * @returns "DefaultRenderingPipeline"
  121213. */
  121214. getClassName(): string;
  121215. /**
  121216. * Force the compilation of the entire pipeline.
  121217. */
  121218. prepare(): void;
  121219. private _hasCleared;
  121220. private _prevPostProcess;
  121221. private _prevPrevPostProcess;
  121222. private _setAutoClearAndTextureSharing;
  121223. private _depthOfFieldSceneObserver;
  121224. private _buildPipeline;
  121225. private _disposePostProcesses;
  121226. /**
  121227. * Adds a camera to the pipeline
  121228. * @param camera the camera to be added
  121229. */
  121230. addCamera(camera: Camera): void;
  121231. /**
  121232. * Removes a camera from the pipeline
  121233. * @param camera the camera to remove
  121234. */
  121235. removeCamera(camera: Camera): void;
  121236. /**
  121237. * Dispose of the pipeline and stop all post processes
  121238. */
  121239. dispose(): void;
  121240. /**
  121241. * Serialize the rendering pipeline (Used when exporting)
  121242. * @returns the serialized object
  121243. */
  121244. serialize(): any;
  121245. /**
  121246. * Parse the serialized pipeline
  121247. * @param source Source pipeline.
  121248. * @param scene The scene to load the pipeline to.
  121249. * @param rootUrl The URL of the serialized pipeline.
  121250. * @returns An instantiated pipeline from the serialized object.
  121251. */
  121252. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  121253. }
  121254. }
  121255. declare module BABYLON {
  121256. /** @hidden */
  121257. export var lensHighlightsPixelShader: {
  121258. name: string;
  121259. shader: string;
  121260. };
  121261. }
  121262. declare module BABYLON {
  121263. /** @hidden */
  121264. export var depthOfFieldPixelShader: {
  121265. name: string;
  121266. shader: string;
  121267. };
  121268. }
  121269. declare module BABYLON {
  121270. /**
  121271. * BABYLON.JS Chromatic Aberration GLSL Shader
  121272. * Author: Olivier Guyot
  121273. * Separates very slightly R, G and B colors on the edges of the screen
  121274. * Inspired by Francois Tarlier & Martins Upitis
  121275. */
  121276. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  121277. /**
  121278. * @ignore
  121279. * The chromatic aberration PostProcess id in the pipeline
  121280. */
  121281. LensChromaticAberrationEffect: string;
  121282. /**
  121283. * @ignore
  121284. * The highlights enhancing PostProcess id in the pipeline
  121285. */
  121286. HighlightsEnhancingEffect: string;
  121287. /**
  121288. * @ignore
  121289. * The depth-of-field PostProcess id in the pipeline
  121290. */
  121291. LensDepthOfFieldEffect: string;
  121292. private _scene;
  121293. private _depthTexture;
  121294. private _grainTexture;
  121295. private _chromaticAberrationPostProcess;
  121296. private _highlightsPostProcess;
  121297. private _depthOfFieldPostProcess;
  121298. private _edgeBlur;
  121299. private _grainAmount;
  121300. private _chromaticAberration;
  121301. private _distortion;
  121302. private _highlightsGain;
  121303. private _highlightsThreshold;
  121304. private _dofDistance;
  121305. private _dofAperture;
  121306. private _dofDarken;
  121307. private _dofPentagon;
  121308. private _blurNoise;
  121309. /**
  121310. * @constructor
  121311. *
  121312. * Effect parameters are as follow:
  121313. * {
  121314. * chromatic_aberration: number; // from 0 to x (1 for realism)
  121315. * edge_blur: number; // from 0 to x (1 for realism)
  121316. * distortion: number; // from 0 to x (1 for realism)
  121317. * grain_amount: number; // from 0 to 1
  121318. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  121319. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  121320. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  121321. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  121322. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  121323. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  121324. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  121325. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  121326. * }
  121327. * Note: if an effect parameter is unset, effect is disabled
  121328. *
  121329. * @param name The rendering pipeline name
  121330. * @param parameters - An object containing all parameters (see above)
  121331. * @param scene The scene linked to this pipeline
  121332. * @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)
  121333. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121334. */
  121335. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  121336. /**
  121337. * Get the class name
  121338. * @returns "LensRenderingPipeline"
  121339. */
  121340. getClassName(): string;
  121341. /**
  121342. * Gets associated scene
  121343. */
  121344. readonly scene: Scene;
  121345. /**
  121346. * Gets or sets the edge blur
  121347. */
  121348. edgeBlur: number;
  121349. /**
  121350. * Gets or sets the grain amount
  121351. */
  121352. grainAmount: number;
  121353. /**
  121354. * Gets or sets the chromatic aberration amount
  121355. */
  121356. chromaticAberration: number;
  121357. /**
  121358. * Gets or sets the depth of field aperture
  121359. */
  121360. dofAperture: number;
  121361. /**
  121362. * Gets or sets the edge distortion
  121363. */
  121364. edgeDistortion: number;
  121365. /**
  121366. * Gets or sets the depth of field distortion
  121367. */
  121368. dofDistortion: number;
  121369. /**
  121370. * Gets or sets the darken out of focus amount
  121371. */
  121372. darkenOutOfFocus: number;
  121373. /**
  121374. * Gets or sets a boolean indicating if blur noise is enabled
  121375. */
  121376. blurNoise: boolean;
  121377. /**
  121378. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  121379. */
  121380. pentagonBokeh: boolean;
  121381. /**
  121382. * Gets or sets the highlight grain amount
  121383. */
  121384. highlightsGain: number;
  121385. /**
  121386. * Gets or sets the highlight threshold
  121387. */
  121388. highlightsThreshold: number;
  121389. /**
  121390. * Sets the amount of blur at the edges
  121391. * @param amount blur amount
  121392. */
  121393. setEdgeBlur(amount: number): void;
  121394. /**
  121395. * Sets edge blur to 0
  121396. */
  121397. disableEdgeBlur(): void;
  121398. /**
  121399. * Sets the amout of grain
  121400. * @param amount Amount of grain
  121401. */
  121402. setGrainAmount(amount: number): void;
  121403. /**
  121404. * Set grain amount to 0
  121405. */
  121406. disableGrain(): void;
  121407. /**
  121408. * Sets the chromatic aberration amount
  121409. * @param amount amount of chromatic aberration
  121410. */
  121411. setChromaticAberration(amount: number): void;
  121412. /**
  121413. * Sets chromatic aberration amount to 0
  121414. */
  121415. disableChromaticAberration(): void;
  121416. /**
  121417. * Sets the EdgeDistortion amount
  121418. * @param amount amount of EdgeDistortion
  121419. */
  121420. setEdgeDistortion(amount: number): void;
  121421. /**
  121422. * Sets edge distortion to 0
  121423. */
  121424. disableEdgeDistortion(): void;
  121425. /**
  121426. * Sets the FocusDistance amount
  121427. * @param amount amount of FocusDistance
  121428. */
  121429. setFocusDistance(amount: number): void;
  121430. /**
  121431. * Disables depth of field
  121432. */
  121433. disableDepthOfField(): void;
  121434. /**
  121435. * Sets the Aperture amount
  121436. * @param amount amount of Aperture
  121437. */
  121438. setAperture(amount: number): void;
  121439. /**
  121440. * Sets the DarkenOutOfFocus amount
  121441. * @param amount amount of DarkenOutOfFocus
  121442. */
  121443. setDarkenOutOfFocus(amount: number): void;
  121444. private _pentagonBokehIsEnabled;
  121445. /**
  121446. * Creates a pentagon bokeh effect
  121447. */
  121448. enablePentagonBokeh(): void;
  121449. /**
  121450. * Disables the pentagon bokeh effect
  121451. */
  121452. disablePentagonBokeh(): void;
  121453. /**
  121454. * Enables noise blur
  121455. */
  121456. enableNoiseBlur(): void;
  121457. /**
  121458. * Disables noise blur
  121459. */
  121460. disableNoiseBlur(): void;
  121461. /**
  121462. * Sets the HighlightsGain amount
  121463. * @param amount amount of HighlightsGain
  121464. */
  121465. setHighlightsGain(amount: number): void;
  121466. /**
  121467. * Sets the HighlightsThreshold amount
  121468. * @param amount amount of HighlightsThreshold
  121469. */
  121470. setHighlightsThreshold(amount: number): void;
  121471. /**
  121472. * Disables highlights
  121473. */
  121474. disableHighlights(): void;
  121475. /**
  121476. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  121477. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  121478. */
  121479. dispose(disableDepthRender?: boolean): void;
  121480. private _createChromaticAberrationPostProcess;
  121481. private _createHighlightsPostProcess;
  121482. private _createDepthOfFieldPostProcess;
  121483. private _createGrainTexture;
  121484. }
  121485. }
  121486. declare module BABYLON {
  121487. /** @hidden */
  121488. export var ssao2PixelShader: {
  121489. name: string;
  121490. shader: string;
  121491. };
  121492. }
  121493. declare module BABYLON {
  121494. /** @hidden */
  121495. export var ssaoCombinePixelShader: {
  121496. name: string;
  121497. shader: string;
  121498. };
  121499. }
  121500. declare module BABYLON {
  121501. /**
  121502. * Render pipeline to produce ssao effect
  121503. */
  121504. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  121505. /**
  121506. * @ignore
  121507. * The PassPostProcess id in the pipeline that contains the original scene color
  121508. */
  121509. SSAOOriginalSceneColorEffect: string;
  121510. /**
  121511. * @ignore
  121512. * The SSAO PostProcess id in the pipeline
  121513. */
  121514. SSAORenderEffect: string;
  121515. /**
  121516. * @ignore
  121517. * The horizontal blur PostProcess id in the pipeline
  121518. */
  121519. SSAOBlurHRenderEffect: string;
  121520. /**
  121521. * @ignore
  121522. * The vertical blur PostProcess id in the pipeline
  121523. */
  121524. SSAOBlurVRenderEffect: string;
  121525. /**
  121526. * @ignore
  121527. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121528. */
  121529. SSAOCombineRenderEffect: string;
  121530. /**
  121531. * The output strength of the SSAO post-process. Default value is 1.0.
  121532. */
  121533. totalStrength: number;
  121534. /**
  121535. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  121536. */
  121537. maxZ: number;
  121538. /**
  121539. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  121540. */
  121541. minZAspect: number;
  121542. private _samples;
  121543. /**
  121544. * Number of samples used for the SSAO calculations. Default value is 8
  121545. */
  121546. samples: number;
  121547. private _textureSamples;
  121548. /**
  121549. * Number of samples to use for antialiasing
  121550. */
  121551. textureSamples: number;
  121552. /**
  121553. * Ratio object used for SSAO ratio and blur ratio
  121554. */
  121555. private _ratio;
  121556. /**
  121557. * Dynamically generated sphere sampler.
  121558. */
  121559. private _sampleSphere;
  121560. /**
  121561. * Blur filter offsets
  121562. */
  121563. private _samplerOffsets;
  121564. private _expensiveBlur;
  121565. /**
  121566. * If bilateral blur should be used
  121567. */
  121568. expensiveBlur: boolean;
  121569. /**
  121570. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  121571. */
  121572. radius: number;
  121573. /**
  121574. * The base color of the SSAO post-process
  121575. * The final result is "base + ssao" between [0, 1]
  121576. */
  121577. base: number;
  121578. /**
  121579. * Support test.
  121580. */
  121581. static readonly IsSupported: boolean;
  121582. private _scene;
  121583. private _depthTexture;
  121584. private _normalTexture;
  121585. private _randomTexture;
  121586. private _originalColorPostProcess;
  121587. private _ssaoPostProcess;
  121588. private _blurHPostProcess;
  121589. private _blurVPostProcess;
  121590. private _ssaoCombinePostProcess;
  121591. private _firstUpdate;
  121592. /**
  121593. * Gets active scene
  121594. */
  121595. readonly scene: Scene;
  121596. /**
  121597. * @constructor
  121598. * @param name The rendering pipeline name
  121599. * @param scene The scene linked to this pipeline
  121600. * @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 }
  121601. * @param cameras The array of cameras that the rendering pipeline will be attached to
  121602. */
  121603. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121604. /**
  121605. * Get the class name
  121606. * @returns "SSAO2RenderingPipeline"
  121607. */
  121608. getClassName(): string;
  121609. /**
  121610. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121611. */
  121612. dispose(disableGeometryBufferRenderer?: boolean): void;
  121613. private _createBlurPostProcess;
  121614. /** @hidden */
  121615. _rebuild(): void;
  121616. private _bits;
  121617. private _radicalInverse_VdC;
  121618. private _hammersley;
  121619. private _hemisphereSample_uniform;
  121620. private _generateHemisphere;
  121621. private _createSSAOPostProcess;
  121622. private _createSSAOCombinePostProcess;
  121623. private _createRandomTexture;
  121624. /**
  121625. * Serialize the rendering pipeline (Used when exporting)
  121626. * @returns the serialized object
  121627. */
  121628. serialize(): any;
  121629. /**
  121630. * Parse the serialized pipeline
  121631. * @param source Source pipeline.
  121632. * @param scene The scene to load the pipeline to.
  121633. * @param rootUrl The URL of the serialized pipeline.
  121634. * @returns An instantiated pipeline from the serialized object.
  121635. */
  121636. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  121637. }
  121638. }
  121639. declare module BABYLON {
  121640. /** @hidden */
  121641. export var ssaoPixelShader: {
  121642. name: string;
  121643. shader: string;
  121644. };
  121645. }
  121646. declare module BABYLON {
  121647. /**
  121648. * Render pipeline to produce ssao effect
  121649. */
  121650. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  121651. /**
  121652. * @ignore
  121653. * The PassPostProcess id in the pipeline that contains the original scene color
  121654. */
  121655. SSAOOriginalSceneColorEffect: string;
  121656. /**
  121657. * @ignore
  121658. * The SSAO PostProcess id in the pipeline
  121659. */
  121660. SSAORenderEffect: string;
  121661. /**
  121662. * @ignore
  121663. * The horizontal blur PostProcess id in the pipeline
  121664. */
  121665. SSAOBlurHRenderEffect: string;
  121666. /**
  121667. * @ignore
  121668. * The vertical blur PostProcess id in the pipeline
  121669. */
  121670. SSAOBlurVRenderEffect: string;
  121671. /**
  121672. * @ignore
  121673. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  121674. */
  121675. SSAOCombineRenderEffect: string;
  121676. /**
  121677. * The output strength of the SSAO post-process. Default value is 1.0.
  121678. */
  121679. totalStrength: number;
  121680. /**
  121681. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  121682. */
  121683. radius: number;
  121684. /**
  121685. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  121686. * Must not be equal to fallOff and superior to fallOff.
  121687. * Default value is 0.0075
  121688. */
  121689. area: number;
  121690. /**
  121691. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  121692. * Must not be equal to area and inferior to area.
  121693. * Default value is 0.000001
  121694. */
  121695. fallOff: number;
  121696. /**
  121697. * The base color of the SSAO post-process
  121698. * The final result is "base + ssao" between [0, 1]
  121699. */
  121700. base: number;
  121701. private _scene;
  121702. private _depthTexture;
  121703. private _randomTexture;
  121704. private _originalColorPostProcess;
  121705. private _ssaoPostProcess;
  121706. private _blurHPostProcess;
  121707. private _blurVPostProcess;
  121708. private _ssaoCombinePostProcess;
  121709. private _firstUpdate;
  121710. /**
  121711. * Gets active scene
  121712. */
  121713. readonly scene: Scene;
  121714. /**
  121715. * @constructor
  121716. * @param name - The rendering pipeline name
  121717. * @param scene - The scene linked to this pipeline
  121718. * @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 }
  121719. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  121720. */
  121721. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  121722. /**
  121723. * Get the class name
  121724. * @returns "SSAORenderingPipeline"
  121725. */
  121726. getClassName(): string;
  121727. /**
  121728. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  121729. */
  121730. dispose(disableDepthRender?: boolean): void;
  121731. private _createBlurPostProcess;
  121732. /** @hidden */
  121733. _rebuild(): void;
  121734. private _createSSAOPostProcess;
  121735. private _createSSAOCombinePostProcess;
  121736. private _createRandomTexture;
  121737. }
  121738. }
  121739. declare module BABYLON {
  121740. /** @hidden */
  121741. export var standardPixelShader: {
  121742. name: string;
  121743. shader: string;
  121744. };
  121745. }
  121746. declare module BABYLON {
  121747. /**
  121748. * Standard rendering pipeline
  121749. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  121750. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  121751. */
  121752. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  121753. /**
  121754. * Public members
  121755. */
  121756. /**
  121757. * Post-process which contains the original scene color before the pipeline applies all the effects
  121758. */
  121759. originalPostProcess: Nullable<PostProcess>;
  121760. /**
  121761. * Post-process used to down scale an image x4
  121762. */
  121763. downSampleX4PostProcess: Nullable<PostProcess>;
  121764. /**
  121765. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  121766. */
  121767. brightPassPostProcess: Nullable<PostProcess>;
  121768. /**
  121769. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  121770. */
  121771. blurHPostProcesses: PostProcess[];
  121772. /**
  121773. * Post-process array storing all the vertical blur post-processes used by the pipeline
  121774. */
  121775. blurVPostProcesses: PostProcess[];
  121776. /**
  121777. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  121778. */
  121779. textureAdderPostProcess: Nullable<PostProcess>;
  121780. /**
  121781. * Post-process used to create volumetric lighting effect
  121782. */
  121783. volumetricLightPostProcess: Nullable<PostProcess>;
  121784. /**
  121785. * Post-process used to smooth the previous volumetric light post-process on the X axis
  121786. */
  121787. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  121788. /**
  121789. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  121790. */
  121791. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  121792. /**
  121793. * Post-process used to merge the volumetric light effect and the real scene color
  121794. */
  121795. volumetricLightMergePostProces: Nullable<PostProcess>;
  121796. /**
  121797. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  121798. */
  121799. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  121800. /**
  121801. * Base post-process used to calculate the average luminance of the final image for HDR
  121802. */
  121803. luminancePostProcess: Nullable<PostProcess>;
  121804. /**
  121805. * Post-processes used to create down sample post-processes in order to get
  121806. * the average luminance of the final image for HDR
  121807. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  121808. */
  121809. luminanceDownSamplePostProcesses: PostProcess[];
  121810. /**
  121811. * Post-process used to create a HDR effect (light adaptation)
  121812. */
  121813. hdrPostProcess: Nullable<PostProcess>;
  121814. /**
  121815. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  121816. */
  121817. textureAdderFinalPostProcess: Nullable<PostProcess>;
  121818. /**
  121819. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  121820. */
  121821. lensFlareFinalPostProcess: Nullable<PostProcess>;
  121822. /**
  121823. * Post-process used to merge the final HDR post-process and the real scene color
  121824. */
  121825. hdrFinalPostProcess: Nullable<PostProcess>;
  121826. /**
  121827. * Post-process used to create a lens flare effect
  121828. */
  121829. lensFlarePostProcess: Nullable<PostProcess>;
  121830. /**
  121831. * Post-process that merges the result of the lens flare post-process and the real scene color
  121832. */
  121833. lensFlareComposePostProcess: Nullable<PostProcess>;
  121834. /**
  121835. * Post-process used to create a motion blur effect
  121836. */
  121837. motionBlurPostProcess: Nullable<PostProcess>;
  121838. /**
  121839. * Post-process used to create a depth of field effect
  121840. */
  121841. depthOfFieldPostProcess: Nullable<PostProcess>;
  121842. /**
  121843. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  121844. */
  121845. fxaaPostProcess: Nullable<FxaaPostProcess>;
  121846. /**
  121847. * Represents the brightness threshold in order to configure the illuminated surfaces
  121848. */
  121849. brightThreshold: number;
  121850. /**
  121851. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  121852. */
  121853. blurWidth: number;
  121854. /**
  121855. * Sets if the blur for highlighted surfaces must be only horizontal
  121856. */
  121857. horizontalBlur: boolean;
  121858. /**
  121859. * Gets the overall exposure used by the pipeline
  121860. */
  121861. /**
  121862. * Sets the overall exposure used by the pipeline
  121863. */
  121864. exposure: number;
  121865. /**
  121866. * Texture used typically to simulate "dirty" on camera lens
  121867. */
  121868. lensTexture: Nullable<Texture>;
  121869. /**
  121870. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  121871. */
  121872. volumetricLightCoefficient: number;
  121873. /**
  121874. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  121875. */
  121876. volumetricLightPower: number;
  121877. /**
  121878. * Used the set the blur intensity to smooth the volumetric lights
  121879. */
  121880. volumetricLightBlurScale: number;
  121881. /**
  121882. * Light (spot or directional) used to generate the volumetric lights rays
  121883. * The source light must have a shadow generate so the pipeline can get its
  121884. * depth map
  121885. */
  121886. sourceLight: Nullable<SpotLight | DirectionalLight>;
  121887. /**
  121888. * For eye adaptation, represents the minimum luminance the eye can see
  121889. */
  121890. hdrMinimumLuminance: number;
  121891. /**
  121892. * For eye adaptation, represents the decrease luminance speed
  121893. */
  121894. hdrDecreaseRate: number;
  121895. /**
  121896. * For eye adaptation, represents the increase luminance speed
  121897. */
  121898. hdrIncreaseRate: number;
  121899. /**
  121900. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121901. */
  121902. /**
  121903. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  121904. */
  121905. hdrAutoExposure: boolean;
  121906. /**
  121907. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  121908. */
  121909. lensColorTexture: Nullable<Texture>;
  121910. /**
  121911. * The overall strengh for the lens flare effect
  121912. */
  121913. lensFlareStrength: number;
  121914. /**
  121915. * Dispersion coefficient for lens flare ghosts
  121916. */
  121917. lensFlareGhostDispersal: number;
  121918. /**
  121919. * Main lens flare halo width
  121920. */
  121921. lensFlareHaloWidth: number;
  121922. /**
  121923. * Based on the lens distortion effect, defines how much the lens flare result
  121924. * is distorted
  121925. */
  121926. lensFlareDistortionStrength: number;
  121927. /**
  121928. * Lens star texture must be used to simulate rays on the flares and is available
  121929. * in the documentation
  121930. */
  121931. lensStarTexture: Nullable<Texture>;
  121932. /**
  121933. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  121934. * flare effect by taking account of the dirt texture
  121935. */
  121936. lensFlareDirtTexture: Nullable<Texture>;
  121937. /**
  121938. * Represents the focal length for the depth of field effect
  121939. */
  121940. depthOfFieldDistance: number;
  121941. /**
  121942. * Represents the blur intensity for the blurred part of the depth of field effect
  121943. */
  121944. depthOfFieldBlurWidth: number;
  121945. /**
  121946. * Gets how much the image is blurred by the movement while using the motion blur post-process
  121947. */
  121948. /**
  121949. * Sets how much the image is blurred by the movement while using the motion blur post-process
  121950. */
  121951. motionStrength: number;
  121952. /**
  121953. * Gets wether or not the motion blur post-process is object based or screen based.
  121954. */
  121955. /**
  121956. * Sets wether or not the motion blur post-process should be object based or screen based
  121957. */
  121958. objectBasedMotionBlur: boolean;
  121959. /**
  121960. * List of animations for the pipeline (IAnimatable implementation)
  121961. */
  121962. animations: Animation[];
  121963. /**
  121964. * Private members
  121965. */
  121966. private _scene;
  121967. private _currentDepthOfFieldSource;
  121968. private _basePostProcess;
  121969. private _fixedExposure;
  121970. private _currentExposure;
  121971. private _hdrAutoExposure;
  121972. private _hdrCurrentLuminance;
  121973. private _motionStrength;
  121974. private _isObjectBasedMotionBlur;
  121975. private _floatTextureType;
  121976. private _ratio;
  121977. private _bloomEnabled;
  121978. private _depthOfFieldEnabled;
  121979. private _vlsEnabled;
  121980. private _lensFlareEnabled;
  121981. private _hdrEnabled;
  121982. private _motionBlurEnabled;
  121983. private _fxaaEnabled;
  121984. private _motionBlurSamples;
  121985. private _volumetricLightStepsCount;
  121986. private _samples;
  121987. /**
  121988. * @ignore
  121989. * Specifies if the bloom pipeline is enabled
  121990. */
  121991. BloomEnabled: boolean;
  121992. /**
  121993. * @ignore
  121994. * Specifies if the depth of field pipeline is enabed
  121995. */
  121996. DepthOfFieldEnabled: boolean;
  121997. /**
  121998. * @ignore
  121999. * Specifies if the lens flare pipeline is enabed
  122000. */
  122001. LensFlareEnabled: boolean;
  122002. /**
  122003. * @ignore
  122004. * Specifies if the HDR pipeline is enabled
  122005. */
  122006. HDREnabled: boolean;
  122007. /**
  122008. * @ignore
  122009. * Specifies if the volumetric lights scattering effect is enabled
  122010. */
  122011. VLSEnabled: boolean;
  122012. /**
  122013. * @ignore
  122014. * Specifies if the motion blur effect is enabled
  122015. */
  122016. MotionBlurEnabled: boolean;
  122017. /**
  122018. * Specifies if anti-aliasing is enabled
  122019. */
  122020. fxaaEnabled: boolean;
  122021. /**
  122022. * Specifies the number of steps used to calculate the volumetric lights
  122023. * Typically in interval [50, 200]
  122024. */
  122025. volumetricLightStepsCount: number;
  122026. /**
  122027. * Specifies the number of samples used for the motion blur effect
  122028. * Typically in interval [16, 64]
  122029. */
  122030. motionBlurSamples: number;
  122031. /**
  122032. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  122033. */
  122034. samples: number;
  122035. /**
  122036. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  122037. * @constructor
  122038. * @param name The rendering pipeline name
  122039. * @param scene The scene linked to this pipeline
  122040. * @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)
  122041. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  122042. * @param cameras The array of cameras that the rendering pipeline will be attached to
  122043. */
  122044. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  122045. private _buildPipeline;
  122046. private _createDownSampleX4PostProcess;
  122047. private _createBrightPassPostProcess;
  122048. private _createBlurPostProcesses;
  122049. private _createTextureAdderPostProcess;
  122050. private _createVolumetricLightPostProcess;
  122051. private _createLuminancePostProcesses;
  122052. private _createHdrPostProcess;
  122053. private _createLensFlarePostProcess;
  122054. private _createDepthOfFieldPostProcess;
  122055. private _createMotionBlurPostProcess;
  122056. private _getDepthTexture;
  122057. private _disposePostProcesses;
  122058. /**
  122059. * Dispose of the pipeline and stop all post processes
  122060. */
  122061. dispose(): void;
  122062. /**
  122063. * Serialize the rendering pipeline (Used when exporting)
  122064. * @returns the serialized object
  122065. */
  122066. serialize(): any;
  122067. /**
  122068. * Parse the serialized pipeline
  122069. * @param source Source pipeline.
  122070. * @param scene The scene to load the pipeline to.
  122071. * @param rootUrl The URL of the serialized pipeline.
  122072. * @returns An instantiated pipeline from the serialized object.
  122073. */
  122074. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  122075. /**
  122076. * Luminance steps
  122077. */
  122078. static LuminanceSteps: number;
  122079. }
  122080. }
  122081. declare module BABYLON {
  122082. /** @hidden */
  122083. export var tonemapPixelShader: {
  122084. name: string;
  122085. shader: string;
  122086. };
  122087. }
  122088. declare module BABYLON {
  122089. /** Defines operator used for tonemapping */
  122090. export enum TonemappingOperator {
  122091. /** Hable */
  122092. Hable = 0,
  122093. /** Reinhard */
  122094. Reinhard = 1,
  122095. /** HejiDawson */
  122096. HejiDawson = 2,
  122097. /** Photographic */
  122098. Photographic = 3
  122099. }
  122100. /**
  122101. * Defines a post process to apply tone mapping
  122102. */
  122103. export class TonemapPostProcess extends PostProcess {
  122104. private _operator;
  122105. /** Defines the required exposure adjustement */
  122106. exposureAdjustment: number;
  122107. /**
  122108. * Creates a new TonemapPostProcess
  122109. * @param name defines the name of the postprocess
  122110. * @param _operator defines the operator to use
  122111. * @param exposureAdjustment defines the required exposure adjustement
  122112. * @param camera defines the camera to use (can be null)
  122113. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  122114. * @param engine defines the hosting engine (can be ignore if camera is set)
  122115. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  122116. */
  122117. constructor(name: string, _operator: TonemappingOperator,
  122118. /** Defines the required exposure adjustement */
  122119. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  122120. }
  122121. }
  122122. declare module BABYLON {
  122123. /** @hidden */
  122124. export var depthVertexShader: {
  122125. name: string;
  122126. shader: string;
  122127. };
  122128. }
  122129. declare module BABYLON {
  122130. /** @hidden */
  122131. export var volumetricLightScatteringPixelShader: {
  122132. name: string;
  122133. shader: string;
  122134. };
  122135. }
  122136. declare module BABYLON {
  122137. /** @hidden */
  122138. export var volumetricLightScatteringPassPixelShader: {
  122139. name: string;
  122140. shader: string;
  122141. };
  122142. }
  122143. declare module BABYLON {
  122144. /**
  122145. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  122146. */
  122147. export class VolumetricLightScatteringPostProcess extends PostProcess {
  122148. private _volumetricLightScatteringPass;
  122149. private _volumetricLightScatteringRTT;
  122150. private _viewPort;
  122151. private _screenCoordinates;
  122152. private _cachedDefines;
  122153. /**
  122154. * If not undefined, the mesh position is computed from the attached node position
  122155. */
  122156. attachedNode: {
  122157. position: Vector3;
  122158. };
  122159. /**
  122160. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  122161. */
  122162. customMeshPosition: Vector3;
  122163. /**
  122164. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  122165. */
  122166. useCustomMeshPosition: boolean;
  122167. /**
  122168. * If the post-process should inverse the light scattering direction
  122169. */
  122170. invert: boolean;
  122171. /**
  122172. * The internal mesh used by the post-process
  122173. */
  122174. mesh: Mesh;
  122175. /**
  122176. * @hidden
  122177. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  122178. */
  122179. useDiffuseColor: boolean;
  122180. /**
  122181. * Array containing the excluded meshes not rendered in the internal pass
  122182. */
  122183. excludedMeshes: AbstractMesh[];
  122184. /**
  122185. * Controls the overall intensity of the post-process
  122186. */
  122187. exposure: number;
  122188. /**
  122189. * Dissipates each sample's contribution in range [0, 1]
  122190. */
  122191. decay: number;
  122192. /**
  122193. * Controls the overall intensity of each sample
  122194. */
  122195. weight: number;
  122196. /**
  122197. * Controls the density of each sample
  122198. */
  122199. density: number;
  122200. /**
  122201. * @constructor
  122202. * @param name The post-process name
  122203. * @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)
  122204. * @param camera The camera that the post-process will be attached to
  122205. * @param mesh The mesh used to create the light scattering
  122206. * @param samples The post-process quality, default 100
  122207. * @param samplingModeThe post-process filtering mode
  122208. * @param engine The babylon engine
  122209. * @param reusable If the post-process is reusable
  122210. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  122211. */
  122212. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  122213. /**
  122214. * Returns the string "VolumetricLightScatteringPostProcess"
  122215. * @returns "VolumetricLightScatteringPostProcess"
  122216. */
  122217. getClassName(): string;
  122218. private _isReady;
  122219. /**
  122220. * Sets the new light position for light scattering effect
  122221. * @param position The new custom light position
  122222. */
  122223. setCustomMeshPosition(position: Vector3): void;
  122224. /**
  122225. * Returns the light position for light scattering effect
  122226. * @return Vector3 The custom light position
  122227. */
  122228. getCustomMeshPosition(): Vector3;
  122229. /**
  122230. * Disposes the internal assets and detaches the post-process from the camera
  122231. */
  122232. dispose(camera: Camera): void;
  122233. /**
  122234. * Returns the render target texture used by the post-process
  122235. * @return the render target texture used by the post-process
  122236. */
  122237. getPass(): RenderTargetTexture;
  122238. private _meshExcluded;
  122239. private _createPass;
  122240. private _updateMeshScreenCoordinates;
  122241. /**
  122242. * Creates a default mesh for the Volumeric Light Scattering post-process
  122243. * @param name The mesh name
  122244. * @param scene The scene where to create the mesh
  122245. * @return the default mesh
  122246. */
  122247. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  122248. }
  122249. }
  122250. declare module BABYLON {
  122251. interface Scene {
  122252. /** @hidden (Backing field) */
  122253. _boundingBoxRenderer: BoundingBoxRenderer;
  122254. /** @hidden (Backing field) */
  122255. _forceShowBoundingBoxes: boolean;
  122256. /**
  122257. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  122258. */
  122259. forceShowBoundingBoxes: boolean;
  122260. /**
  122261. * Gets the bounding box renderer associated with the scene
  122262. * @returns a BoundingBoxRenderer
  122263. */
  122264. getBoundingBoxRenderer(): BoundingBoxRenderer;
  122265. }
  122266. interface AbstractMesh {
  122267. /** @hidden (Backing field) */
  122268. _showBoundingBox: boolean;
  122269. /**
  122270. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  122271. */
  122272. showBoundingBox: boolean;
  122273. }
  122274. /**
  122275. * Component responsible of rendering the bounding box of the meshes in a scene.
  122276. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  122277. */
  122278. export class BoundingBoxRenderer implements ISceneComponent {
  122279. /**
  122280. * The component name helpfull to identify the component in the list of scene components.
  122281. */
  122282. readonly name: string;
  122283. /**
  122284. * The scene the component belongs to.
  122285. */
  122286. scene: Scene;
  122287. /**
  122288. * Color of the bounding box lines placed in front of an object
  122289. */
  122290. frontColor: Color3;
  122291. /**
  122292. * Color of the bounding box lines placed behind an object
  122293. */
  122294. backColor: Color3;
  122295. /**
  122296. * Defines if the renderer should show the back lines or not
  122297. */
  122298. showBackLines: boolean;
  122299. /**
  122300. * @hidden
  122301. */
  122302. renderList: SmartArray<BoundingBox>;
  122303. private _colorShader;
  122304. private _vertexBuffers;
  122305. private _indexBuffer;
  122306. private _fillIndexBuffer;
  122307. private _fillIndexData;
  122308. /**
  122309. * Instantiates a new bounding box renderer in a scene.
  122310. * @param scene the scene the renderer renders in
  122311. */
  122312. constructor(scene: Scene);
  122313. /**
  122314. * Registers the component in a given scene
  122315. */
  122316. register(): void;
  122317. private _evaluateSubMesh;
  122318. private _activeMesh;
  122319. private _prepareRessources;
  122320. private _createIndexBuffer;
  122321. /**
  122322. * Rebuilds the elements related to this component in case of
  122323. * context lost for instance.
  122324. */
  122325. rebuild(): void;
  122326. /**
  122327. * @hidden
  122328. */
  122329. reset(): void;
  122330. /**
  122331. * Render the bounding boxes of a specific rendering group
  122332. * @param renderingGroupId defines the rendering group to render
  122333. */
  122334. render(renderingGroupId: number): void;
  122335. /**
  122336. * In case of occlusion queries, we can render the occlusion bounding box through this method
  122337. * @param mesh Define the mesh to render the occlusion bounding box for
  122338. */
  122339. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  122340. /**
  122341. * Dispose and release the resources attached to this renderer.
  122342. */
  122343. dispose(): void;
  122344. }
  122345. }
  122346. declare module BABYLON {
  122347. /** @hidden */
  122348. export var depthPixelShader: {
  122349. name: string;
  122350. shader: string;
  122351. };
  122352. }
  122353. declare module BABYLON {
  122354. /**
  122355. * This represents a depth renderer in Babylon.
  122356. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  122357. */
  122358. export class DepthRenderer {
  122359. private _scene;
  122360. private _depthMap;
  122361. private _effect;
  122362. private readonly _storeNonLinearDepth;
  122363. private readonly _clearColor;
  122364. /** Get if the depth renderer is using packed depth or not */
  122365. readonly isPacked: boolean;
  122366. private _cachedDefines;
  122367. private _camera;
  122368. /**
  122369. * Specifiess that the depth renderer will only be used within
  122370. * the camera it is created for.
  122371. * This can help forcing its rendering during the camera processing.
  122372. */
  122373. useOnlyInActiveCamera: boolean;
  122374. /** @hidden */
  122375. static _SceneComponentInitialization: (scene: Scene) => void;
  122376. /**
  122377. * Instantiates a depth renderer
  122378. * @param scene The scene the renderer belongs to
  122379. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  122380. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  122381. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122382. */
  122383. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  122384. /**
  122385. * Creates the depth rendering effect and checks if the effect is ready.
  122386. * @param subMesh The submesh to be used to render the depth map of
  122387. * @param useInstances If multiple world instances should be used
  122388. * @returns if the depth renderer is ready to render the depth map
  122389. */
  122390. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122391. /**
  122392. * Gets the texture which the depth map will be written to.
  122393. * @returns The depth map texture
  122394. */
  122395. getDepthMap(): RenderTargetTexture;
  122396. /**
  122397. * Disposes of the depth renderer.
  122398. */
  122399. dispose(): void;
  122400. }
  122401. }
  122402. declare module BABYLON {
  122403. interface Scene {
  122404. /** @hidden (Backing field) */
  122405. _depthRenderer: {
  122406. [id: string]: DepthRenderer;
  122407. };
  122408. /**
  122409. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  122410. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  122411. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  122412. * @returns the created depth renderer
  122413. */
  122414. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  122415. /**
  122416. * Disables a depth renderer for a given camera
  122417. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  122418. */
  122419. disableDepthRenderer(camera?: Nullable<Camera>): void;
  122420. }
  122421. /**
  122422. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  122423. * in several rendering techniques.
  122424. */
  122425. export class DepthRendererSceneComponent implements ISceneComponent {
  122426. /**
  122427. * The component name helpfull to identify the component in the list of scene components.
  122428. */
  122429. readonly name: string;
  122430. /**
  122431. * The scene the component belongs to.
  122432. */
  122433. scene: Scene;
  122434. /**
  122435. * Creates a new instance of the component for the given scene
  122436. * @param scene Defines the scene to register the component in
  122437. */
  122438. constructor(scene: Scene);
  122439. /**
  122440. * Registers the component in a given scene
  122441. */
  122442. register(): void;
  122443. /**
  122444. * Rebuilds the elements related to this component in case of
  122445. * context lost for instance.
  122446. */
  122447. rebuild(): void;
  122448. /**
  122449. * Disposes the component and the associated ressources
  122450. */
  122451. dispose(): void;
  122452. private _gatherRenderTargets;
  122453. private _gatherActiveCameraRenderTargets;
  122454. }
  122455. }
  122456. declare module BABYLON {
  122457. /** @hidden */
  122458. export var outlinePixelShader: {
  122459. name: string;
  122460. shader: string;
  122461. };
  122462. }
  122463. declare module BABYLON {
  122464. /** @hidden */
  122465. export var outlineVertexShader: {
  122466. name: string;
  122467. shader: string;
  122468. };
  122469. }
  122470. declare module BABYLON {
  122471. interface Scene {
  122472. /** @hidden */
  122473. _outlineRenderer: OutlineRenderer;
  122474. /**
  122475. * Gets the outline renderer associated with the scene
  122476. * @returns a OutlineRenderer
  122477. */
  122478. getOutlineRenderer(): OutlineRenderer;
  122479. }
  122480. interface AbstractMesh {
  122481. /** @hidden (Backing field) */
  122482. _renderOutline: boolean;
  122483. /**
  122484. * Gets or sets a boolean indicating if the outline must be rendered as well
  122485. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  122486. */
  122487. renderOutline: boolean;
  122488. /** @hidden (Backing field) */
  122489. _renderOverlay: boolean;
  122490. /**
  122491. * Gets or sets a boolean indicating if the overlay must be rendered as well
  122492. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  122493. */
  122494. renderOverlay: boolean;
  122495. }
  122496. /**
  122497. * This class is responsible to draw bothe outline/overlay of meshes.
  122498. * It should not be used directly but through the available method on mesh.
  122499. */
  122500. export class OutlineRenderer implements ISceneComponent {
  122501. /**
  122502. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  122503. */
  122504. private static _StencilReference;
  122505. /**
  122506. * The name of the component. Each component must have a unique name.
  122507. */
  122508. name: string;
  122509. /**
  122510. * The scene the component belongs to.
  122511. */
  122512. scene: Scene;
  122513. /**
  122514. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122515. */
  122516. zOffset: number;
  122517. private _engine;
  122518. private _effect;
  122519. private _cachedDefines;
  122520. private _savedDepthWrite;
  122521. /**
  122522. * Instantiates a new outline renderer. (There could be only one per scene).
  122523. * @param scene Defines the scene it belongs to
  122524. */
  122525. constructor(scene: Scene);
  122526. /**
  122527. * Register the component to one instance of a scene.
  122528. */
  122529. register(): void;
  122530. /**
  122531. * Rebuilds the elements related to this component in case of
  122532. * context lost for instance.
  122533. */
  122534. rebuild(): void;
  122535. /**
  122536. * Disposes the component and the associated ressources.
  122537. */
  122538. dispose(): void;
  122539. /**
  122540. * Renders the outline in the canvas.
  122541. * @param subMesh Defines the sumesh to render
  122542. * @param batch Defines the batch of meshes in case of instances
  122543. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122544. */
  122545. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  122546. /**
  122547. * Returns whether or not the outline renderer is ready for a given submesh.
  122548. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122549. * @param subMesh Defines the submesh to check readyness for
  122550. * @param useInstances Defines wheter wee are trying to render instances or not
  122551. * @returns true if ready otherwise false
  122552. */
  122553. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  122554. private _beforeRenderingMesh;
  122555. private _afterRenderingMesh;
  122556. }
  122557. }
  122558. declare module BABYLON {
  122559. /**
  122560. * Defines the list of states available for a task inside a AssetsManager
  122561. */
  122562. export enum AssetTaskState {
  122563. /**
  122564. * Initialization
  122565. */
  122566. INIT = 0,
  122567. /**
  122568. * Running
  122569. */
  122570. RUNNING = 1,
  122571. /**
  122572. * Done
  122573. */
  122574. DONE = 2,
  122575. /**
  122576. * Error
  122577. */
  122578. ERROR = 3
  122579. }
  122580. /**
  122581. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  122582. */
  122583. export abstract class AbstractAssetTask {
  122584. /**
  122585. * Task name
  122586. */ name: string;
  122587. /**
  122588. * Callback called when the task is successful
  122589. */
  122590. onSuccess: (task: any) => void;
  122591. /**
  122592. * Callback called when the task is not successful
  122593. */
  122594. onError: (task: any, message?: string, exception?: any) => void;
  122595. /**
  122596. * Creates a new AssetsManager
  122597. * @param name defines the name of the task
  122598. */
  122599. constructor(
  122600. /**
  122601. * Task name
  122602. */ name: string);
  122603. private _isCompleted;
  122604. private _taskState;
  122605. private _errorObject;
  122606. /**
  122607. * Get if the task is completed
  122608. */
  122609. readonly isCompleted: boolean;
  122610. /**
  122611. * Gets the current state of the task
  122612. */
  122613. readonly taskState: AssetTaskState;
  122614. /**
  122615. * Gets the current error object (if task is in error)
  122616. */
  122617. readonly errorObject: {
  122618. message?: string;
  122619. exception?: any;
  122620. };
  122621. /**
  122622. * Internal only
  122623. * @hidden
  122624. */
  122625. _setErrorObject(message?: string, exception?: any): void;
  122626. /**
  122627. * Execute the current task
  122628. * @param scene defines the scene where you want your assets to be loaded
  122629. * @param onSuccess is a callback called when the task is successfully executed
  122630. * @param onError is a callback called if an error occurs
  122631. */
  122632. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122633. /**
  122634. * Execute the current task
  122635. * @param scene defines the scene where you want your assets to be loaded
  122636. * @param onSuccess is a callback called when the task is successfully executed
  122637. * @param onError is a callback called if an error occurs
  122638. */
  122639. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122640. /**
  122641. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  122642. * This can be used with failed tasks that have the reason for failure fixed.
  122643. */
  122644. reset(): void;
  122645. private onErrorCallback;
  122646. private onDoneCallback;
  122647. }
  122648. /**
  122649. * Define the interface used by progress events raised during assets loading
  122650. */
  122651. export interface IAssetsProgressEvent {
  122652. /**
  122653. * Defines the number of remaining tasks to process
  122654. */
  122655. remainingCount: number;
  122656. /**
  122657. * Defines the total number of tasks
  122658. */
  122659. totalCount: number;
  122660. /**
  122661. * Defines the task that was just processed
  122662. */
  122663. task: AbstractAssetTask;
  122664. }
  122665. /**
  122666. * Class used to share progress information about assets loading
  122667. */
  122668. export class AssetsProgressEvent implements IAssetsProgressEvent {
  122669. /**
  122670. * Defines the number of remaining tasks to process
  122671. */
  122672. remainingCount: number;
  122673. /**
  122674. * Defines the total number of tasks
  122675. */
  122676. totalCount: number;
  122677. /**
  122678. * Defines the task that was just processed
  122679. */
  122680. task: AbstractAssetTask;
  122681. /**
  122682. * Creates a AssetsProgressEvent
  122683. * @param remainingCount defines the number of remaining tasks to process
  122684. * @param totalCount defines the total number of tasks
  122685. * @param task defines the task that was just processed
  122686. */
  122687. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  122688. }
  122689. /**
  122690. * Define a task used by AssetsManager to load meshes
  122691. */
  122692. export class MeshAssetTask extends AbstractAssetTask {
  122693. /**
  122694. * Defines the name of the task
  122695. */
  122696. name: string;
  122697. /**
  122698. * Defines the list of mesh's names you want to load
  122699. */
  122700. meshesNames: any;
  122701. /**
  122702. * Defines the root url to use as a base to load your meshes and associated resources
  122703. */
  122704. rootUrl: string;
  122705. /**
  122706. * Defines the filename of the scene to load from
  122707. */
  122708. sceneFilename: string;
  122709. /**
  122710. * Gets the list of loaded meshes
  122711. */
  122712. loadedMeshes: Array<AbstractMesh>;
  122713. /**
  122714. * Gets the list of loaded particle systems
  122715. */
  122716. loadedParticleSystems: Array<IParticleSystem>;
  122717. /**
  122718. * Gets the list of loaded skeletons
  122719. */
  122720. loadedSkeletons: Array<Skeleton>;
  122721. /**
  122722. * Gets the list of loaded animation groups
  122723. */
  122724. loadedAnimationGroups: Array<AnimationGroup>;
  122725. /**
  122726. * Callback called when the task is successful
  122727. */
  122728. onSuccess: (task: MeshAssetTask) => void;
  122729. /**
  122730. * Callback called when the task is successful
  122731. */
  122732. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  122733. /**
  122734. * Creates a new MeshAssetTask
  122735. * @param name defines the name of the task
  122736. * @param meshesNames defines the list of mesh's names you want to load
  122737. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  122738. * @param sceneFilename defines the filename of the scene to load from
  122739. */
  122740. constructor(
  122741. /**
  122742. * Defines the name of the task
  122743. */
  122744. name: string,
  122745. /**
  122746. * Defines the list of mesh's names you want to load
  122747. */
  122748. meshesNames: any,
  122749. /**
  122750. * Defines the root url to use as a base to load your meshes and associated resources
  122751. */
  122752. rootUrl: string,
  122753. /**
  122754. * Defines the filename of the scene to load from
  122755. */
  122756. sceneFilename: string);
  122757. /**
  122758. * Execute the current task
  122759. * @param scene defines the scene where you want your assets to be loaded
  122760. * @param onSuccess is a callback called when the task is successfully executed
  122761. * @param onError is a callback called if an error occurs
  122762. */
  122763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122764. }
  122765. /**
  122766. * Define a task used by AssetsManager to load text content
  122767. */
  122768. export class TextFileAssetTask extends AbstractAssetTask {
  122769. /**
  122770. * Defines the name of the task
  122771. */
  122772. name: string;
  122773. /**
  122774. * Defines the location of the file to load
  122775. */
  122776. url: string;
  122777. /**
  122778. * Gets the loaded text string
  122779. */
  122780. text: string;
  122781. /**
  122782. * Callback called when the task is successful
  122783. */
  122784. onSuccess: (task: TextFileAssetTask) => void;
  122785. /**
  122786. * Callback called when the task is successful
  122787. */
  122788. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  122789. /**
  122790. * Creates a new TextFileAssetTask object
  122791. * @param name defines the name of the task
  122792. * @param url defines the location of the file to load
  122793. */
  122794. constructor(
  122795. /**
  122796. * Defines the name of the task
  122797. */
  122798. name: string,
  122799. /**
  122800. * Defines the location of the file to load
  122801. */
  122802. url: string);
  122803. /**
  122804. * Execute the current task
  122805. * @param scene defines the scene where you want your assets to be loaded
  122806. * @param onSuccess is a callback called when the task is successfully executed
  122807. * @param onError is a callback called if an error occurs
  122808. */
  122809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122810. }
  122811. /**
  122812. * Define a task used by AssetsManager to load binary data
  122813. */
  122814. export class BinaryFileAssetTask extends AbstractAssetTask {
  122815. /**
  122816. * Defines the name of the task
  122817. */
  122818. name: string;
  122819. /**
  122820. * Defines the location of the file to load
  122821. */
  122822. url: string;
  122823. /**
  122824. * Gets the lodaded data (as an array buffer)
  122825. */
  122826. data: ArrayBuffer;
  122827. /**
  122828. * Callback called when the task is successful
  122829. */
  122830. onSuccess: (task: BinaryFileAssetTask) => void;
  122831. /**
  122832. * Callback called when the task is successful
  122833. */
  122834. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  122835. /**
  122836. * Creates a new BinaryFileAssetTask object
  122837. * @param name defines the name of the new task
  122838. * @param url defines the location of the file to load
  122839. */
  122840. constructor(
  122841. /**
  122842. * Defines the name of the task
  122843. */
  122844. name: string,
  122845. /**
  122846. * Defines the location of the file to load
  122847. */
  122848. url: string);
  122849. /**
  122850. * Execute the current task
  122851. * @param scene defines the scene where you want your assets to be loaded
  122852. * @param onSuccess is a callback called when the task is successfully executed
  122853. * @param onError is a callback called if an error occurs
  122854. */
  122855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122856. }
  122857. /**
  122858. * Define a task used by AssetsManager to load images
  122859. */
  122860. export class ImageAssetTask extends AbstractAssetTask {
  122861. /**
  122862. * Defines the name of the task
  122863. */
  122864. name: string;
  122865. /**
  122866. * Defines the location of the image to load
  122867. */
  122868. url: string;
  122869. /**
  122870. * Gets the loaded images
  122871. */
  122872. image: HTMLImageElement;
  122873. /**
  122874. * Callback called when the task is successful
  122875. */
  122876. onSuccess: (task: ImageAssetTask) => void;
  122877. /**
  122878. * Callback called when the task is successful
  122879. */
  122880. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  122881. /**
  122882. * Creates a new ImageAssetTask
  122883. * @param name defines the name of the task
  122884. * @param url defines the location of the image to load
  122885. */
  122886. constructor(
  122887. /**
  122888. * Defines the name of the task
  122889. */
  122890. name: string,
  122891. /**
  122892. * Defines the location of the image to load
  122893. */
  122894. url: string);
  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. * Defines the interface used by texture loading tasks
  122905. */
  122906. export interface ITextureAssetTask<TEX extends BaseTexture> {
  122907. /**
  122908. * Gets the loaded texture
  122909. */
  122910. texture: TEX;
  122911. }
  122912. /**
  122913. * Define a task used by AssetsManager to load 2D textures
  122914. */
  122915. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  122916. /**
  122917. * Defines the name of the task
  122918. */
  122919. name: string;
  122920. /**
  122921. * Defines the location of the file to load
  122922. */
  122923. url: string;
  122924. /**
  122925. * Defines if mipmap should not be generated (default is false)
  122926. */
  122927. noMipmap?: boolean | undefined;
  122928. /**
  122929. * Defines if texture must be inverted on Y axis (default is false)
  122930. */
  122931. invertY?: boolean | undefined;
  122932. /**
  122933. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122934. */
  122935. samplingMode: number;
  122936. /**
  122937. * Gets the loaded texture
  122938. */
  122939. texture: Texture;
  122940. /**
  122941. * Callback called when the task is successful
  122942. */
  122943. onSuccess: (task: TextureAssetTask) => void;
  122944. /**
  122945. * Callback called when the task is successful
  122946. */
  122947. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  122948. /**
  122949. * Creates a new TextureAssetTask object
  122950. * @param name defines the name of the task
  122951. * @param url defines the location of the file to load
  122952. * @param noMipmap defines if mipmap should not be generated (default is false)
  122953. * @param invertY defines if texture must be inverted on Y axis (default is false)
  122954. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122955. */
  122956. constructor(
  122957. /**
  122958. * Defines the name of the task
  122959. */
  122960. name: string,
  122961. /**
  122962. * Defines the location of the file to load
  122963. */
  122964. url: string,
  122965. /**
  122966. * Defines if mipmap should not be generated (default is false)
  122967. */
  122968. noMipmap?: boolean | undefined,
  122969. /**
  122970. * Defines if texture must be inverted on Y axis (default is false)
  122971. */
  122972. invertY?: boolean | undefined,
  122973. /**
  122974. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  122975. */
  122976. samplingMode?: number);
  122977. /**
  122978. * Execute the current task
  122979. * @param scene defines the scene where you want your assets to be loaded
  122980. * @param onSuccess is a callback called when the task is successfully executed
  122981. * @param onError is a callback called if an error occurs
  122982. */
  122983. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  122984. }
  122985. /**
  122986. * Define a task used by AssetsManager to load cube textures
  122987. */
  122988. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  122989. /**
  122990. * Defines the name of the task
  122991. */
  122992. name: string;
  122993. /**
  122994. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  122995. */
  122996. url: string;
  122997. /**
  122998. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  122999. */
  123000. extensions?: string[] | undefined;
  123001. /**
  123002. * Defines if mipmaps should not be generated (default is false)
  123003. */
  123004. noMipmap?: boolean | undefined;
  123005. /**
  123006. * Defines the explicit list of files (undefined by default)
  123007. */
  123008. files?: string[] | undefined;
  123009. /**
  123010. * Gets the loaded texture
  123011. */
  123012. texture: CubeTexture;
  123013. /**
  123014. * Callback called when the task is successful
  123015. */
  123016. onSuccess: (task: CubeTextureAssetTask) => void;
  123017. /**
  123018. * Callback called when the task is successful
  123019. */
  123020. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  123021. /**
  123022. * Creates a new CubeTextureAssetTask
  123023. * @param name defines the name of the task
  123024. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123025. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123026. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123027. * @param files defines the explicit list of files (undefined by default)
  123028. */
  123029. constructor(
  123030. /**
  123031. * Defines the name of the task
  123032. */
  123033. name: string,
  123034. /**
  123035. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  123036. */
  123037. url: string,
  123038. /**
  123039. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  123040. */
  123041. extensions?: string[] | undefined,
  123042. /**
  123043. * Defines if mipmaps should not be generated (default is false)
  123044. */
  123045. noMipmap?: boolean | undefined,
  123046. /**
  123047. * Defines the explicit list of files (undefined by default)
  123048. */
  123049. files?: string[] | undefined);
  123050. /**
  123051. * Execute the current task
  123052. * @param scene defines the scene where you want your assets to be loaded
  123053. * @param onSuccess is a callback called when the task is successfully executed
  123054. * @param onError is a callback called if an error occurs
  123055. */
  123056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123057. }
  123058. /**
  123059. * Define a task used by AssetsManager to load HDR cube textures
  123060. */
  123061. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  123062. /**
  123063. * Defines the name of the task
  123064. */
  123065. name: string;
  123066. /**
  123067. * Defines the location of the file to load
  123068. */
  123069. url: string;
  123070. /**
  123071. * Defines the desired size (the more it increases the longer the generation will be)
  123072. */
  123073. size: number;
  123074. /**
  123075. * Defines if mipmaps should not be generated (default is false)
  123076. */
  123077. noMipmap: boolean;
  123078. /**
  123079. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123080. */
  123081. generateHarmonics: boolean;
  123082. /**
  123083. * 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)
  123084. */
  123085. gammaSpace: boolean;
  123086. /**
  123087. * Internal Use Only
  123088. */
  123089. reserved: boolean;
  123090. /**
  123091. * Gets the loaded texture
  123092. */
  123093. texture: HDRCubeTexture;
  123094. /**
  123095. * Callback called when the task is successful
  123096. */
  123097. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  123098. /**
  123099. * Callback called when the task is successful
  123100. */
  123101. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  123102. /**
  123103. * Creates a new HDRCubeTextureAssetTask object
  123104. * @param name defines the name of the task
  123105. * @param url defines the location of the file to load
  123106. * @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.
  123107. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123108. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123109. * @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)
  123110. * @param reserved Internal use only
  123111. */
  123112. constructor(
  123113. /**
  123114. * Defines the name of the task
  123115. */
  123116. name: string,
  123117. /**
  123118. * Defines the location of the file to load
  123119. */
  123120. url: string,
  123121. /**
  123122. * Defines the desired size (the more it increases the longer the generation will be)
  123123. */
  123124. size: number,
  123125. /**
  123126. * Defines if mipmaps should not be generated (default is false)
  123127. */
  123128. noMipmap?: boolean,
  123129. /**
  123130. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  123131. */
  123132. generateHarmonics?: boolean,
  123133. /**
  123134. * 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)
  123135. */
  123136. gammaSpace?: boolean,
  123137. /**
  123138. * Internal Use Only
  123139. */
  123140. reserved?: boolean);
  123141. /**
  123142. * Execute the current task
  123143. * @param scene defines the scene where you want your assets to be loaded
  123144. * @param onSuccess is a callback called when the task is successfully executed
  123145. * @param onError is a callback called if an error occurs
  123146. */
  123147. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123148. }
  123149. /**
  123150. * Define a task used by AssetsManager to load Equirectangular cube textures
  123151. */
  123152. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  123153. /**
  123154. * Defines the name of the task
  123155. */
  123156. name: string;
  123157. /**
  123158. * Defines the location of the file to load
  123159. */
  123160. url: string;
  123161. /**
  123162. * Defines the desired size (the more it increases the longer the generation will be)
  123163. */
  123164. size: number;
  123165. /**
  123166. * Defines if mipmaps should not be generated (default is false)
  123167. */
  123168. noMipmap: boolean;
  123169. /**
  123170. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123171. * but the standard material would require them in Gamma space) (default is true)
  123172. */
  123173. gammaSpace: boolean;
  123174. /**
  123175. * Gets the loaded texture
  123176. */
  123177. texture: EquiRectangularCubeTexture;
  123178. /**
  123179. * Callback called when the task is successful
  123180. */
  123181. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  123182. /**
  123183. * Callback called when the task is successful
  123184. */
  123185. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  123186. /**
  123187. * Creates a new EquiRectangularCubeTextureAssetTask object
  123188. * @param name defines the name of the task
  123189. * @param url defines the location of the file to load
  123190. * @param size defines the desired size (the more it increases the longer the generation will be)
  123191. * If the size is omitted this implies you are using a preprocessed cubemap.
  123192. * @param noMipmap defines if mipmaps should not be generated (default is false)
  123193. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  123194. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  123195. * (default is true)
  123196. */
  123197. constructor(
  123198. /**
  123199. * Defines the name of the task
  123200. */
  123201. name: string,
  123202. /**
  123203. * Defines the location of the file to load
  123204. */
  123205. url: string,
  123206. /**
  123207. * Defines the desired size (the more it increases the longer the generation will be)
  123208. */
  123209. size: number,
  123210. /**
  123211. * Defines if mipmaps should not be generated (default is false)
  123212. */
  123213. noMipmap?: boolean,
  123214. /**
  123215. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  123216. * but the standard material would require them in Gamma space) (default is true)
  123217. */
  123218. gammaSpace?: boolean);
  123219. /**
  123220. * Execute the current task
  123221. * @param scene defines the scene where you want your assets to be loaded
  123222. * @param onSuccess is a callback called when the task is successfully executed
  123223. * @param onError is a callback called if an error occurs
  123224. */
  123225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  123226. }
  123227. /**
  123228. * This class can be used to easily import assets into a scene
  123229. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  123230. */
  123231. export class AssetsManager {
  123232. private _scene;
  123233. private _isLoading;
  123234. protected _tasks: AbstractAssetTask[];
  123235. protected _waitingTasksCount: number;
  123236. protected _totalTasksCount: number;
  123237. /**
  123238. * Callback called when all tasks are processed
  123239. */
  123240. onFinish: (tasks: AbstractAssetTask[]) => void;
  123241. /**
  123242. * Callback called when a task is successful
  123243. */
  123244. onTaskSuccess: (task: AbstractAssetTask) => void;
  123245. /**
  123246. * Callback called when a task had an error
  123247. */
  123248. onTaskError: (task: AbstractAssetTask) => void;
  123249. /**
  123250. * Callback called when a task is done (whatever the result is)
  123251. */
  123252. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  123253. /**
  123254. * Observable called when all tasks are processed
  123255. */
  123256. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  123257. /**
  123258. * Observable called when a task had an error
  123259. */
  123260. onTaskErrorObservable: Observable<AbstractAssetTask>;
  123261. /**
  123262. * Observable called when all tasks were executed
  123263. */
  123264. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  123265. /**
  123266. * Observable called when a task is done (whatever the result is)
  123267. */
  123268. onProgressObservable: Observable<IAssetsProgressEvent>;
  123269. /**
  123270. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  123271. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  123272. */
  123273. useDefaultLoadingScreen: boolean;
  123274. /**
  123275. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  123276. * when all assets have been downloaded.
  123277. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  123278. */
  123279. autoHideLoadingUI: boolean;
  123280. /**
  123281. * Creates a new AssetsManager
  123282. * @param scene defines the scene to work on
  123283. */
  123284. constructor(scene: Scene);
  123285. /**
  123286. * Add a MeshAssetTask to the list of active tasks
  123287. * @param taskName defines the name of the new task
  123288. * @param meshesNames defines the name of meshes to load
  123289. * @param rootUrl defines the root url to use to locate files
  123290. * @param sceneFilename defines the filename of the scene file
  123291. * @returns a new MeshAssetTask object
  123292. */
  123293. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  123294. /**
  123295. * Add a TextFileAssetTask to the list of active tasks
  123296. * @param taskName defines the name of the new task
  123297. * @param url defines the url of the file to load
  123298. * @returns a new TextFileAssetTask object
  123299. */
  123300. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  123301. /**
  123302. * Add a BinaryFileAssetTask to the list of active tasks
  123303. * @param taskName defines the name of the new task
  123304. * @param url defines the url of the file to load
  123305. * @returns a new BinaryFileAssetTask object
  123306. */
  123307. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  123308. /**
  123309. * Add a ImageAssetTask to the list of active tasks
  123310. * @param taskName defines the name of the new task
  123311. * @param url defines the url of the file to load
  123312. * @returns a new ImageAssetTask object
  123313. */
  123314. addImageTask(taskName: string, url: string): ImageAssetTask;
  123315. /**
  123316. * Add a TextureAssetTask to the list of active tasks
  123317. * @param taskName defines the name of the new task
  123318. * @param url defines the url of the file to load
  123319. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123320. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  123321. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  123322. * @returns a new TextureAssetTask object
  123323. */
  123324. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  123325. /**
  123326. * Add a CubeTextureAssetTask to the list of active tasks
  123327. * @param taskName defines the name of the new task
  123328. * @param url defines the url of the file to load
  123329. * @param extensions defines the extension to use to load the cube map (can be null)
  123330. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123331. * @param files defines the list of files to load (can be null)
  123332. * @returns a new CubeTextureAssetTask object
  123333. */
  123334. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  123335. /**
  123336. *
  123337. * Add a HDRCubeTextureAssetTask to the list of active tasks
  123338. * @param taskName defines the name of the new task
  123339. * @param url defines the url of the file to load
  123340. * @param size defines the size you want for the cubemap (can be null)
  123341. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123342. * @param generateHarmonics defines if you want to automatically generate (true by default)
  123343. * @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)
  123344. * @param reserved Internal use only
  123345. * @returns a new HDRCubeTextureAssetTask object
  123346. */
  123347. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  123348. /**
  123349. *
  123350. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  123351. * @param taskName defines the name of the new task
  123352. * @param url defines the url of the file to load
  123353. * @param size defines the size you want for the cubemap (can be null)
  123354. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  123355. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  123356. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  123357. * @returns a new EquiRectangularCubeTextureAssetTask object
  123358. */
  123359. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  123360. /**
  123361. * Remove a task from the assets manager.
  123362. * @param task the task to remove
  123363. */
  123364. removeTask(task: AbstractAssetTask): void;
  123365. private _decreaseWaitingTasksCount;
  123366. private _runTask;
  123367. /**
  123368. * Reset the AssetsManager and remove all tasks
  123369. * @return the current instance of the AssetsManager
  123370. */
  123371. reset(): AssetsManager;
  123372. /**
  123373. * Start the loading process
  123374. * @return the current instance of the AssetsManager
  123375. */
  123376. load(): AssetsManager;
  123377. /**
  123378. * Start the loading process as an async operation
  123379. * @return a promise returning the list of failed tasks
  123380. */
  123381. loadAsync(): Promise<void>;
  123382. }
  123383. }
  123384. declare module BABYLON {
  123385. /**
  123386. * Wrapper class for promise with external resolve and reject.
  123387. */
  123388. export class Deferred<T> {
  123389. /**
  123390. * The promise associated with this deferred object.
  123391. */
  123392. readonly promise: Promise<T>;
  123393. private _resolve;
  123394. private _reject;
  123395. /**
  123396. * The resolve method of the promise associated with this deferred object.
  123397. */
  123398. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  123399. /**
  123400. * The reject method of the promise associated with this deferred object.
  123401. */
  123402. readonly reject: (reason?: any) => void;
  123403. /**
  123404. * Constructor for this deferred object.
  123405. */
  123406. constructor();
  123407. }
  123408. }
  123409. declare module BABYLON {
  123410. /**
  123411. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  123412. */
  123413. export class MeshExploder {
  123414. private _centerMesh;
  123415. private _meshes;
  123416. private _meshesOrigins;
  123417. private _toCenterVectors;
  123418. private _scaledDirection;
  123419. private _newPosition;
  123420. private _centerPosition;
  123421. /**
  123422. * Explodes meshes from a center mesh.
  123423. * @param meshes The meshes to explode.
  123424. * @param centerMesh The mesh to be center of explosion.
  123425. */
  123426. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  123427. private _setCenterMesh;
  123428. /**
  123429. * Get class name
  123430. * @returns "MeshExploder"
  123431. */
  123432. getClassName(): string;
  123433. /**
  123434. * "Exploded meshes"
  123435. * @returns Array of meshes with the centerMesh at index 0.
  123436. */
  123437. getMeshes(): Array<Mesh>;
  123438. /**
  123439. * Explodes meshes giving a specific direction
  123440. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  123441. */
  123442. explode(direction?: number): void;
  123443. }
  123444. }
  123445. declare module BABYLON {
  123446. /**
  123447. * Class used to help managing file picking and drag'n'drop
  123448. */
  123449. export class FilesInput {
  123450. /**
  123451. * List of files ready to be loaded
  123452. */
  123453. static readonly FilesToLoad: {
  123454. [key: string]: File;
  123455. };
  123456. /**
  123457. * Callback called when a file is processed
  123458. */
  123459. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  123460. private _engine;
  123461. private _currentScene;
  123462. private _sceneLoadedCallback;
  123463. private _progressCallback;
  123464. private _additionalRenderLoopLogicCallback;
  123465. private _textureLoadingCallback;
  123466. private _startingProcessingFilesCallback;
  123467. private _onReloadCallback;
  123468. private _errorCallback;
  123469. private _elementToMonitor;
  123470. private _sceneFileToLoad;
  123471. private _filesToLoad;
  123472. /**
  123473. * Creates a new FilesInput
  123474. * @param engine defines the rendering engine
  123475. * @param scene defines the hosting scene
  123476. * @param sceneLoadedCallback callback called when scene is loaded
  123477. * @param progressCallback callback called to track progress
  123478. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  123479. * @param textureLoadingCallback callback called when a texture is loading
  123480. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  123481. * @param onReloadCallback callback called when a reload is requested
  123482. * @param errorCallback callback call if an error occurs
  123483. */
  123484. 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);
  123485. private _dragEnterHandler;
  123486. private _dragOverHandler;
  123487. private _dropHandler;
  123488. /**
  123489. * Calls this function to listen to drag'n'drop events on a specific DOM element
  123490. * @param elementToMonitor defines the DOM element to track
  123491. */
  123492. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  123493. /**
  123494. * Release all associated resources
  123495. */
  123496. dispose(): void;
  123497. private renderFunction;
  123498. private drag;
  123499. private drop;
  123500. private _traverseFolder;
  123501. private _processFiles;
  123502. /**
  123503. * Load files from a drop event
  123504. * @param event defines the drop event to use as source
  123505. */
  123506. loadFiles(event: any): void;
  123507. private _processReload;
  123508. /**
  123509. * Reload the current scene from the loaded files
  123510. */
  123511. reload(): void;
  123512. }
  123513. }
  123514. declare module BABYLON {
  123515. /**
  123516. * Defines the root class used to create scene optimization to use with SceneOptimizer
  123517. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123518. */
  123519. export class SceneOptimization {
  123520. /**
  123521. * Defines the priority of this optimization (0 by default which means first in the list)
  123522. */
  123523. priority: number;
  123524. /**
  123525. * Gets a string describing the action executed by the current optimization
  123526. * @returns description string
  123527. */
  123528. getDescription(): string;
  123529. /**
  123530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123531. * @param scene defines the current scene where to apply this optimization
  123532. * @param optimizer defines the current optimizer
  123533. * @returns true if everything that can be done was applied
  123534. */
  123535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123536. /**
  123537. * Creates the SceneOptimization object
  123538. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123539. * @param desc defines the description associated with the optimization
  123540. */
  123541. constructor(
  123542. /**
  123543. * Defines the priority of this optimization (0 by default which means first in the list)
  123544. */
  123545. priority?: number);
  123546. }
  123547. /**
  123548. * Defines an optimization used to reduce the size of render target textures
  123549. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123550. */
  123551. export class TextureOptimization extends SceneOptimization {
  123552. /**
  123553. * Defines the priority of this optimization (0 by default which means first in the list)
  123554. */
  123555. priority: number;
  123556. /**
  123557. * 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
  123558. */
  123559. maximumSize: number;
  123560. /**
  123561. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123562. */
  123563. step: number;
  123564. /**
  123565. * Gets a string describing the action executed by the current optimization
  123566. * @returns description string
  123567. */
  123568. getDescription(): string;
  123569. /**
  123570. * Creates the TextureOptimization object
  123571. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123572. * @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
  123573. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123574. */
  123575. constructor(
  123576. /**
  123577. * Defines the priority of this optimization (0 by default which means first in the list)
  123578. */
  123579. priority?: number,
  123580. /**
  123581. * 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
  123582. */
  123583. maximumSize?: number,
  123584. /**
  123585. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  123586. */
  123587. step?: number);
  123588. /**
  123589. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123590. * @param scene defines the current scene where to apply this optimization
  123591. * @param optimizer defines the current optimizer
  123592. * @returns true if everything that can be done was applied
  123593. */
  123594. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123595. }
  123596. /**
  123597. * Defines an optimization used to increase or decrease the rendering resolution
  123598. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123599. */
  123600. export class HardwareScalingOptimization extends SceneOptimization {
  123601. /**
  123602. * Defines the priority of this optimization (0 by default which means first in the list)
  123603. */
  123604. priority: number;
  123605. /**
  123606. * Defines the maximum scale to use (2 by default)
  123607. */
  123608. maximumScale: number;
  123609. /**
  123610. * Defines the step to use between two passes (0.5 by default)
  123611. */
  123612. step: number;
  123613. private _currentScale;
  123614. private _directionOffset;
  123615. /**
  123616. * Gets a string describing the action executed by the current optimization
  123617. * @return description string
  123618. */
  123619. getDescription(): string;
  123620. /**
  123621. * Creates the HardwareScalingOptimization object
  123622. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123623. * @param maximumScale defines the maximum scale to use (2 by default)
  123624. * @param step defines the step to use between two passes (0.5 by default)
  123625. */
  123626. constructor(
  123627. /**
  123628. * Defines the priority of this optimization (0 by default which means first in the list)
  123629. */
  123630. priority?: number,
  123631. /**
  123632. * Defines the maximum scale to use (2 by default)
  123633. */
  123634. maximumScale?: number,
  123635. /**
  123636. * Defines the step to use between two passes (0.5 by default)
  123637. */
  123638. step?: number);
  123639. /**
  123640. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123641. * @param scene defines the current scene where to apply this optimization
  123642. * @param optimizer defines the current optimizer
  123643. * @returns true if everything that can be done was applied
  123644. */
  123645. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123646. }
  123647. /**
  123648. * Defines an optimization used to remove shadows
  123649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123650. */
  123651. export class ShadowsOptimization extends SceneOptimization {
  123652. /**
  123653. * Gets a string describing the action executed by the current optimization
  123654. * @return description string
  123655. */
  123656. getDescription(): string;
  123657. /**
  123658. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123659. * @param scene defines the current scene where to apply this optimization
  123660. * @param optimizer defines the current optimizer
  123661. * @returns true if everything that can be done was applied
  123662. */
  123663. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123664. }
  123665. /**
  123666. * Defines an optimization used to turn post-processes off
  123667. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123668. */
  123669. export class PostProcessesOptimization extends SceneOptimization {
  123670. /**
  123671. * Gets a string describing the action executed by the current optimization
  123672. * @return description string
  123673. */
  123674. getDescription(): string;
  123675. /**
  123676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123677. * @param scene defines the current scene where to apply this optimization
  123678. * @param optimizer defines the current optimizer
  123679. * @returns true if everything that can be done was applied
  123680. */
  123681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123682. }
  123683. /**
  123684. * Defines an optimization used to turn lens flares off
  123685. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123686. */
  123687. export class LensFlaresOptimization extends SceneOptimization {
  123688. /**
  123689. * Gets a string describing the action executed by the current optimization
  123690. * @return description string
  123691. */
  123692. getDescription(): string;
  123693. /**
  123694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123695. * @param scene defines the current scene where to apply this optimization
  123696. * @param optimizer defines the current optimizer
  123697. * @returns true if everything that can be done was applied
  123698. */
  123699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123700. }
  123701. /**
  123702. * Defines an optimization based on user defined callback.
  123703. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123704. */
  123705. export class CustomOptimization extends SceneOptimization {
  123706. /**
  123707. * Callback called to apply the custom optimization.
  123708. */
  123709. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  123710. /**
  123711. * Callback called to get custom description
  123712. */
  123713. onGetDescription: () => string;
  123714. /**
  123715. * Gets a string describing the action executed by the current optimization
  123716. * @returns description string
  123717. */
  123718. getDescription(): string;
  123719. /**
  123720. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123721. * @param scene defines the current scene where to apply this optimization
  123722. * @param optimizer defines the current optimizer
  123723. * @returns true if everything that can be done was applied
  123724. */
  123725. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123726. }
  123727. /**
  123728. * Defines an optimization used to turn particles off
  123729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123730. */
  123731. export class ParticlesOptimization extends SceneOptimization {
  123732. /**
  123733. * Gets a string describing the action executed by the current optimization
  123734. * @return description string
  123735. */
  123736. getDescription(): string;
  123737. /**
  123738. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123739. * @param scene defines the current scene where to apply this optimization
  123740. * @param optimizer defines the current optimizer
  123741. * @returns true if everything that can be done was applied
  123742. */
  123743. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123744. }
  123745. /**
  123746. * Defines an optimization used to turn render targets off
  123747. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123748. */
  123749. export class RenderTargetsOptimization extends SceneOptimization {
  123750. /**
  123751. * Gets a string describing the action executed by the current optimization
  123752. * @return description string
  123753. */
  123754. getDescription(): string;
  123755. /**
  123756. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123757. * @param scene defines the current scene where to apply this optimization
  123758. * @param optimizer defines the current optimizer
  123759. * @returns true if everything that can be done was applied
  123760. */
  123761. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  123762. }
  123763. /**
  123764. * Defines an optimization used to merge meshes with compatible materials
  123765. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123766. */
  123767. export class MergeMeshesOptimization extends SceneOptimization {
  123768. private static _UpdateSelectionTree;
  123769. /**
  123770. * Gets or sets a boolean which defines if optimization octree has to be updated
  123771. */
  123772. /**
  123773. * Gets or sets a boolean which defines if optimization octree has to be updated
  123774. */
  123775. static UpdateSelectionTree: boolean;
  123776. /**
  123777. * Gets a string describing the action executed by the current optimization
  123778. * @return description string
  123779. */
  123780. getDescription(): string;
  123781. private _canBeMerged;
  123782. /**
  123783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  123784. * @param scene defines the current scene where to apply this optimization
  123785. * @param optimizer defines the current optimizer
  123786. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  123787. * @returns true if everything that can be done was applied
  123788. */
  123789. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  123790. }
  123791. /**
  123792. * Defines a list of options used by SceneOptimizer
  123793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123794. */
  123795. export class SceneOptimizerOptions {
  123796. /**
  123797. * Defines the target frame rate to reach (60 by default)
  123798. */
  123799. targetFrameRate: number;
  123800. /**
  123801. * Defines the interval between two checkes (2000ms by default)
  123802. */
  123803. trackerDuration: number;
  123804. /**
  123805. * Gets the list of optimizations to apply
  123806. */
  123807. optimizations: SceneOptimization[];
  123808. /**
  123809. * Creates a new list of options used by SceneOptimizer
  123810. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  123811. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  123812. */
  123813. constructor(
  123814. /**
  123815. * Defines the target frame rate to reach (60 by default)
  123816. */
  123817. targetFrameRate?: number,
  123818. /**
  123819. * Defines the interval between two checkes (2000ms by default)
  123820. */
  123821. trackerDuration?: number);
  123822. /**
  123823. * Add a new optimization
  123824. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  123825. * @returns the current SceneOptimizerOptions
  123826. */
  123827. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  123828. /**
  123829. * Add a new custom optimization
  123830. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  123831. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  123832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  123833. * @returns the current SceneOptimizerOptions
  123834. */
  123835. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  123836. /**
  123837. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  123838. * @param targetFrameRate defines the target frame rate (60 by default)
  123839. * @returns a SceneOptimizerOptions object
  123840. */
  123841. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123842. /**
  123843. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  123844. * @param targetFrameRate defines the target frame rate (60 by default)
  123845. * @returns a SceneOptimizerOptions object
  123846. */
  123847. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123848. /**
  123849. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  123850. * @param targetFrameRate defines the target frame rate (60 by default)
  123851. * @returns a SceneOptimizerOptions object
  123852. */
  123853. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  123854. }
  123855. /**
  123856. * Class used to run optimizations in order to reach a target frame rate
  123857. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  123858. */
  123859. export class SceneOptimizer implements IDisposable {
  123860. private _isRunning;
  123861. private _options;
  123862. private _scene;
  123863. private _currentPriorityLevel;
  123864. private _targetFrameRate;
  123865. private _trackerDuration;
  123866. private _currentFrameRate;
  123867. private _sceneDisposeObserver;
  123868. private _improvementMode;
  123869. /**
  123870. * Defines an observable called when the optimizer reaches the target frame rate
  123871. */
  123872. onSuccessObservable: Observable<SceneOptimizer>;
  123873. /**
  123874. * Defines an observable called when the optimizer enables an optimization
  123875. */
  123876. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  123877. /**
  123878. * Defines an observable called when the optimizer is not able to reach the target frame rate
  123879. */
  123880. onFailureObservable: Observable<SceneOptimizer>;
  123881. /**
  123882. * Gets a boolean indicating if the optimizer is in improvement mode
  123883. */
  123884. readonly isInImprovementMode: boolean;
  123885. /**
  123886. * Gets the current priority level (0 at start)
  123887. */
  123888. readonly currentPriorityLevel: number;
  123889. /**
  123890. * Gets the current frame rate checked by the SceneOptimizer
  123891. */
  123892. readonly currentFrameRate: number;
  123893. /**
  123894. * Gets or sets the current target frame rate (60 by default)
  123895. */
  123896. /**
  123897. * Gets or sets the current target frame rate (60 by default)
  123898. */
  123899. targetFrameRate: number;
  123900. /**
  123901. * Gets or sets the current interval between two checks (every 2000ms by default)
  123902. */
  123903. /**
  123904. * Gets or sets the current interval between two checks (every 2000ms by default)
  123905. */
  123906. trackerDuration: number;
  123907. /**
  123908. * Gets the list of active optimizations
  123909. */
  123910. readonly optimizations: SceneOptimization[];
  123911. /**
  123912. * Creates a new SceneOptimizer
  123913. * @param scene defines the scene to work on
  123914. * @param options defines the options to use with the SceneOptimizer
  123915. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  123916. * @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)
  123917. */
  123918. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  123919. /**
  123920. * Stops the current optimizer
  123921. */
  123922. stop(): void;
  123923. /**
  123924. * Reset the optimizer to initial step (current priority level = 0)
  123925. */
  123926. reset(): void;
  123927. /**
  123928. * Start the optimizer. By default it will try to reach a specific framerate
  123929. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  123930. */
  123931. start(): void;
  123932. private _checkCurrentState;
  123933. /**
  123934. * Release all resources
  123935. */
  123936. dispose(): void;
  123937. /**
  123938. * Helper function to create a SceneOptimizer with one single line of code
  123939. * @param scene defines the scene to work on
  123940. * @param options defines the options to use with the SceneOptimizer
  123941. * @param onSuccess defines a callback to call on success
  123942. * @param onFailure defines a callback to call on failure
  123943. * @returns the new SceneOptimizer object
  123944. */
  123945. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  123946. }
  123947. }
  123948. declare module BABYLON {
  123949. /**
  123950. * Class used to serialize a scene into a string
  123951. */
  123952. export class SceneSerializer {
  123953. /**
  123954. * Clear cache used by a previous serialization
  123955. */
  123956. static ClearCache(): void;
  123957. /**
  123958. * Serialize a scene into a JSON compatible object
  123959. * @param scene defines the scene to serialize
  123960. * @returns a JSON compatible object
  123961. */
  123962. static Serialize(scene: Scene): any;
  123963. /**
  123964. * Serialize a mesh into a JSON compatible object
  123965. * @param toSerialize defines the mesh to serialize
  123966. * @param withParents defines if parents must be serialized as well
  123967. * @param withChildren defines if children must be serialized as well
  123968. * @returns a JSON compatible object
  123969. */
  123970. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  123971. }
  123972. }
  123973. declare module BABYLON {
  123974. /**
  123975. * Class used to host texture specific utilities
  123976. */
  123977. export class TextureTools {
  123978. /**
  123979. * Uses the GPU to create a copy texture rescaled at a given size
  123980. * @param texture Texture to copy from
  123981. * @param width defines the desired width
  123982. * @param height defines the desired height
  123983. * @param useBilinearMode defines if bilinear mode has to be used
  123984. * @return the generated texture
  123985. */
  123986. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  123987. }
  123988. }
  123989. declare module BABYLON {
  123990. /**
  123991. * This represents the different options available for the video capture.
  123992. */
  123993. export interface VideoRecorderOptions {
  123994. /** Defines the mime type of the video. */
  123995. mimeType: string;
  123996. /** Defines the FPS the video should be recorded at. */
  123997. fps: number;
  123998. /** Defines the chunk size for the recording data. */
  123999. recordChunckSize: number;
  124000. /** The audio tracks to attach to the recording. */
  124001. audioTracks?: MediaStreamTrack[];
  124002. }
  124003. /**
  124004. * This can help with recording videos from BabylonJS.
  124005. * This is based on the available WebRTC functionalities of the browser.
  124006. *
  124007. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  124008. */
  124009. export class VideoRecorder {
  124010. private static readonly _defaultOptions;
  124011. /**
  124012. * Returns whether or not the VideoRecorder is available in your browser.
  124013. * @param engine Defines the Babylon Engine.
  124014. * @returns true if supported otherwise false.
  124015. */
  124016. static IsSupported(engine: Engine): boolean;
  124017. private readonly _options;
  124018. private _canvas;
  124019. private _mediaRecorder;
  124020. private _recordedChunks;
  124021. private _fileName;
  124022. private _resolve;
  124023. private _reject;
  124024. /**
  124025. * True when a recording is already in progress.
  124026. */
  124027. readonly isRecording: boolean;
  124028. /**
  124029. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  124030. * @param engine Defines the BabylonJS Engine you wish to record.
  124031. * @param options Defines options that can be used to customize the capture.
  124032. */
  124033. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  124034. /**
  124035. * Stops the current recording before the default capture timeout passed in the startRecording function.
  124036. */
  124037. stopRecording(): void;
  124038. /**
  124039. * Starts recording the canvas for a max duration specified in parameters.
  124040. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  124041. * If null no automatic download will start and you can rely on the promise to get the data back.
  124042. * @param maxDuration Defines the maximum recording time in seconds.
  124043. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  124044. * @return A promise callback at the end of the recording with the video data in Blob.
  124045. */
  124046. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  124047. /**
  124048. * Releases internal resources used during the recording.
  124049. */
  124050. dispose(): void;
  124051. private _handleDataAvailable;
  124052. private _handleError;
  124053. private _handleStop;
  124054. }
  124055. }
  124056. declare module BABYLON {
  124057. /**
  124058. * Class containing a set of static utilities functions for screenshots
  124059. */
  124060. export class ScreenshotTools {
  124061. /**
  124062. * Captures a screenshot of the current rendering
  124063. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124064. * @param engine defines the rendering engine
  124065. * @param camera defines the source camera
  124066. * @param size This parameter can be set to a single number or to an object with the
  124067. * following (optional) properties: precision, width, height. If a single number is passed,
  124068. * it will be used for both width and height. If an object is passed, the screenshot size
  124069. * will be derived from the parameters. The precision property is a multiplier allowing
  124070. * rendering at a higher or lower resolution
  124071. * @param successCallback defines the callback receives a single parameter which contains the
  124072. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124073. * src parameter of an <img> to display it
  124074. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124075. * Check your browser for supported MIME types
  124076. */
  124077. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  124078. /**
  124079. * Captures a screenshot of the current rendering
  124080. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124081. * @param engine defines the rendering engine
  124082. * @param camera defines the source camera
  124083. * @param size This parameter can be set to a single number or to an object with the
  124084. * following (optional) properties: precision, width, height. If a single number is passed,
  124085. * it will be used for both width and height. If an object is passed, the screenshot size
  124086. * will be derived from the parameters. The precision property is a multiplier allowing
  124087. * rendering at a higher or lower resolution
  124088. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  124089. * Check your browser for supported MIME types
  124090. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124091. * to the src parameter of an <img> to display it
  124092. */
  124093. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  124094. /**
  124095. * Generates an image screenshot from the specified camera.
  124096. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124097. * @param engine The engine to use for rendering
  124098. * @param camera The camera to use for rendering
  124099. * @param size This parameter can be set to a single number or to an object with the
  124100. * following (optional) properties: precision, width, height. If a single number is passed,
  124101. * it will be used for both width and height. If an object is passed, the screenshot size
  124102. * will be derived from the parameters. The precision property is a multiplier allowing
  124103. * rendering at a higher or lower resolution
  124104. * @param successCallback The callback receives a single parameter which contains the
  124105. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  124106. * src parameter of an <img> to display it
  124107. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124108. * Check your browser for supported MIME types
  124109. * @param samples Texture samples (default: 1)
  124110. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124111. * @param fileName A name for for the downloaded file.
  124112. */
  124113. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  124114. /**
  124115. * Generates an image screenshot from the specified camera.
  124116. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  124117. * @param engine The engine to use for rendering
  124118. * @param camera The camera to use for rendering
  124119. * @param size This parameter can be set to a single number or to an object with the
  124120. * following (optional) properties: precision, width, height. If a single number is passed,
  124121. * it will be used for both width and height. If an object is passed, the screenshot size
  124122. * will be derived from the parameters. The precision property is a multiplier allowing
  124123. * rendering at a higher or lower resolution
  124124. * @param mimeType The MIME type of the screenshot image (default: image/png).
  124125. * Check your browser for supported MIME types
  124126. * @param samples Texture samples (default: 1)
  124127. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  124128. * @param fileName A name for for the downloaded file.
  124129. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  124130. * to the src parameter of an <img> to display it
  124131. */
  124132. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  124133. }
  124134. }
  124135. declare module BABYLON {
  124136. /**
  124137. * A cursor which tracks a point on a path
  124138. */
  124139. export class PathCursor {
  124140. private path;
  124141. /**
  124142. * Stores path cursor callbacks for when an onchange event is triggered
  124143. */
  124144. private _onchange;
  124145. /**
  124146. * The value of the path cursor
  124147. */
  124148. value: number;
  124149. /**
  124150. * The animation array of the path cursor
  124151. */
  124152. animations: Animation[];
  124153. /**
  124154. * Initializes the path cursor
  124155. * @param path The path to track
  124156. */
  124157. constructor(path: Path2);
  124158. /**
  124159. * Gets the cursor point on the path
  124160. * @returns A point on the path cursor at the cursor location
  124161. */
  124162. getPoint(): Vector3;
  124163. /**
  124164. * Moves the cursor ahead by the step amount
  124165. * @param step The amount to move the cursor forward
  124166. * @returns This path cursor
  124167. */
  124168. moveAhead(step?: number): PathCursor;
  124169. /**
  124170. * Moves the cursor behind by the step amount
  124171. * @param step The amount to move the cursor back
  124172. * @returns This path cursor
  124173. */
  124174. moveBack(step?: number): PathCursor;
  124175. /**
  124176. * Moves the cursor by the step amount
  124177. * If the step amount is greater than one, an exception is thrown
  124178. * @param step The amount to move the cursor
  124179. * @returns This path cursor
  124180. */
  124181. move(step: number): PathCursor;
  124182. /**
  124183. * Ensures that the value is limited between zero and one
  124184. * @returns This path cursor
  124185. */
  124186. private ensureLimits;
  124187. /**
  124188. * Runs onchange callbacks on change (used by the animation engine)
  124189. * @returns This path cursor
  124190. */
  124191. private raiseOnChange;
  124192. /**
  124193. * Executes a function on change
  124194. * @param f A path cursor onchange callback
  124195. * @returns This path cursor
  124196. */
  124197. onchange(f: (cursor: PathCursor) => void): PathCursor;
  124198. }
  124199. }
  124200. declare module BABYLON {
  124201. /** @hidden */
  124202. export var blurPixelShader: {
  124203. name: string;
  124204. shader: string;
  124205. };
  124206. }
  124207. declare module BABYLON {
  124208. /** @hidden */
  124209. export var pointCloudVertexDeclaration: {
  124210. name: string;
  124211. shader: string;
  124212. };
  124213. }
  124214. // Mixins
  124215. interface Window {
  124216. mozIndexedDB: IDBFactory;
  124217. webkitIndexedDB: IDBFactory;
  124218. msIndexedDB: IDBFactory;
  124219. webkitURL: typeof URL;
  124220. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  124221. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  124222. WebGLRenderingContext: WebGLRenderingContext;
  124223. MSGesture: MSGesture;
  124224. CANNON: any;
  124225. AudioContext: AudioContext;
  124226. webkitAudioContext: AudioContext;
  124227. PointerEvent: any;
  124228. Math: Math;
  124229. Uint8Array: Uint8ArrayConstructor;
  124230. Float32Array: Float32ArrayConstructor;
  124231. mozURL: typeof URL;
  124232. msURL: typeof URL;
  124233. VRFrameData: any; // WebVR, from specs 1.1
  124234. DracoDecoderModule: any;
  124235. setImmediate(handler: (...args: any[]) => void): number;
  124236. }
  124237. interface HTMLCanvasElement {
  124238. requestPointerLock(): void;
  124239. msRequestPointerLock?(): void;
  124240. mozRequestPointerLock?(): void;
  124241. webkitRequestPointerLock?(): void;
  124242. /** Track wether a record is in progress */
  124243. isRecording: boolean;
  124244. /** Capture Stream method defined by some browsers */
  124245. captureStream(fps?: number): MediaStream;
  124246. }
  124247. interface CanvasRenderingContext2D {
  124248. msImageSmoothingEnabled: boolean;
  124249. }
  124250. interface MouseEvent {
  124251. mozMovementX: number;
  124252. mozMovementY: number;
  124253. webkitMovementX: number;
  124254. webkitMovementY: number;
  124255. msMovementX: number;
  124256. msMovementY: number;
  124257. }
  124258. interface Navigator {
  124259. mozGetVRDevices: (any: any) => any;
  124260. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124261. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124262. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124263. webkitGetGamepads(): Gamepad[];
  124264. msGetGamepads(): Gamepad[];
  124265. webkitGamepads(): Gamepad[];
  124266. }
  124267. interface HTMLVideoElement {
  124268. mozSrcObject: any;
  124269. }
  124270. interface Math {
  124271. fround(x: number): number;
  124272. imul(a: number, b: number): number;
  124273. }
  124274. interface WebGLRenderingContext {
  124275. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  124276. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  124277. vertexAttribDivisor(index: number, divisor: number): void;
  124278. createVertexArray(): any;
  124279. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  124280. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  124281. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  124282. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  124283. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  124284. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  124285. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  124286. // Queries
  124287. createQuery(): WebGLQuery;
  124288. deleteQuery(query: WebGLQuery): void;
  124289. beginQuery(target: number, query: WebGLQuery): void;
  124290. endQuery(target: number): void;
  124291. getQueryParameter(query: WebGLQuery, pname: number): any;
  124292. getQuery(target: number, pname: number): any;
  124293. MAX_SAMPLES: number;
  124294. RGBA8: number;
  124295. READ_FRAMEBUFFER: number;
  124296. DRAW_FRAMEBUFFER: number;
  124297. UNIFORM_BUFFER: number;
  124298. HALF_FLOAT_OES: number;
  124299. RGBA16F: number;
  124300. RGBA32F: number;
  124301. R32F: number;
  124302. RG32F: number;
  124303. RGB32F: number;
  124304. R16F: number;
  124305. RG16F: number;
  124306. RGB16F: number;
  124307. RED: number;
  124308. RG: number;
  124309. R8: number;
  124310. RG8: number;
  124311. UNSIGNED_INT_24_8: number;
  124312. DEPTH24_STENCIL8: number;
  124313. /* Multiple Render Targets */
  124314. drawBuffers(buffers: number[]): void;
  124315. readBuffer(src: number): void;
  124316. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  124317. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  124318. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  124319. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  124320. // Occlusion Query
  124321. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  124322. ANY_SAMPLES_PASSED: number;
  124323. QUERY_RESULT_AVAILABLE: number;
  124324. QUERY_RESULT: number;
  124325. }
  124326. interface WebGLProgram {
  124327. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  124328. }
  124329. interface EXT_disjoint_timer_query {
  124330. QUERY_COUNTER_BITS_EXT: number;
  124331. TIME_ELAPSED_EXT: number;
  124332. TIMESTAMP_EXT: number;
  124333. GPU_DISJOINT_EXT: number;
  124334. QUERY_RESULT_EXT: number;
  124335. QUERY_RESULT_AVAILABLE_EXT: number;
  124336. queryCounterEXT(query: WebGLQuery, target: number): void;
  124337. createQueryEXT(): WebGLQuery;
  124338. beginQueryEXT(target: number, query: WebGLQuery): void;
  124339. endQueryEXT(target: number): void;
  124340. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  124341. deleteQueryEXT(query: WebGLQuery): void;
  124342. }
  124343. interface WebGLUniformLocation {
  124344. _currentState: any;
  124345. }
  124346. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  124347. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  124348. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  124349. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124350. interface WebGLRenderingContext {
  124351. readonly RASTERIZER_DISCARD: number;
  124352. readonly DEPTH_COMPONENT24: number;
  124353. readonly TEXTURE_3D: number;
  124354. readonly TEXTURE_2D_ARRAY: number;
  124355. readonly TEXTURE_COMPARE_FUNC: number;
  124356. readonly TEXTURE_COMPARE_MODE: number;
  124357. readonly COMPARE_REF_TO_TEXTURE: number;
  124358. readonly TEXTURE_WRAP_R: number;
  124359. readonly HALF_FLOAT: number;
  124360. readonly RGB8: number;
  124361. readonly RED_INTEGER: number;
  124362. readonly RG_INTEGER: number;
  124363. readonly RGB_INTEGER: number;
  124364. readonly RGBA_INTEGER: number;
  124365. readonly R8_SNORM: number;
  124366. readonly RG8_SNORM: number;
  124367. readonly RGB8_SNORM: number;
  124368. readonly RGBA8_SNORM: number;
  124369. readonly R8I: number;
  124370. readonly RG8I: number;
  124371. readonly RGB8I: number;
  124372. readonly RGBA8I: number;
  124373. readonly R8UI: number;
  124374. readonly RG8UI: number;
  124375. readonly RGB8UI: number;
  124376. readonly RGBA8UI: number;
  124377. readonly R16I: number;
  124378. readonly RG16I: number;
  124379. readonly RGB16I: number;
  124380. readonly RGBA16I: number;
  124381. readonly R16UI: number;
  124382. readonly RG16UI: number;
  124383. readonly RGB16UI: number;
  124384. readonly RGBA16UI: number;
  124385. readonly R32I: number;
  124386. readonly RG32I: number;
  124387. readonly RGB32I: number;
  124388. readonly RGBA32I: number;
  124389. readonly R32UI: number;
  124390. readonly RG32UI: number;
  124391. readonly RGB32UI: number;
  124392. readonly RGBA32UI: number;
  124393. readonly RGB10_A2UI: number;
  124394. readonly R11F_G11F_B10F: number;
  124395. readonly RGB9_E5: number;
  124396. readonly RGB10_A2: number;
  124397. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  124398. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  124399. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  124400. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  124401. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  124402. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  124403. 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;
  124404. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  124405. readonly TRANSFORM_FEEDBACK: number;
  124406. readonly INTERLEAVED_ATTRIBS: number;
  124407. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  124408. createTransformFeedback(): WebGLTransformFeedback;
  124409. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  124410. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  124411. beginTransformFeedback(primitiveMode: number): void;
  124412. endTransformFeedback(): void;
  124413. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  124414. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124415. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124416. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  124417. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  124418. }
  124419. interface ImageBitmap {
  124420. readonly width: number;
  124421. readonly height: number;
  124422. close(): void;
  124423. }
  124424. interface WebGLQuery extends WebGLObject {
  124425. }
  124426. declare var WebGLQuery: {
  124427. prototype: WebGLQuery;
  124428. new(): WebGLQuery;
  124429. };
  124430. interface WebGLSampler extends WebGLObject {
  124431. }
  124432. declare var WebGLSampler: {
  124433. prototype: WebGLSampler;
  124434. new(): WebGLSampler;
  124435. };
  124436. interface WebGLSync extends WebGLObject {
  124437. }
  124438. declare var WebGLSync: {
  124439. prototype: WebGLSync;
  124440. new(): WebGLSync;
  124441. };
  124442. interface WebGLTransformFeedback extends WebGLObject {
  124443. }
  124444. declare var WebGLTransformFeedback: {
  124445. prototype: WebGLTransformFeedback;
  124446. new(): WebGLTransformFeedback;
  124447. };
  124448. interface WebGLVertexArrayObject extends WebGLObject {
  124449. }
  124450. declare var WebGLVertexArrayObject: {
  124451. prototype: WebGLVertexArrayObject;
  124452. new(): WebGLVertexArrayObject;
  124453. };
  124454. // Type definitions for WebVR API
  124455. // Project: https://w3c.github.io/webvr/
  124456. // Definitions by: six a <https://github.com/lostfictions>
  124457. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  124458. interface VRDisplay extends EventTarget {
  124459. /**
  124460. * Dictionary of capabilities describing the VRDisplay.
  124461. */
  124462. readonly capabilities: VRDisplayCapabilities;
  124463. /**
  124464. * z-depth defining the far plane of the eye view frustum
  124465. * enables mapping of values in the render target depth
  124466. * attachment to scene coordinates. Initially set to 10000.0.
  124467. */
  124468. depthFar: number;
  124469. /**
  124470. * z-depth defining the near plane of the eye view frustum
  124471. * enables mapping of values in the render target depth
  124472. * attachment to scene coordinates. Initially set to 0.01.
  124473. */
  124474. depthNear: number;
  124475. /**
  124476. * An identifier for this distinct VRDisplay. Used as an
  124477. * association point in the Gamepad API.
  124478. */
  124479. readonly displayId: number;
  124480. /**
  124481. * A display name, a user-readable name identifying it.
  124482. */
  124483. readonly displayName: string;
  124484. readonly isConnected: boolean;
  124485. readonly isPresenting: boolean;
  124486. /**
  124487. * If this VRDisplay supports room-scale experiences, the optional
  124488. * stage attribute contains details on the room-scale parameters.
  124489. */
  124490. readonly stageParameters: VRStageParameters | null;
  124491. /**
  124492. * Passing the value returned by `requestAnimationFrame` to
  124493. * `cancelAnimationFrame` will unregister the callback.
  124494. * @param handle Define the hanle of the request to cancel
  124495. */
  124496. cancelAnimationFrame(handle: number): void;
  124497. /**
  124498. * Stops presenting to the VRDisplay.
  124499. * @returns a promise to know when it stopped
  124500. */
  124501. exitPresent(): Promise<void>;
  124502. /**
  124503. * Return the current VREyeParameters for the given eye.
  124504. * @param whichEye Define the eye we want the parameter for
  124505. * @returns the eye parameters
  124506. */
  124507. getEyeParameters(whichEye: string): VREyeParameters;
  124508. /**
  124509. * Populates the passed VRFrameData with the information required to render
  124510. * the current frame.
  124511. * @param frameData Define the data structure to populate
  124512. * @returns true if ok otherwise false
  124513. */
  124514. getFrameData(frameData: VRFrameData): boolean;
  124515. /**
  124516. * Get the layers currently being presented.
  124517. * @returns the list of VR layers
  124518. */
  124519. getLayers(): VRLayer[];
  124520. /**
  124521. * Return a VRPose containing the future predicted pose of the VRDisplay
  124522. * when the current frame will be presented. The value returned will not
  124523. * change until JavaScript has returned control to the browser.
  124524. *
  124525. * The VRPose will contain the position, orientation, velocity,
  124526. * and acceleration of each of these properties.
  124527. * @returns the pose object
  124528. */
  124529. getPose(): VRPose;
  124530. /**
  124531. * Return the current instantaneous pose of the VRDisplay, with no
  124532. * prediction applied.
  124533. * @returns the current instantaneous pose
  124534. */
  124535. getImmediatePose(): VRPose;
  124536. /**
  124537. * The callback passed to `requestAnimationFrame` will be called
  124538. * any time a new frame should be rendered. When the VRDisplay is
  124539. * presenting the callback will be called at the native refresh
  124540. * rate of the HMD. When not presenting this function acts
  124541. * identically to how window.requestAnimationFrame acts. Content should
  124542. * make no assumptions of frame rate or vsync behavior as the HMD runs
  124543. * asynchronously from other displays and at differing refresh rates.
  124544. * @param callback Define the eaction to run next frame
  124545. * @returns the request handle it
  124546. */
  124547. requestAnimationFrame(callback: FrameRequestCallback): number;
  124548. /**
  124549. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  124550. * Repeat calls while already presenting will update the VRLayers being displayed.
  124551. * @param layers Define the list of layer to present
  124552. * @returns a promise to know when the request has been fulfilled
  124553. */
  124554. requestPresent(layers: VRLayer[]): Promise<void>;
  124555. /**
  124556. * Reset the pose for this display, treating its current position and
  124557. * orientation as the "origin/zero" values. VRPose.position,
  124558. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  124559. * updated when calling resetPose(). This should be called in only
  124560. * sitting-space experiences.
  124561. */
  124562. resetPose(): void;
  124563. /**
  124564. * The VRLayer provided to the VRDisplay will be captured and presented
  124565. * in the HMD. Calling this function has the same effect on the source
  124566. * canvas as any other operation that uses its source image, and canvases
  124567. * created without preserveDrawingBuffer set to true will be cleared.
  124568. * @param pose Define the pose to submit
  124569. */
  124570. submitFrame(pose?: VRPose): void;
  124571. }
  124572. declare var VRDisplay: {
  124573. prototype: VRDisplay;
  124574. new(): VRDisplay;
  124575. };
  124576. interface VRLayer {
  124577. leftBounds?: number[] | Float32Array | null;
  124578. rightBounds?: number[] | Float32Array | null;
  124579. source?: HTMLCanvasElement | null;
  124580. }
  124581. interface VRDisplayCapabilities {
  124582. readonly canPresent: boolean;
  124583. readonly hasExternalDisplay: boolean;
  124584. readonly hasOrientation: boolean;
  124585. readonly hasPosition: boolean;
  124586. readonly maxLayers: number;
  124587. }
  124588. interface VREyeParameters {
  124589. /** @deprecated */
  124590. readonly fieldOfView: VRFieldOfView;
  124591. readonly offset: Float32Array;
  124592. readonly renderHeight: number;
  124593. readonly renderWidth: number;
  124594. }
  124595. interface VRFieldOfView {
  124596. readonly downDegrees: number;
  124597. readonly leftDegrees: number;
  124598. readonly rightDegrees: number;
  124599. readonly upDegrees: number;
  124600. }
  124601. interface VRFrameData {
  124602. readonly leftProjectionMatrix: Float32Array;
  124603. readonly leftViewMatrix: Float32Array;
  124604. readonly pose: VRPose;
  124605. readonly rightProjectionMatrix: Float32Array;
  124606. readonly rightViewMatrix: Float32Array;
  124607. readonly timestamp: number;
  124608. }
  124609. interface VRPose {
  124610. readonly angularAcceleration: Float32Array | null;
  124611. readonly angularVelocity: Float32Array | null;
  124612. readonly linearAcceleration: Float32Array | null;
  124613. readonly linearVelocity: Float32Array | null;
  124614. readonly orientation: Float32Array | null;
  124615. readonly position: Float32Array | null;
  124616. readonly timestamp: number;
  124617. }
  124618. interface VRStageParameters {
  124619. sittingToStandingTransform?: Float32Array;
  124620. sizeX?: number;
  124621. sizeY?: number;
  124622. }
  124623. interface Navigator {
  124624. getVRDisplays(): Promise<VRDisplay[]>;
  124625. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  124626. }
  124627. interface Window {
  124628. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  124629. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  124630. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  124631. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124632. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  124633. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  124634. }
  124635. interface Gamepad {
  124636. readonly displayId: number;
  124637. }
  124638. type XRSessionMode =
  124639. | "inline"
  124640. | "immersive-vr"
  124641. | "immersive-ar";
  124642. type XRReferenceSpaceType =
  124643. | "viewer"
  124644. | "local"
  124645. | "local-floor"
  124646. | "bounded-floor"
  124647. | "unbounded";
  124648. type XREnvironmentBlendMode =
  124649. | "opaque"
  124650. | "additive"
  124651. | "alpha-blend";
  124652. type XRVisibilityState =
  124653. | "visible"
  124654. | "visible-blurred"
  124655. | "hidden";
  124656. type XRHandedness =
  124657. | "none"
  124658. | "left"
  124659. | "right";
  124660. type XRTargetRayMode =
  124661. | "gaze"
  124662. | "tracked-pointer"
  124663. | "screen";
  124664. type XREye =
  124665. | "none"
  124666. | "left"
  124667. | "right";
  124668. interface XRSpace extends EventTarget {
  124669. }
  124670. interface XRRenderState {
  124671. depthNear?: number;
  124672. depthFar?: number;
  124673. inlineVerticalFieldOfView?: number;
  124674. baseLayer?: XRWebGLLayer;
  124675. }
  124676. interface XRInputSource {
  124677. handedness: XRHandedness;
  124678. targetRayMode: XRTargetRayMode;
  124679. targetRaySpace: XRSpace;
  124680. gripSpace: XRSpace | undefined;
  124681. gamepad: Gamepad | undefined;
  124682. profiles: Array<string>;
  124683. }
  124684. interface XRSession {
  124685. addEventListener: Function;
  124686. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124687. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  124688. requestAnimationFrame: Function;
  124689. end(): Promise<void>;
  124690. renderState: XRRenderState;
  124691. inputSources: Array<XRInputSource>;
  124692. }
  124693. interface XRReferenceSpace extends XRSpace {
  124694. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  124695. onreset: any;
  124696. }
  124697. interface XRFrame {
  124698. session: XRSession;
  124699. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  124700. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  124701. }
  124702. interface XRViewerPose extends XRPose {
  124703. views: Array<XRView>;
  124704. }
  124705. interface XRPose {
  124706. transform: XRRigidTransform;
  124707. emulatedPosition: boolean;
  124708. }
  124709. declare var XRWebGLLayer: {
  124710. prototype: XRWebGLLayer;
  124711. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  124712. };
  124713. interface XRWebGLLayer {
  124714. framebuffer: WebGLFramebuffer;
  124715. framebufferWidth: number;
  124716. framebufferHeight: number;
  124717. getViewport: Function;
  124718. }
  124719. interface XRRigidTransform {
  124720. position: DOMPointReadOnly;
  124721. orientation: DOMPointReadOnly;
  124722. matrix: Float32Array;
  124723. inverse: XRRigidTransform;
  124724. }
  124725. interface XRView {
  124726. eye: XREye;
  124727. projectionMatrix: Float32Array;
  124728. transform: XRRigidTransform;
  124729. }
  124730. interface XRInputSourceChangeEvent {
  124731. session: XRSession;
  124732. removed: Array<XRInputSource>;
  124733. added: Array<XRInputSource>;
  124734. }